// @author cebrusfs
// headers {{{
#include<bits/stdc++.h>
using namespace std;
// }}}
// macros {{{
#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(x) (sort(ALL(x)), ((x).erase(unique(ALL(x)), (x).end())))
#define MSA(x, v) std::fill(ALL(x), (v))
#define MS(st, ed, v) std::fill((st), (ed), (v))

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

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

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int, int> PII;
#define MP make_pair
#define F first
#define S second

typedef vector<int> VI;
#define PB push_back
#define PF push_front

#define PPB pop_back
#define PPF pop_front

#define runtime() ((double)clock() / CLOCKS_PER_SEC)

const double eps = 1e-7;

// C++11
#if __cplusplus >= 201103L
#define MT make_tuple
typedef tuple<int, int> TII;

// dump() {{{
template<typename T>
void _dump(const char* s, T&& head) {
    cerr<< s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c = 0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr << *s++;
    }
    cerr << "=" << head << ", ";
    _dump(s+1, tail...);
}

#ifdef FISH
#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0);
#else
#define dump(...) ;
#endif

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s << "[";
    for (auto it = b; it != e; it++) s << (it == b ? "":" ") << *it;
    s << "]";
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &c) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &c) { return _out(s,ALL(c)); }
// }}}

#endif
// }}}

#define MAX 100005

vector<int> e[MAX], re[MAX];
int ary[MAX];
vector<int> toporder;

bool vis[MAX];

int scc[MAX], sn;

void dfs1(int a)
{
    vis[a] = true;
    for (int b : e[a])
        if (not vis[b])
            dfs1(b);

    toporder.PB(a);
}
void dfs2(int a)
{
    scc[a] = sn;
    vis[a] = true;
    for (int b : re[a])
        if (not vis[b])
            dfs2(b);
}

vector<int> scc_cnt[MAX];
vector<int> scc_all[MAX];

int dp[MAX];
int lab[MAX];

int main()
{
    int T;
    scanf("%d", &T);

    while (T--)
    {
        int n, m, N;
        scanf("%d %d %d", &n, &m, &N);

        for (int i = 0; i < N; ++i)
            scanf("%d", &ary[i]), ary[i]--;

        for (int i = 0; i < n; ++i)
            e[i].clear(), re[i].clear();

        for (int i = 0; i < m; ++i)
        {
            int a, b;
            scanf("%d %d", &a, &b);
            --a, --b;
            e[a].PB(b);
            re[b].PB(a);
        }

        memset(vis, 0, sizeof(vis));
        toporder.clear();
        for (int i = 0; i < n; ++i)
            if (not vis[i])
                dfs1(i);

        memset(vis, 0, sizeof(vis));
        reverse(ALL(toporder));
        sn = 0;
        for (int i = 0; i < n; ++i)
            if (not vis[toporder[i]])
                dfs2(toporder[i]), sn++;

        for (int i = 0; i < sn; ++i)
        {
            scc_cnt[i].clear();
            scc_all[i].clear();
        }

        for (int i = 0; i < sn; ++i)
            dp[i] = N, lab[i] = N;

        for (int i = 0; i < n; ++i)
            for (int b : e[i])
                scc_all[scc[i]].PB(scc[b]);

        for (int i = 0; i < N; ++i)
        {
            int idx = ary[i];

            int sc = scc[idx];
            scc_cnt[sc].push_back(idx);
        }

        for (int i = 0; i < sn; ++i)
            sort(ALL(scc_cnt[i]));

        vector<int> ans;
        for (int i = 0; i < sn; ++i)
            ans.insert(ans.end(), ALL(scc_cnt[i]));

        for (int i = N - 1; i >= 0; --i)
            lab[scc[ans[i]]] = i;

        for (int i = n - 1; i >= 0; --i)
        {
            int a = toporder[i];
            for (int b : e[a])
            {
                if (scc[a] != scc[b])
                {
                    dp[scc[a]] = min(dp[scc[b]], dp[scc[a]]);
                    dp[scc[a]] = min(lab[scc[b]], dp[scc[a]]);
                }
            }
        }
        bool check = true;
        for (int i = 1; i < N; ++i)
        {
            int sc = scc[ans[i]];
            int psc = scc[ans[i - 1]];
            if (sc != psc)
                check &= dp[psc] == i;
        }
        if (check)
        {
            for (int a : ans)
                printf("%d ", a + 1);
        }
        else
            printf("-1");
        printf("\n");
    }
}