from sys import stdin input = stdin.readline Q = int(input()) stack = [] def check(stack): if len(stack) >= 3 and stack[-1] == ")" and stack[-2] == "|" and stack[-3] == "(": stack.pop() stack.pop() stack.pop() return check(stack) return stack for _ in range(Q): temp = list(map(str, input().strip().split())) n, s = int(temp[0]), temp[1] for c in s: stack.append(c) stack = check(stack) if len(stack) == 0: print("Yes") else: print("No")