#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const long long MOD = 1e9 + 7;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline int lb(int x) { return x & -x; }
long long qpow(long long base, int n) {
  if (base == 0) return 0;
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= base;
    n >>= 1;
    base *= base;
  }
  return ans;
}
int T, n;
int tr[maxn * 4];
queue<int> qu[maxn];
int a[maxn], b[maxn];
inline void push_up(int p) { tr[p] = min(tr[p * 2], tr[p * 2 + 1]); }
void build(int l, int r, int p) {
  if (l == r) {
    if (qu[l].empty())
      tr[p] = maxn;
    else
      tr[p] = qu[l].front();
    return;
  }
  int mi = (l + r) >> 1;
  build(l, mi, p * 2);
  build(mi + 1, r, p * 2 + 1);
  push_up(p);
}
void update(int l, int r, int u, int p) {
  if (l == u && r == u) {
    qu[u].pop();
    if (qu[u].empty())
      tr[p] = maxn;
    else
      tr[p] = qu[u].front();
    return;
  }
  int mi = (l + r) >> 1;
  if (u <= mi)
    update(l, mi, u, p * 2);
  else
    update(mi + 1, r, u, p * 2 + 1);
  push_up(p);
}
int query(int s, int t, int l, int r, int p) {
  if (s <= l && r <= t) return tr[p];
  int res = maxn;
  int mi = (l + r) >> 1;
  if (t <= mi)
    res = min(res, query(s, t, l, mi, p * 2));
  else if (s > mi)
    res = min(res, query(s, t, mi + 1, r, p * 2 + 1));
  else {
    res = min(res, query(s, mi, l, mi, p * 2));
    res = min(res, query(mi + 1, t, mi + 1, r, p * 2 + 1));
  }
  return res;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
    for (int i = (1); i <= (n); ++i) scanf("%d", &b[i]);
    for (int i = (1); i <= (n); ++i) qu[a[i]].push(i);
    build(1, n, 1);
    bool flag = 1;
    for (int i = (1); i <= (n); ++i) {
      if (qu[b[i]].empty()) {
        printf("NO\n");
        flag = 0;
        break;
      }
      int to = qu[b[i]].front();
      int tmp = query(1, b[i], 1, n, 1);
      if (tmp < to) {
        printf("NO\n");
        flag = 0;
        break;
      } else {
        update(1, n, b[i], 1);
      }
    }
    if (flag) printf("YES\n");
    for (int i = (1); i <= (n); ++i) {
      queue<int> empty;
      swap(empty, qu[i]);
    }
  }
}
