#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main(){
int t;
cin>>t;
while(t--){
stack<int>q;
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
cin>>b[i];
}
int zxc=a[n+1]=b[n+1]=1;
for(int i=1;i<=n;i++){
q.push(a[i]);
while(q.size()!=0&&b[zxc]==q.top()){
zxc++;
q.pop();
}
}
if(q.size()>0){
cout<<"NO\n";
}else{
cout<<"YES\n";
}
}
return 0;
}
大小写问题
No变NO,Yes变YES