#include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} templatestruct SegmentTree{ int sz; vector data; SegmentTree(int n){ sz=1; while(sz v){ rep(i,0,v.size())data[i+sz]=v[i]; for(int k=sz-1;k>0;k--)data[k]=f(data[2*k],data[2*k+1]); } void set(int k,const M &x){ k+=sz; data[k]=x; while(k>>=1)data[k]=f(data[2*k],data[2*k+1]); } void update(int k,const N &x){ k+=sz; data[k]=g(data[k],x); while(k>>=1)data[k]=f(data[2*k],data[2*k+1]); } M query(int a,int b){ M L=m1(),R=m1(); for(a+=sz,b+=sz;a>=1,b>>=1){ if(a&1)L=f(L,data[a++]); if(b&1)R=f(data[--b],R); } return f(L,R); } M operator[](const int &k)const{return data[k+sz];} }; int f(int a,int b){return max(a,b);} int g(int a,int b){return b;} int e(){return 0;} void solve(int _rot){ // printf("Case #%d: ",_rot); int n; cin>>n; vector a(n),b(n); rep(i,0,n)cin>>a[i]; rep(i,0,n)cin>>b[i]; rep(i,0,n)if(a[i]>b[i]){ puts("No"); return; } SegmentTree seg(n); seg.run(a); vector pos(n+1,vector()); rep(i,0,n)pos[a[i]].push_back(i); rep(i,0,n){ if(pos[b[i]].empty()){ puts("No"); return; } bool ng=1; int id=lower_bound(ALL(pos[b[i]]),i)-pos[b[i]].begin(); if(id!=pos[b[i]].size()){ if(seg.query(i,pos[b[i]][id]+1)<=b[i])ng=0; } if(id){ if(seg.query(i,pos[b[i]][id-1]+1)<=b[i])ng=0; } if(ng){ puts("No"); return; } } puts("Yes"); } int main(){ int t; scanf("%d",&t); rep(rot,0,t)solve(rot+1); return 0; }