def solve(N,A,B): for i in range(N): if A[i]>B[i]: return False X=[[0,0]] for i in range(1,N): if B[i-1]==B[i]: X[-1][1]+=1 else: X.append([i,i]) for x,y in X: alpha=0 for k in range(x,y+1): alpha=max(alpha,A[k]) if alpha!=B[x]: return False return True T=int(input()) for _ in range(T): N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) print("Yes" if solve(N,A,B) else "No")