def count_gold_placements(notes): MOD = 10**9 + 7 n = len(notes) westmost_gold, eastmost_gold = float('-inf'), float('inf') gold_pos = set() unknowns = 0 for i, note in enumerate(notes): if note == 'o': gold_pos.add(i) westmost_gold = max(westmost_gold, i) eastmost_gold = min(eastmost_gold, i) elif note == '<': eastmost_gold = min(eastmost_gold, i) elif note == '>': westmost_gold = max(westmost_gold, i) elif note == '.': unknowns += 1 if westmost_gold > eastmost_gold: return 0 if len(gold_pos) == 0: return pow(2, unknowns, MOD) count = 0 for i in range(westmost_gold, eastmost_gold+1): if i not in gold_pos: count += 1 return pow(2, unknowns, MOD) * count % MOD t = int(input()) for case in range(1, t+1): notes = input().strip() print(f"Case #{case}: {count_gold_placements(notes)}")