#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
int t, n, a[N], b[N];
stack<int> pos[N + 1];
int f[N];
int init(int i, int j) {
  if (i == j) return a[i];
  int k = (i + j) / 2;
  return f[k] = max(init(i, k), init(k + 1, j));
}
int query(int i, int j, int x, int y) {
  if (x == y) return a[x];
  int k = (i + j) / 2;
  if (i == x && j == y) return f[k];
  if (y <= k) return query(i, k, x, y);
  if (k + 1 <= x) return query(k + 1, j, x, y);
  return max(query(i, k, x, k), query(k + 1, j, k + 1, y));
}
int modify(int i, int j, int x, int val) {
  if (i == j) return a[i] = val;
  int k = (i + j) / 2;
  if (x <= k)
    return f[k] = max(modify(i, k, x, val), query(k + 1, j, k + 1, j));
  return f[k] = max(query(i, k, i, k), modify(k + 1, j, x, val));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) stack<int>().swap(pos[i]);
    for (int i = 0; i < n; i++) pos[a[i]].push(i);
    init(0, n - 1);
    bool sol = true;
    int i = n - 1;
    for (int j = n - 1; 0 <= j; j--) {
      if (a[i] > b[j] || pos[b[j]].empty()) {
        sol = false;
        break;
      }
      if (pos[b[j]].top() + 1 <= i) {
        if (query(0, n - 1, pos[b[j]].top() + 1, i) > b[j]) {
          sol = false;
          break;
        }
      }
      modify(0, n - 1, pos[b[j]].top(), -1);
      pos[b[j]].pop();
      while (0 <= i && a[i] == -1) i--;
    }
    cout << (sol ? "YES" : "NO") << "\n";
  }
  return 0;
}
