import sys from sys import stdin tt = int(stdin.readline()) ANS = [] for loop in range(tt): N = int(stdin.readline()) A = list(map(int,stdin.readline().split())) B = list(map(int,stdin.readline().split())) flag = True for i in range(N): if A[i] > B[i]: flag = False able = [False] * N stk = [] stkset = set() for i in range(N): while len(stk) > 0 and stk[-1] <= A[i]: stkset.remove(stk[-1]) del stk[-1] stk.append(A[i]) stkset.add(A[i]) if B[i] in stkset: able[i] = True A.reverse() B.reverse() stk = [] stkset = set() for i in range(N): while len(stk) > 0 and stk[-1] <= A[i]: stkset.remove(stk[-1]) del stk[-1] stk.append(A[i]) stkset.add(A[i]) if B[i] in stkset: able[N-1-i] = True A.reverse() B.reverse() if False in able: flag = False B2 = [] for i in B: if len(B2) == 0 or B2[-1] != i: B2.append(i) for i in range(N-1,-1,-1): if len(B2) > 0 and B2[-1] == A[i]: del B2[-1] if B2: flag = False if flag: ANS.append("Yes") else: ANS.append("No") print ("\n".join(ANS))