#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;

int n, m, k;
bool good[100005];
vector<int> g[100005], gr[100005], what[100005];
int used[100005];
vector<int> order;

void dfs(int x) {
    if (used[x]) return;
    used[x] = true;
    for (int u : g[x])
        dfs(u);
    order.push_back(x);
}

void dfs2(int x, int color) {
    if (used[x]) return;
    used[x] = color;
    if (good[x])
        what[color].push_back(x);
    for (int u : gr[x])
        dfs2(u, color);
}

int dp[100005], to[100005];
vector<int> ne[100005];

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%d%d%d", &n, &m, &k);
        for (int i = 0; i < n; ++i) {
            good[i] = false;
            g[i].clear();
            gr[i].clear();
        }
        for (int i = 0; i < k; ++i) {
            int a;
            scanf("%d", &a);
            good[a - 1] = true;
        }
        for (int i = 0; i < m; ++i) {
            int x, y;
            scanf("%d%d", &x, &y); --x; --y;
            g[x].push_back(y);
            gr[y].push_back(x);
        }
        
        order.clear();
        memset(used, 0, sizeof(used));
        for (int i = 0; i < n; ++i) {
            if (!used[i])
                dfs(i);
        }
        
        reverse(order.begin(), order.end());
        memset(used, 0, sizeof(used));
        int cnt = 0;
        for (int x : order) {
            if (!used[x]) {
                what[cnt + 1].clear();
                ne[cnt + 1].clear();
                dfs2(x, ++cnt);
            }
        }
        
        memset(dp, 0, sizeof(dp));
        memset(to, -1, sizeof(to));
        
/*        reverse(order.begin(), order.end());
        for (int x : order) {
            dp[used[x]] = what[used[x]].size();
            for (int u : g[x]) {
                int nval = what[used[x]].size() + dp[used[u]];
                if (nval > dp[used[x]] && used[x] != used[u]) {
                    dp[used[x]] = nval;
                    to[used[x]] = used[u];
                }
            }
        }*/
        
        for (int i = 0; i < n; ++i) {
            for (int x : g[i])
                if (used[i] != used[x])
                    ne[used[i]].push_back(used[x]);
        }
        for (int x = cnt; x >= 1; --x) {
            dp[x] = what[x].size();
            for (int u : ne[x]) {
                int nval = what[x].size() + dp[u];
                if (nval > dp[x]) {
                    dp[x] = nval;
                    to[x] = u;
                }
            }
        }
        
        int st = -1;
        for (int i = 1; i <= cnt; ++i) {
            if (dp[i] == k)
                st = i;
        }
        
        if (st == -1) {
            puts("-1");
        } else {
            while (st != -1) {
                sort(what[st].begin(), what[st].end());
                for (int x : what[st])
                    printf("%d ", x + 1);
                st = to[st];
            }
            printf("\n");
        }
    }
    return 0;
}