wo488 @ 2024-10-14 19:02:15
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int i;
vector<int>re(n);
int k = 0;
for (i = 0; i < n; i++) {
int q;
int j;
int t = 0;
stack<int>ss;
scanf("%d", &q);
vector<int>a(q);
vector<int>b(q);
for (j = 0; j < q; j++) {
cin >> a[j];
}
for (j = 0; j < q; j++) {
cin >> b[j];
}
for (j = 0; j < q; j++) {
ss.push(a[j]);
}
int flag = 1;
while (!ss.empty())
{
int x = ss.top();
if (x != b[t++]) {
flag = 0;
break;
}
ss.pop();
}
if (flag == 1)
re[k++] = 1;
else
re[k++] = 0;
}
for (i = 0; i < n; i++) {
if (re[i] == 1)
printf("YES\n");
else
printf("NO\n");
}
}