t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] ok = True l = 0 r = 0 while l < n: for i in range(l, n - 1): if b[i + 1] != b[i]: r = i break r = i + 1 aMax = max(a[l:(r + 1)]) if aMax != b[l]: ok = False break l = r + 1 r = l if ok: print("Yes") else: print("No")