#include <bits/stdc++.h>
using namespace std;
int s[300005];
queue<int> ve[300005];
int b[300005];
struct node {
  int l, r, v;
} tr[300005 * 4];
void push_up(int id) { tr[id].v = min(tr[id << 1].v, tr[id << 1 | 1].v); }
void build(int id, int l, int r) {
  tr[id].l = l;
  tr[id].r = r;
  if (l == r) {
    tr[id].v = s[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  push_up(id);
}
void update(int id, int l, int c) {
  if (l == tr[id].l && tr[id].r == l) {
    tr[id].v = c;
    return;
  }
  int mid = (tr[id].l + tr[id].r) >> 1;
  if (l <= mid)
    update(id << 1, l, c);
  else
    update(id << 1 | 1, l, c);
  push_up(id);
}
int query(int id, int l, int r) {
  if (tr[id].l >= l && tr[id].r <= r) return tr[id].v;
  int mid = (tr[id].l + tr[id].r) >> 1;
  if (r <= mid)
    return query(id << 1, l, r);
  else if (l > mid)
    return query(id << 1 | 1, l, r);
  else {
    int a = query(id << 1, l, mid);
    int b = query(id << 1 | 1, mid + 1, r);
    return min(a, b);
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &s[i]), ve[s[i]].push(i);
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    build(1, 1, n);
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      if (!ve[b[i]].empty()) {
        int v = ve[b[i]].front();
        ve[b[i]].pop();
        if (query(1, 1, v) != b[i])
          flag = 0;
        else
          update(1, v, INT_MAX);
      } else
        flag = 0;
      if (!flag) break;
    }
    for (int i = 1; i <= n; i++)
      while (!ve[s[i]].empty()) ve[s[i]].pop();
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
