#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt + 20 )
#define inf  1000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  100000

vector<int>G[MX];


stack<int>stk;
bool fnd[MX];
int idx[MX] , low[MX] , num;
int par[MX] , pr;
int ts , n , m , k ;

void strongconnect(int v){

    idx[v] = low[v] = num++;
    stk.push(v);
    fnd[v] = true;

    repv(i,G[v]){
        int w = G[v][i];

        if(idx[w]==-1){
            strongconnect(w);
            low[v] = min(low[v],low[w]);
        }
        else if(fnd[w]){
            low[v] = min(low[v],idx[w]);
        }
    }

    if(low[v]==idx[v]){

        int w;
        pr++;
        do{
            w = stk.top(); stk.pop();
            fnd[w] = false;
            par[w] = pr;

        }while(w!=v);
    }
}

void tarjan(){

    memset(idx , -1 , sizeof idx);
    num = 1;

    rep(i,1,n){
        if(idx[i]==-1) strongconnect(i);
    }
}

vector<int>H[MX] , ulta[MX];
int ind[MX];
int pos[MX];
int come[MX];

int dorkar[MX];
int achhe[MX];
int d[MX];

bool comp(int a,int b){

    if(par[ d[a] ]==par[ d[b] ]){

        return d[a] < d[b];
    }
    return pos[ par[ d[a] ] ]  < pos[ par[ d[b] ] ];
}

pair<int,int>data[MX];

int main()
{
    cin>>ts;
    while(ts--){
        cin>>n>>m>>k;

        memset(dorkar , 0 , sizeof dorkar);
        rep(i,1,n) {G[i].clear(); H[i].clear();ulta[i].clear();}

        num  = 1;
        pr = 0;
        rep(i,1,k) {cin>>d[i];}

        rep(i,1,m){ int x,y;
            cin>>x>>y;
            G[x].pb(y);
        }

        tarjan();
//        cout<<par[4]<<endl;
        //ok

        // new graph making
        memset(ind , 0 , sizeof ind);
        rep(i,1,n){ int v = i;
            repv(j,G[v]){
                int u = G[v][j];
                if( par[u]!=par[v] ){
                    H[ par[v] ].pb( par[u] );
                    ind[ par[u] ]++;
                    ulta[ par[u] ].pb( par[v] );
                }
            }
        }

        //ok;

        vector<int>topo;
        topo.pb(0);

        rep(i,1,pr){
            if( ind[ i ] == 0 ){
                topo.pb(i);
            }
        }

        int st = 1;
        while(st<=pr){
            int v  =  topo[st++];
            repv( i , H[v] ){
                int u = H[v][i];
                ind[u]--;
                if(ind[u]==0) topo.pb(u);
            }
        }

//        cout<<"now topo "<<topo.size()<<endl;

//        rep(i,1,4) cout<<topo[i]<<" ";cout<<endl;
//        rep(i,1,4) cout<<i<<" "<<par[i]<<" "<<endl;

//        return 0;

        repv(i,topo){
            pos[ topo[i] ] = i;// kon parent
        }

//        cout<<"AA "<<pos[3]<<endl;

        memset(dorkar , 0 , sizeof dorkar);
        rep(i,1,k){
//            cout<<par[ d[i] ]<<" ";
            dorkar[ par[ d[i] ] ] = 1;
        }

//        cout<<"ok"<<endl;

        int len = topo.size();
        vector<int>ans;
        int lst = -1;
//        cout<<"ok"<<endl;
        rep(i,1,len-1){
            int v = topo[i];
            if(dorkar[v]){
                if(lst==-1){
                    lst = v;
                    come[v] = v;
                    ans.pb(v);
                }
                else{
                    repv(j,ulta[v]){
                        int u = ulta[v][j];
                        if(come[u]==lst){
                            come[v] = v;
                            lst = v;
                            ans.pb(v);
                            break;
                        }
                    }
                }
            }
            else if(lst==-1){
                continue;
            }
            else{
                repv(j,ulta[v]){
                    int u = ulta[v][j];
                    if(lst== come[u] ){
                        come[ v ] = lst;
                        break;
                    }
                }
            }
        }
//
//        rep(i,1,4){
//            cout<<"A "<<par[i]<<endl;
//        }


        memset(achhe, 0 , sizeof achhe);
        repv(i,ans){
            achhe[ ans[i] ] = 1;
        }

        bool chk = true;
        rep(i,1,k){
            if(! achhe[ par[d[i]] ]) chk = false;
        }

        if(!chk) puts("-1");
        else {


//            sort( d + 1 ,d + k + 1 , comp );

            rep(i,1,k){
//                cout<< pos[ par[d[i]] ]<<endl;pos[ par[d[i]] ]

                data[i] = mp( pos[ par[d[i]] ] , d[i] );
            }

//            cout<<par[3]<<endl;

            sort( data + 1 , data + k + 1 );

            rep(i,1,k){
                printf("%d%c",data[i].yy,i==k?'\n':' ');
            }
        }
    }

    return 0;
}