#include<iostream>
#include<stack>
using namespace std;
typedef long long LL;
const LL N=100001;
LL Push[N],Pop[N];
LL Read(){
LL f=1,num=0;
for(char ch=getchar();ch>=48&&ch<=57||ch==45;ch=getchar())
ch==45?f=-1:num=(num<<1)+(num<<3)+(ch^48);
return f*num;
}int main(){
for(LL q=Read();q--;){
LL n=Read();
for(LL i=1;i<=n;i++)Push[i]=Read();
for(LL i=1;i<=n;i++)Pop[i]=Read();
stack<LL> sta;
for(LL i=1,j=1;i<=n;i++){
sta.push(Push[i]);
while(!sta.empty()&&(sta.top())==Pop[j])sta.pop(),j++;
}cout<<(sta.empty()?"Yes\n":"No\n");
}return 0;
}
求调,大佬,~~我以跪下感救命之恩!~