#include <bits/stdc++.h>
using namespace std;
struct Dbg {
  template <typename T>
  Dbg& operator,(const T& v) {
    cerr << v << ", ";
    return *this;
  }
} Dbg;
template <typename T>
ostream& operator<<(ostream& _o_, const vector<T>& _v_) {
  if (!_v_.empty()) {
    _o_ << '[';
    copy(_v_.begin(), _v_.end(), ostream_iterator<T>(_o_, ", "));
    _o_ << "\b\b]";
  }
  return _o_;
}
template <class C>
void mini(C& _a, C _b) {
  _a = min(_a, _b);
}
template <class C>
void maxi(C& _a, C _b) {
  _a = max(_a, _b);
}
int a[300005], b[300005], tree[300005 * 4];
void build(int i, int L, int R) {
  if (L == R) {
    tree[i] = a[L];
    return;
  }
  int mid = (L + R) >> 1;
  build(i << 1, L, mid);
  build(i << 1 | 1, mid + 1, R);
  tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
}
int query(int i, int ql, int qr, int L, int R) {
  if (ql > R || qr < L) return 1e9;
  if (ql <= L && qr >= R) return tree[i];
  int mid = (L + R) >> 1;
  return min(query(i << 1, ql, qr, L, mid),
             query(i << 1 | 1, ql, qr, mid + 1, R));
}
int update(int ind, int L, int R, int pos, int val) {
  if (pos < L || pos > R) return tree[ind];
  if (L == pos && R == pos) {
    a[pos] = val;
    return tree[ind] = val;
  }
  int mid = (L + R) >> 1;
  int p1 = update(ind << 1, L, mid, pos, val),
      p2 = update(ind << 1 | 1, mid + 1, R, pos, val);
  return tree[ind] = min(p1, p2);
}
void solve() {
  int n;
  cin >> n;
  set<pair<int, int>> s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert({a[i], i});
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    auto it = s.lower_bound({b[i], -1});
    if (it == s.end() || it->first != b[i]) {
      ok = 0;
      break;
    }
    int ind = it->second;
    s.erase(it);
    if (b[i] != query(1, 1, ind, 1, n)) {
      ok = 0;
      break;
    }
    update(1, 1, n, ind, 1e9);
  }
  if (ok) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
