#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 111;
const int INF = 1e9;
int nTest;
int n, A[N], B[N];
vector<int> V[N];
int ST[4 * N];
void Update(int id, int l, int r, int pos, int val) {
  if (pos < l || r < pos) return;
  if (l == r) {
    ST[id] = val;
    return;
  }
  int mid = (l + r) >> 1;
  Update(2 * id, l, mid, pos, val);
  Update(2 * id + 1, mid + 1, r, pos, val);
  ST[id] = min(ST[2 * id], ST[2 * id + 1]);
}
int Get(int id, int l, int r, int u, int v) {
  if (v < l || r < u) return INF;
  if (u <= l && r <= v) return ST[id];
  int mid = (l + r) >> 1;
  return min(Get(2 * id, l, mid, u, v), Get(2 * id + 1, mid + 1, r, u, v));
}
void Solve() {
  for (int i = 1; i <= n; ++i) V[i].clear();
  for (int i = 1; i < 4 * n; ++i) ST[i] = INF;
  for (int i = n; i >= 1; --i) V[A[i]].push_back(i);
  for (int i = 1; i <= n; ++i) {
    if (V[i].empty())
      Update(1, 1, n, i, INF);
    else
      Update(1, 1, n, i, V[i].back());
  }
  for (int i = 1; i <= n; ++i) {
    if (V[B[i]].empty()) {
      cout << "NO\n";
      return;
    }
    if (V[B[i]].back() > Get(1, 1, n, 1, B[i] - 1)) {
      cout << "NO\n";
      return;
    }
    V[B[i]].pop_back();
    if (V[B[i]].empty())
      Update(1, 1, n, B[i], INF);
    else
      Update(1, 1, n, B[i], V[B[i]].back());
  }
  cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> nTest;
  while (nTest--) {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> A[i];
    for (int i = 1; i <= n; ++i) cin >> B[i];
    Solve();
  }
  return 0;
}
