#include <bits/stdc++.h>
using namespace std;
int stree[4 * 300010];
vector<int> indexes[300010];
int a[300010];
int make(int l, int r, int x) {
  if (l == r) {
    stree[x] = a[l];
    return stree[x];
  }
  int mid = (l + r) / 2;
  stree[x] = min(make(l, mid, 2 * x + 1), make(mid + 1, r, 2 * x + 2));
  return stree[x];
}
int query(int l, int r, int s, int e, int x) {
  if (s >= l && e <= r) return stree[x];
  if (s > r || e < l) return 1e8;
  int mid = (s + e) / 2;
  return min(query(l, r, s, mid, 2 * x + 1),
             query(l, r, mid + 1, e, 2 * x + 2));
}
int update(int pos, int s, int e, int x) {
  if (pos > e || pos < s) return stree[x];
  if (s == e) {
    stree[x] = 1e8;
    return stree[x];
  }
  int mid = (s + e) / 2;
  stree[x] =
      min(update(pos, s, mid, 2 * x + 1), update(pos, mid + 1, e, 2 * x + 2));
  return stree[x];
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n + 5; i++) indexes[i].clear();
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      indexes[a[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) cin >> b[i];
    make(0, n - 1, 0);
    vector<int> eleused(n + 5, 0);
    bool possible = true;
    for (int i = 0; i < b.size(); i++) {
      if (eleused[b[i]] == indexes[b[i]].size()) {
        possible = false;
        break;
      }
      int pos = indexes[b[i]][eleused[b[i]]];
      eleused[b[i]]++;
      int mini = query(0, pos, 0, n - 1, 0);
      if (mini < b[i]) {
        possible = false;
        break;
      }
      a[pos] = 1e8;
      update(pos, 0, n - 1, 0);
    }
    if (possible)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
