#include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) namespace rmq{ using S = int; S op(S l, S r){ return min(l,r); } S e(){ return 1001001001; } using rmq = atcoder::segtree; } namespace rurmq{ using S = int; S e(){ return -1; } S op(S l, S r){ return e(); } using F = int; S mapping(F f, S x){ if(f == -1) return x; return f; } F composition(F f, F x){ if(f == -1) return x; return f; } F id(){ return -1; } using rurmq = atcoder::lazy_segtree; } struct non_less_than{ int a; bool operator()(int x) const { return a <= x; } }; struct greater_than{ int a; bool operator()(int x) const { return a <= x; } }; bool testcase(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; vector B(N); rep(i,N) cin >> B[i]; rmq::rmq rmqB(B); vector idxA(N); rep(i,N) idxA[i] = i; sort(idxA.begin(), idxA.end(), [&](int l, int r)->bool{ return A[l] < A[r]; }); rurmq::rurmq ruqB(N); for(int p : idxA){ int l = rmqB.min_left(p, non_less_than{A[p]}); int r = rmqB.max_right(p+1, non_less_than{A[p]}); ruqB.apply(l,r,A[p]); } rep(i,N) if(B[i] != ruqB.get(i)) return false; return true; } int main(){ int T; cin >> T; rep(i,T){ if(testcase()) cout << "Yes\n"; else cout << "No\n"; } return 0; } struct ios_do_not_sync { ios_do_not_sync() { ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;