func_code_string: #include <bits/stdc++.h>   using namespace std;   map<int, vector<int>> pos;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n;       cin >> n;       vector<int> a(n), b(n);       for (int i = 0; i < n; i++) {         cin >> a[i];       }       for (int i = 0; i < n; i++) {         cin >> b[i];       }       pos.clear();       for (int i = n - 1; i >= 0; i--) {         pos[a[i]].push_back(i);       }       vector<int> tree(4 * n);       function<void(int, int, int)> build = [&](int v, int l, int r) {         if (l + 1 == r) {           tree[v] = a[l];           return;         }         int mid = (l + r) / 2;         build(2 * v, l, mid);         build(2 * v + 1, mid, r);         tree[v] = min(tree[2 * v], tree[2 * v + 1]);       };       function<int(int, int, int, int, int)> query_min =           [&](int ql, int qr, int v, int l, int r) {             if (ql <= l && r <= qr) return tree[v];             if (r <= ql || qr <= l) return int(1e6);             int mid = (l + r) / 2;             return min(query_min(ql, qr, 2 * v, l, mid),                        query_min(ql, qr, 2 * v + 1, mid, r));           };       function<void(int, int, int, int)> update = [&](int x, int v, int l,                                                       int r) {         if (l == x && r == l + 1) {           tree[v] = int(1e6);           return;         }         int mid = (l + r) / 2;         if (x < mid)           update(x, 2 * v, l, mid);         else           update(x, 2 * v + 1, mid, r);         tree[v] = min(tree[2 * v], tree[2 * v + 1]);       };       bool ok = true;       build(1, 0, n);       for (int i = 0; i < n; i++) {         if (pos[b[i]].size() == 0) {           ok = false;           break;         }         int x = pos[b[i]].back();         pos[b[i]].pop_back();         if (query_min(0, x + 1, 1, 0, n) != b[i]) {           ok = false;           break;         }         update(x, 1, 0, n);       }       if (ok)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }   