#include<iostream>
#include<stack>
using namespace std;
stack<int>a;
int z;//询问次数
int n;//序列长度
int x;//序列的数
int main() {
cin >> z;
int answer[z+1]={};
for (int i = 1; i <= z; i++) {
cin >> n;
int testout[n + 1] = {};
for (int j = 1; j <= n; j++) {
cin >> x;
a.push(x);
}
for (int j = 1; j <= n; j++) {
cin >> testout[j];
int tmp = a.top(); //出栈
a.pop();//删栈顶
if(tmp!=testout[j]){
answer[i]=1;
}
}
}
for(int i=1;i<=z;i++){
if(answer[i]){
cout<<"No"<<endl;
}else{
cout<<"Yes"<<endl;
}
}
return 0;
}
感觉没错......