// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

typedef vector<int> Node;
typedef vector<Node> Graph;

void add_edge(Graph& G, int a, int b) {
    G[a].push_back(b);
}
int scc(const Graph& G, const Graph& RG, vector<int>& cmp) {
    int n = G.size();
    int K = 0; // the number of components

    cmp.assign(n, -1); // cmp[v] := component id of vertex v (0, 1, ..., K-1)
    vector<bool> used(n);
    vector<int> order;

    // ordinary dfs
    function<void(int)> dfs = [&](int u) {
        used[u] = true;
        for(int w : G[u]) if(!used[w]) {
            dfs(w);
        }
        order.push_back(u);
    };
    for(int u = 0; u < n; u++) if(!used[u]) {
        dfs(u);
    }
    reverse(order.begin(), order.end());

    // reverse dfs
    function<void(int)> rdfs = [&](int u) {
        cmp[u] = K;
        for(int w : RG[u]) if(cmp[w] == -1) {
            rdfs(w);
        }
    };
    for(int u : order) if(cmp[u] == -1) {
        rdfs(u);
        K++;
    }

    return K;
}
int main(){
    iostream_init();
    int T;
    cin >> T;
    while(T--) {
        int K, N, M;
        cin >> N >> M >> K;
        vector<int> C(K);
        REP(i, K) cin >> C[i];
        REP(i, K) C[i]--;
        Graph G(N);
        Graph RG(N);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            add_edge(G, a, b);
            add_edge(RG, b, a);
        }
        vector<int> cmp;
        int L = scc(G, RG, cmp);
        vector<set<int>> F(L);
        REP(i, N) for(int j : G[i]) {
            int u = cmp[i];
            int v = cmp[j];
            if(u != v) {
                F[u].insert(v);
            }
        }
        map<int, vector<int>> bucket;
        for(int c : C) {
            bucket[ cmp[c] ].push_back(c);
        }
        vector<int> index;
        for(auto p : bucket) {
            index.push_back(p.first);
            sort(bucket[p.first].begin(), bucket[p.first].end());
        }
        vector<int> dp(L, INT_MIN);
        dp[ index.front() ] = 0;
        REP(i, L) {
            const int idx = dp[i];
            if(idx < 0) continue;
            if(idx+1 < index.size() && index[idx+1] == i) {
                dp[i] = idx+1;
            }
            for(int j : F[i]) {
                dp[j] = max(dp[j], dp[i]);
            }
        }
        if(dp[index.back()] == index.size()-1) {
            bool first = true;
            for(auto p : bucket) {
                for(int x : p.second) {
                    if(first) {
                        first = false;
                    } else {
                        cout << " ";
                    }
                    cout << x+1;
                }
            }
            cout << endl;
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}