#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 15;
const int inf = 0x3f3f3f3f;
int a[N], b[N];
int seg[N << 2];
vector<int> vec[N];
unordered_set<int> st;
inline void init(int n) { memset(seg, 0x3f, (n + 1) * 4 * sizeof(int)); }
inline void update(int pos, int val, int l, int r, int rt) {
  if (l == r) {
    seg[rt] = val;
    return;
  }
  int m = (l + r) >> 1;
  if (pos <= m) {
    update(pos, val, l, m, rt << 1);
  } else {
    update(pos, val, m + 1, r, rt << 1 | 1);
  }
  seg[rt] = min(seg[rt << 1], seg[rt << 1 | 1]);
}
inline int query(int qr, int l, int r, int rt) {
  if (r <= qr) {
    return seg[rt];
  }
  int m = (l + r) >> 1;
  int ans = query(qr, l, m, rt << 1);
  if (m < qr) {
    ans = min(ans, query(qr, m + 1, r, rt << 1 | 1));
  }
  return ans;
}
bool solve(int n) {
  for (int i = 1; i <= n; i++) {
    int ele = b[i];
    if (!vec[ele].empty()) {
      int idx = vec[ele].back();
      if (query(idx, 1, n, 1) == b[i]) {
        update(idx, inf, 1, n, 1);
        vec[ele].pop_back();
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    init(n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      st.insert(a[i]);
      update(i, a[i], 1, n, 1);
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
    }
    for (int i = n; i >= 1; i--) {
      vec[a[i]].emplace_back(i);
    }
    puts(solve(n) ? "YES" : "NO");
    for (int ele : st) {
      vec[ele].clear();
    }
    st.clear();
  }
  return 0;
}
