#include <bits/stdc++.h>
using namespace std;
int A[1 << 20];
void build(int x, int l, int r, vector<int> &v) {
  if (l == r)
    A[x] = v[l];
  else {
    int n = x << 1;
    int mid = (l + r) >> 1;
    build(n, l, mid, v);
    build(n + 1, mid + 1, r, v);
    A[x] = min(A[n], A[n + 1]);
  }
}
void upd(int x, int l, int r, int a, int b, int v) {
  if (r < a || b < l) return;
  if (a <= l && r <= b) {
    A[x] = v;
    return;
  }
  int mid = (l + r) >> 1;
  int n = x << 1;
  upd(n, l, mid, a, b, v);
  upd(n + 1, mid + 1, r, a, b, v);
  A[x] = min(A[n], A[n + 1]);
}
int query(int x, int l, int r, int a, int b) {
  if (r < a || b < l) return 1 << 20;
  if (a <= l && r <= b) return A[x];
  int mid = (l + r) >> 1;
  int n = x << 1;
  int u = query(n, l, mid, a, b);
  int v = query(n + 1, mid + 1, r, a, b);
  return min(u, v);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> b(n);
    for (auto &e : a) scanf("%d", &e);
    for (auto &e : b) scanf("%d", &e);
    vector<queue<int>> pos(n + 1);
    for (int i = 0; i < n; i++) pos[a[i]].push(i);
    build(1, 0, n - 1, a);
    bool ok = true;
    vector<bool> seen(n);
    for (int i = 0, j = 0; ok && i < n && j < n; i++, j++) {
      if (seen[i]) {
        j--;
        continue;
      }
      if (a[i] == b[j]) {
        pos[a[i]].pop();
        continue;
      }
      if (pos[b[j]].empty()) {
        ok = false;
        break;
      }
      int npos = pos[b[j]].front();
      pos[b[j]].pop();
      int q = query(1, 0, n - 1, i, npos);
      if (q != b[j]) {
        ok = false;
        continue;
      }
      upd(1, 0, n - 1, npos, npos, n + 1);
      seen[npos] = true;
      i--;
    }
    printf("%s\n", ok ? "YES" : "NO");
  }
  return 0;
}
