#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>
#define pb push_back
#define MAXN 100005
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

vector <int> g[MAXN];
int idx[MAXN];
int low[MAXN];
int color[MAXN];
int used[MAXN];
int comp[MAXN];
int ncomp;
int timer;
vector <int> need;
stack <int> st;

int ok;
vector <pair <int, int> > r;

void strong_connect(int node) {
    timer++;
    low[node] = timer;
    idx[node] = timer;
    color[node] = GRAY;
    st.push(node);

    for (int i = 0; i < (int)g[node].size(); i++) {
        int viz = g[node][i];
        if (color[viz] == WHITE) {
            strong_connect(viz);
            low[node] = min(low[node], low[viz]);
        } else if (color[viz] == GRAY) {
            low[node] = min(low[node], idx[viz]);
        }
    }
    if (low[node] == idx[node]) {
        ncomp++;
        int w;
        do {
            w = st.top();
            st.pop();
            color[w] = BLACK;
            comp[w] = ncomp;
        } while (w != node);
    }
    return;
}

bool compare(const pair <int, int> &a, const pair <int, int> &b) {
    return a.first > b.first || a.first == b.first && a.second < b.second;
}

void DFS(int node, int target) {
    if (comp[node] == target) {
        ok = 1;
        return;
    }
    used[node] = 1;

    for (int i = 0; i < (int)g[node].size(); i++) {
        int viz = g[node][i];
        if (comp[viz] == target) {
            ok = 1;
            return;
        }
        if (!used[viz]) {
            DFS(viz, target);
        }
    }
    return;
}

int main(void) {
    int t;
    int n, m, k;
    int x, y;

    scanf(" %d", &t);
    while(t--) {
        need.clear();
        r.clear();
        scanf(" %d %d %d", &n, &m, &k);
        for (int i = 1; i <= n; i++) {
            used[i] = 0;
            g[i].clear();
            color[i] = WHITE;
        }
        for (int i = 0; i < k; i++) {
            scanf(" %d", &x);
            need.pb(x);
        }
        for (int i = 0; i < m; i++) {
            scanf(" %d %d", &x, &y);
            g[x].pb(y);
        }

        timer = 0;
        ncomp = 0;
        for (int i = 1; i <= n; i++) {
            if (color[i] == WHITE) {
                strong_connect(i);
            }
        }
        for (int i = 0; i < (int)need.size(); i++) {
            x = need[i];
            r.pb(make_pair(comp[x], x));
        }
        sort(r.begin(), r.end(), compare);

        ok = 1;
        for (int i = (int)r.size() - 2; i >= 0; i--) {
            x = r[i].second;
            y = r[i + 1].second;
            if (comp[x] != comp[y]) {
                ok = 0;
                DFS(x, comp[y]);
            }
            if (!ok) {
                break;
            }
        }
        if (ok) {
            for (int i = 0; i < (int)r.size(); i++) {
                if (i != 0) {
                    printf(" ");
                }
                printf("%d", r[i].second);
            }
        } else {
            printf("-1");
        }
        printf("\n");
    }
    return 0;
}