#include <bits/stdc++.h>
using namespace std;
int ar[300009], ar2[300009], br[300009], ars[300009], brs[300009];
int main() {
  int i, j, a, b, ts, f = 1, cn = 0, n, am, bm, t;
  scanf("%d", &ts);
  while (ts--) {
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
      scanf("%d", &ar[i]);
      ar2[i] = ars[i] = ar[i];
    }
    for (i = 0; i < n; i++) {
      scanf("%d", &br[i]);
      brs[i] = br[i];
    }
    sort(ars, ars + n);
    sort(brs, brs + n);
    for (i = 0; i < n; i++) {
      if (ars[i] != brs[i]) break;
    }
    if (i < n) {
      puts("NO");
      continue;
    }
    for (i = 0; i < n; i++) {
      if (br[i] != ars[i]) break;
    }
    if (i == n) {
      puts("YES");
      continue;
    }
    am = bm = 0;
    for (i = 0; i < n; i++) {
      am = max(ar[i], am);
      bm = max(br[i], bm);
      if (bm > am) break;
    }
    if (i < n) {
      puts("NO");
      continue;
    }
    for (i = 0; i < n; i++) {
      if (ar[i] > br[i]) {
        j = i + 1;
        t = ar[i];
        while (br[i] < ar[j]) {
          swap(t, ar[j]);
          j++;
        }
        ar[i] = ar[j];
        ar[j] = t;
      }
      if (ar[i] != br[i]) break;
    }
    if (i == n) {
      puts("YES");
      continue;
    }
    puts("NO");
  }
  return 0;
}
