#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
using namespace std;

const int NMAX=1000005;

int t,n,m,k,len,oras[NMAX],st[NMAX],which[NMAX];
int b[NMAX],c[NMAX],d[NMAX],last[NMAX];
vector<int>v[NMAX];
vector<int>rev[NMAX];
vector<int>vcomp[NMAX];
vector<int>muchiicomp[NMAX];
bitset<NMAX>viz;
bitset<NMAX>vizoi;

void Dfs(int x)
{
    viz[x]=1;
    for (vector<int>::iterator it=v[x].begin();it!=v[x].end();it++)
        if (!viz[*it])
            Dfs(*it);
    st[++st[0]]=x;
}

void Dfsrev(int x)
{
    viz[x]=1;
    for (vector<int>::iterator it=rev[x].begin();it!=rev[x].end();it++)
        if (!viz[*it])
            Dfsrev(*it);
    which[x]=len;
}

void Gorev()
{
    int i;
    for (i=st[0];i>=1;i--)
        if (!viz[st[i]])
            {
                len++;
                Dfsrev(st[i]);
            }
}

void Dfscomp(int x)
{
    vizoi[x]=1;
    for (vector<int>::iterator it=muchiicomp[x].begin();it!=muchiicomp[x].end();it++)
        if (!vizoi[*it])
            Dfscomp(*it);
    st[++st[0]]=x;
}

int main()
{
    int i,j,x,y,act;
    bool ok;

    cin.sync_with_stdio(false);
    cin>>t;
    while (t--)
        {
            cin>>n>>m>>k;len=0;
            for (i=1;i<=k;i++) cin>>oras[i];
            for (i=1;i<=m;i++)
                {
                    cin>>b[i]>>c[i];
                    v[b[i]].push_back(c[i]);
                    rev[c[i]].push_back(b[i]);
                }
            st[0]=0;
            for (i=1;i<=n;i++)
                if (!viz[i])
                    Dfs(i);
            for (i=1;i<=n;i++) viz[i]=0;
            Gorev();
            for (i=1;i<=n;i++) viz[i]=0;
            for (i=1;i<=k;i++)
                {
                    vcomp[which[oras[i]]].push_back(oras[i]);
                    viz[which[oras[i]]]=1;
                }

            for (i=1;i<=len;i++)
                if (vcomp[i].size())
                    sort(vcomp[i].begin(),vcomp[i].end());
            for (i=1;i<=m;i++)
                if (which[b[i]]!=which[c[i]])
                    muchiicomp[which[b[i]]].push_back(which[c[i]]);
            st[0]=0;
            //sortare top
            for (i=1;i<=len;i++)
                if (!vizoi[i])
                    Dfscomp(i);
            d[0]=0;
            for (i=st[0];i>=1;i--)
                if (viz[st[i]]==1)
                    d[++d[0]]=st[i];
            if (d[0]==1)
                {
                    for (vector<int>::iterator it=vcomp[d[1]].begin();it!=vcomp[d[1]].end();it++)
                        cout<<(*it)<<" ";
                    cout<<"\n";
                }
            else
                {
                    //cout<<"pl\n";
                    //for (i=1;i<=st[0];i++) cout<<st[i]<<" ";
                    //cout<<"\n";
                    ok=1;act=0;
                    for (i=st[0];i>=1 && ok==1;i--)
                        {
                            if (last[st[i]]!=act && viz[st[i]]==1) ok=0;
                            if (viz[st[i]]==1) act=st[i];
                            last[st[i]]=act;
                            for (vector<int>::iterator it=muchiicomp[st[i]].begin();it!=muchiicomp[st[i]].end();it++)
                                last[*it]=last[st[i]];
                            //for (j=1;j<=n;j++) cout<<last[j]<<" ";
                            //cout<<ok<<"\n";
                        }

                    if (ok==0) cout<<"-1\n";
                    else
                        {
                            for (i=1;i<=d[0];i++)
                                {
                                    for (vector<int>::iterator it=vcomp[d[i]].begin();it!=vcomp[d[i]].end();it++)
                                        cout<<(*it)<<" ";
                                }
                            cout<<"\n";
                        }
                }

            //golire
            for (i=1;i<NMAX;i++)
                {
                    viz[i]=vizoi[i]=last[i]=0;
                    v[i].clear();rev[i].clear();
                    vcomp[i].clear();
                    muchiicomp[i].clear();
                }
        }
    return 0;
}