#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
vector<int> fact(int n) {
  n = abs(n);
  vector<int> ans;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans.push_back(i);
      ans.push_back(n / i);
    }
  }
  return ans;
}
inline int getPow(int a, int b) {
  int res = 1ll, tp = a;
  while (b) {
    if (b & 1ll) {
      res *= tp;
    }
    tp *= tp;
    b >>= 1ll;
  }
  return res;
}
int vec_mult(int x1, int y1, int x2, int y2, int x3, int y3) {
  return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
}
void ok() {
  cout << "YES" << endl;
  exit(0);
}
void no() {
  cout << "NO" << endl;
  exit(0);
}
inline int nxt() {
  int x;
  cin >> x;
  return x;
}
const int N = 3e5 + 5, inf = 9e8;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
struct SegmentTreeMin {
  int n;
  vector<int> tree;
  vector<int> a;
  SegmentTreeMin(int n) {
    tree.resize(n * 4 + 1000);
    fill(tree.begin(), tree.end(), inf);
    a.resize(n + 2);
    this->n = n;
  }
  void build(int v, int l, int r) {
    if (l == r) {
      tree[v] = a[l];
    } else {
      int md = (l + r) / 2;
      build(v * 2, l, md);
      build(v * 2 + 1, md + 1, r);
      tree[v] = min(tree[v * 2], tree[v * 2 + 1]);
    }
  }
  void upd(int v, int l, int r, int ind, int val) {
    if (l > r || !(l <= ind && ind <= r)) return;
    if (l == r && l == ind) {
      tree[v] = val;
      return;
    }
    int md = (l + r) / 2;
    upd(v * 2, l, md, ind, val);
    upd(v * 2 + 1, md + 1, r, ind, val);
    tree[v] = min(tree[v * 2], tree[v * 2 + 1]);
  }
  void upd(int ind, int val) { upd(1, 0, n - 1, ind, val); }
  int get(int v, int l, int r, int tl, int tr) {
    if (l > tr || tl > r || l > r || tl > tr) return inf;
    if (l >= tl && r <= tr) return tree[v];
    int md = (r + l) / 2;
    return min(get(v * 2, l, md, tl, tr), get(v * 2 + 1, md + 1, r, tl, tr));
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int ttt = nxt();
  while (ttt--) {
    int n = nxt();
    SegmentTreeMin tree(n);
    for (int i = 0; i < n; i++) {
      tree.a[i] = nxt();
    }
    tree.build(1, 0, n - 1);
    bool f = 1;
    for (int i = 0; i < n; i++) {
      int x = nxt();
      int l = 0, r = n - 1;
      while (r - l > 1) {
        int md = (r + l) / 2;
        int cur = tree.get(1, 0, n - 1, 0, md);
        if (cur <= x) {
          r = md;
        } else {
          l = md;
        }
      }
      if (tree.get(1, 0, n - 1, 0, l) == x) {
        tree.upd(l, inf);
      } else if (tree.get(1, 0, n - 1, 0, r) == x) {
        tree.upd(r, inf);
      } else {
        f = 0;
      }
    }
    if (f) {
      cout << "YES\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
