#include<iostream>
#include<stack>
using namespace std;
#define Maxsize 100005
int q, n, head = 1, i, j;
int Test[Maxsize], Ver[Maxsize];
int main()
{
cin >> q;
for (i = 0; i < q; i++)
{
stack<int> s;
cin >> n;
for (j = 1; j <= n; j++)
{
cin >> Test[j];
}
for (j = 1; j <= n; j++)
{
cin >> Ver[j];
}
for (j = 1; j <= n; j++)
{
s.push(Test[j]);
while (Ver[head] == s.top())
{
s.pop();
head++;
if (s.empty())
break;
}
}
if (s.empty())
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}