#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 300005;
int t, st[N * 4];
void upd(int node, int l, int r, int pos, int val) {
  if (l == r) {
    st[node] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= pos) {
    upd(node << 1, l, mid, pos, val);
  } else {
    upd(node << 1 | 1, mid + 1, r, pos, val);
  }
  st[node] = min(st[node << 1], st[node << 1 | 1]);
}
int q(int node, int l, int r, int s, int d) {
  if (l > d || r < s) {
    return 1e9;
  }
  if (l >= s && d >= r) {
    return st[node];
  }
  int mid = (l + r) >> 1;
  return min(q(node << 1, l, mid, s, d), q(node << 1 | 1, mid + 1, r, s, d));
}
void solve() {
  int n, m, x;
  bool good = true;
  cin >> n;
  int b[n + 5];
  for (int i = 1; i <= n * 4; i++) {
    st[i] = 1e9;
  }
  queue<int> vek[n + 5];
  for (int i = 1; i <= n; i++) {
    cin >> x;
    upd(1, 1, n, i, x);
    vek[x].push(i);
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    x = b[i];
    if (vek[x].empty()) {
      good = false;
      break;
    }
    int pos = vek[x].front();
    vek[x].pop();
    int val = q(1, 1, n, 1, pos);
    if (val != x) {
      good = false;
      break;
    }
    upd(1, 1, n, pos, 1e9);
  }
  good ? cout << "YES\n" : cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
