#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int tree[4 * N], n, base;
void update(int idx, int val) {
  idx += base;
  tree[idx] = val;
  for (idx /= 2; idx >= 1; idx /= 2)
    tree[idx] = min(tree[2 * idx], tree[2 * idx + 1]);
}
int query(int a, int b) {
  a += base;
  b += base;
  int ret = n;
  while (a <= b) {
    if (a % 2 == 1) ret = min(ret, tree[a++]);
    if (b % 2 == 0) ret = min(ret, tree[b--]);
    a /= 2;
    b /= 2;
  }
  return ret;
}
bool solve() {
  cin >> n;
  base = 1;
  while (base <= n + 1) {
    base *= 2;
  }
  for (int i = 0; i < 2 * base; i++) tree[i] = n;
  int A[n], B[n];
  for (auto &v : A) cin >> v;
  for (auto &v : B) cin >> v;
  stack<int> s[n + 1];
  for (int i = 0; i <= n; i++) s[i].push(n);
  for (int i = n - 1; i >= 0; i--) s[A[i]].push(i);
  for (int i = 0; i <= 4 * n + 10; i++) tree[i] = n;
  for (int i = 1; i <= n; i++) {
    update(i, s[i].top());
  }
  for (int i = 0; i < n; i++) {
    int &v = B[i];
    if (s[v].top() == n) return false;
    int q;
    if (v != 1) {
      q = query(1, v - 1);
      if (q < s[v].top()) return false;
    }
    s[v].pop();
    update(v, s[v].top());
  }
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    if (solve())
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
