#include <bits/stdc++.h>
using namespace std;
template <class T>
constexpr T lcm(T m, T n) {
  return m / __gcd(m, n) * n;
}
template <typename I>
void join(ostream &ost, I s, I t, string d = " ") {
  for (auto i = s; i != t; ++i) {
    if (i != s) ost << d;
    ost << *i;
  }
  ost << endl;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &a : v) is >> a;
  return is;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
bool chmin(T &a, const U &b) {
  return (a > b ? a = b, true : false);
}
template <typename T, typename U>
bool chmax(T &a, const U &b) {
  return (a < b ? a = b, true : false);
}
template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}
template <typename T>
class SegmentTree {
 private:
  int size;
  vector<T> vec;
  T e;
  function<T(T, T)> f, upd;
  inline T aux(int x, int y, int i, int l, int r) {
    if (r <= x || y <= l)
      return e;
    else if (x <= l && r <= y)
      return vec[i];
    else
      return f(aux(x, y, i * 2 + 1, l, (l + r) / 2),
               aux(x, y, i * 2 + 2, (l + r) / 2, r));
  };

 public:
  SegmentTree(int n, const T &e, const function<T(T, T)> &f,
              const function<T(T, T)> &upd)
      : e(e), f(f), upd(upd) {
    size = 1;
    while (size < n) size *= 2;
    size = size * 2 - 1;
    vec = vector<T>(size, e);
  }
  inline void update(int i, const T &x) {
    int j = i + (size + 1) / 2 - 1;
    vec[j] = upd(vec[j], x);
    --j;
    while (j >= 0) {
      vec[j / 2] = f(vec[(j / 2) * 2 + 1], vec[(j / 2) * 2 + 2]);
      (j /= 2) -= 1;
    }
  }
  inline T get(int x, int y) { return aux(x, y, 0, 0, (size + 1) / 2); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    cin >> a >> b;
    bool ans = true;
    SegmentTree<int> seg(
        n + 1, INT_MAX, [](int a, int b) { return min(a, b); },
        [](int a, int b) { return b; });
    vector<queue<int>> pos(n + 1);
    for (long long int i = (0); i < (n); ++i) {
      if (pos[a[i]].empty()) seg.update(a[i], i);
      pos[a[i]].push(i);
    }
    for (long long int i = (0); i < (n); ++i) {
      if (pos[b[i]].empty()) {
        ans = false;
        break;
      }
      int j = pos[b[i]].front();
      if (seg.get(0, b[i]) <= j) {
        ans = false;
        break;
      }
      pos[b[i]].pop();
      if (pos[b[i]].empty())
        seg.update(b[i], INT_MAX);
      else
        seg.update(b[i], pos[b[i]].front());
    }
    cout << (ans ? "YES" : "NO") << endl;
  }
  return 0;
}
