import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); while(t-- > 0) { int n = sc.nextInt(); SegmentTree st = new SegmentTree(n); for (int i = 0; i < n; i++) { st.setValue(i, sc.nextInt()); } int prev = sc.nextInt(); int idx = 0; boolean enable = true; for (int i = 1; i < n; i++) { int current = sc.nextInt(); if (current != prev) { enable &= (st.getMax(idx, i) == prev); idx = i; prev = current; } } enable &= (st.getMax(idx, n) == prev); if (enable) { sb.append("Yes\n"); } else { sb.append("No\n"); } } System.out.print(sb); } static class SegmentTree { int size; int[] tree; public SegmentTree(int size) { this.size = 1; while (size > this.size) { this.size <<= 1; } tree = new int[this.size * 2 - 1]; } public void setValue(int idx, int value) { updateTree(size - 1 + idx, value); } private void updateTree(int idx, int value) { tree[idx] = Math.max(tree[idx], value); if (idx > 0) { updateTree((idx - 1) / 2, tree[idx]); } } public int getMax(int left, int right) { return getMax(0, 0, size, left, right); } private int getMax(int idx, int min, int max, int left, int right) { if (left <= min && max <= right) { return tree[idx]; } else if (right <= min || max <= left) { return 0; } else { return Math.max(getMax(idx * 2 + 1, min, (min + max) / 2, left, right), getMax(idx * 2 + 2, (min + max) / 2, max, left, right)); } } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }