#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;

#define FU(i, a, b) for(int i = (a); i < (b); ++i)
#define fu(i, n) FU(i, 0, n)

#define FD(i, a, b) for(int i = (b)-1; i>=(a); --i)
#define fd(i, n) FD(i, 0, n)

#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define sz(c) int((c).size())
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

struct graph {
  vi dest;
  vvi adj;
  vi depth;
  int inv(int a) { return a ^ 0x1; }
  graph(int n = 0) {
    adj.resize(n);
  }
  int arc(int i, int j) {
    dest.pb(j);
    adj[i].pb(sz(dest)-1);
    dest.pb(i);
    adj[j].pb(sz(dest)-1);
    return sz(dest)-2;
  }

  vi ord, rep;

  int transp(int a) { return (a & 0x1); }

  void dfs_topsort(int u) {
	for (int a : adj[u]) {
      int v = dest[a];
      if (!transp(a) && depth[v] == -1) {
        depth[v] = depth[u] + 1;
        dfs_topsort(v);
      }
    }
    ord.pb(u);
  }

  void dfs_compfortcon(int u, int ent) {
    rep[u] = ent;
		for (int a : adj[u]) {
      int v = dest[a];
      if (transp(a) && rep[v] == -1) dfs_compfortcon(v, ent);
    }
  }

  void compfortcon() {
    depth = vi(sz(adj), -1);
    ord.clear();
    fu(u, sz(adj)) if (depth[u] == -1) {
        depth[u] = 0;
        dfs_topsort(u);
    }

    rep = vi(sz(adj), -1);
    for (int i = sz(adj)-1; i >= 0; i--) if (rep[ord[i]] == -1)
      dfs_compfortcon(ord[i], ord[i]);
  }
};
vi order;
int L;
vector<bool> mark;

void topsort(vvi &graph2, int i) {
    if (mark[i]) return;
    mark[i] = true;
    for (int x : graph2[i]) topsort(graph2, x);
    order[--L] = i;
}

void dfs(vvi &graph2, int c) {
    if (mark[c]) return;
    mark[c] = true;
    for (int x : graph2[c]) dfs(graph2, x);
}

void solve() {
    int N, M, K, X, Y;
    scanf("%d %d %d", &N, &M, &K);
    vi A(K);
    vector<bool> special(N, false);
    fu(i, K) {
        scanf("%d", &A[i]);
        A[i]--;
        special[A[i]] = true;
    }
        
    graph G(N);
    fu(i, M) {
        int a, b;
        scanf("%d %d", &a, &b);
        G.arc(a-1, b-1);
    }
    G.compfortcon();
    
    unordered_map<int, vi> compM;
    
    fu(i, N) {
        compM.insert(make_pair(G.rep[i], vi()));
        compM[G.rep[i]].push_back(i);
    }
    // make graph of connected components
    vvi comp;
    for (auto &x : compM) {
        comp.push_back(move(x.second));
        for (int y : comp.back()) G.rep[y] = comp.size() - 1;
    }
    
    int NC = comp.size();
    vvi graph2(NC);
    for (int i = 0; i < G.dest.size(); i += 2)
        graph2[G.rep[G.dest[i+1]]].push_back(G.rep[G.dest[i]]);
    
    for (auto &x : graph2) {
        sort(x.begin(), x.end());
        x.erase(unique(x.begin(), x.end()), x.end());
    }
    // perform top sort on G2
    L = NC;
    mark.assign(NC, false);
    order.assign(NC, -1);
    fu(i, NC) if (!mark[i]) topsort(graph2, i);
    // mark special components
    
    vector<bool> spcomp(NC, false);
    fu(i, N) if (special[i]) spcomp[G.rep[i]] = true;
    reverse(order.begin(), order.end());
    // build answer or decide it's impossible
    vi ans;
    int last = -1;
    mark.assign(NC, false);
    for (int c : order) {
        if (!spcomp[c]) continue;
        // check if we can go from c to last
        if (last != -1) mark[last] = false;
        dfs(graph2, c);
        if (last != -1 && !mark[last]) {
            printf("-1\n");
            return;
        }
        last = c;
        sort(comp[c].begin(), comp[c].end());
        reverse(comp[c].begin(), comp[c].end());
        for (int x : comp[c]) if (special[x]) ans.push_back(x);
    }
    reverse(ans.begin(), ans.end());
    fu(i, ans.size()) {
        if (i) printf(" ");
        printf("%d", ans[i]+1);
    }
    printf("\n");
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) solve();
    return 0;
}