T = int(input()) def calc(A,B): N = len(A) now = A[0] right = 0 for left in range(N): if A[left] > B[left]: return False if (left > 0 and A[left-1] == B[left]) or A[left] == B[left]: if right == left: right += 1 continue while right < N and A[right] != B[left]: if A[right] > B[left]: return False right += 1 if right == N: return False for j in range(left,right): A[j] = B[left] if right == left: right += 1 return True for _ in range(T): N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) if calc(A,B): print('Yes') else: print('No')