#include <iostream>
#define ll long long
using namespace std;

int main()
{
    int t,n,c,k2;
    bool provera = true;
    cin >> t;
    for (int k = 0; k < t; k++)
    {
        cin>>n;
        ll a[n], b[n];
        for(int i = 0; i < n; i++)
        {
            cin>>a[i];
        }
        for(int i = 0; i < n; i++)
        {
            cin>>b[i];
        }
        for(int i = 0; i < n && provera == true; i++)
        {
            for (int k =0; k < n && provera == true; k++)
            {
                if(abs(a[k]) == abs(b[i]))
                {
                    k2 = k;
                    while (k2 != i)
                    {
                        c = -a[k2-1];
                        a[k2-1] = -a[k2];
                        a[k2] = c;
                        k2 -= 1;
                    }
                    if(a[i] != b[i])
                    {
                        cout << "ne" << endl;
                        provera = false;
                    }
                }
            }
        }
        if (provera == false)
        {
            provera = true;
        }
        else{
            cout << "da" << endl;
        }
    }
    return 0;
}