#include <iostream>
#include <stack>
#define max 100005
using namespace std;
int p,n;
int x,l;
int main() {
int t;
cin>>t;
while(t--) {
cin>>l;
n=l;
stack<int>q;
while(n--) {
cin>>x;
q.push(x);
}
n=l;
int flag=1;
while(n--) {
cin>>x;
if(!q.empty()) {
if(x!=q.top()) {
flag=0;
}
q.pop();
}
}
if(flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
flag=1;
}
return 0;
}