#include <iostream>
#include <iomanip>
#include <queue>
#include <cstring>
#include <vector>
#include <stack>
using namespace std;
int note[100002];
int main()
{
int n, m, w, p;
cin >> n;
for (int i = 1; i <= n; i++)
{
stack<int> q;
queue<int> x;
int point = 0;
cin >> m;
for (int j = 0; j < m; j++)
{
cin >> w;
q.push(w);
}
for (int k = 0; k < m; k++)
{
cin >> p;
x.push(p);
}
while (!q.empty() && !x.empty())
{
int xxx = q.top();
q.pop();
int yyy = x.front();
x.pop();
if (xxx != yyy)
{
point = 1;
break;
}
}
if (point == 1)
{
cout << "No" << endl;
}
else
{
cout << "Yes" << endl;
}
}
return 0;
}