from collections import defaultdict import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) def RunLengthEncoding(S): res = [] N = len(S) i = 0 while i < N: cnt = 1 while i < N - 1 and S[i] == S[i + 1]: cnt += 1 i += 1 res.append(S[i]) i += 1 return res def F(N, A, B): for i in range(N): if A[i] > B[i]: return False pos = defaultdict(list) for i, a in enumerate(A): pos[a].append(i) i = 0 idx = defaultdict(int) for b in RunLengthEncoding(B): while idx[b] < len(pos[b]) and pos[b][idx[b]] < i: idx[b] += 1 if idx[b] >= len(pos[b]): return False i = pos[b][idx[b]] return True T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) if F(N, A, B): print("Yes") else: print("No")