MOD = 10**9 + 7 def solve(s): n = len(s) left_dist = [None] * n right_dist = [None] * n gold_pos = set() for i in range(n): if s[i] == '<': left_dist[i] = 0 elif i > 0 and left_dist[i-1] is not None: left_dist[i] = left_dist[i-1] + 1 if s[n-i-1] == '>': right_dist[n-i-1] = 0 elif i > 0 and right_dist[n-i] is not None: right_dist[n-i-1] = right_dist[n-i] + 1 if s[i] == 'o': gold_pos.add(i) ans = 0 for i in range(n): if s[i] == '.': left = left_dist[i] if left_dist[i] is not None else n right = right_dist[i] if right_dist[i] is not None else n count = len(gold_pos.intersection(range(i-left, i+right+1))) ans = (ans + pow(2, count, MOD)) % MOD return ans # Read input t = int(input()) for case in range(1, t+1): s = input().strip() ans = solve(s) print(f"Case #{case}: {ans}")