import re n = int(input()) for _ in range(n): s = input() print(re.sub(' ([(0-9]+) ', f" {str(list(map(lambda x: int(x) + 1, re.findall(' ([0-9]+) ', s)))[0])} ", s))