def solve(): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) lst = [] l = 0 b = B[0] for r in range(n): if B[r] != b: lst.append((l, r - 1, b)) l = r b = B[r] lst.append((l, n - 1, b)) for l, r, b in lst: max_ = 0 for i in range(l, r + 1): max_ = max(max_, A[i]) if max_ != b: print("No") return print("Yes") for _ in range(int(input())): solve()