#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int t, n, m, s, x, y;
    scanf("%d", &t);
    while (t--) {
        int res=0;
        scanf("%d %d %d", &n, &m, &s);
        vector<int> ls(s);
        for (int i=0; i<s; i++) {
            scanf("%d", &x);
            ls.push_back(x);
        }
        vector<int> g[n+1];
        for (int i=0; i<m; i++) {
            scanf("%d %d", &x, &y);
            g[x].push_back(y);
            g[y].push_back(x);
        }
        for (auto el : ls) {
            /*int sc=0;
            for (auto adj : g[el]) {
                sc++;
                break;
            }*/
            for (auto adj : g[el]) {
                vector<int> visited(n, 0);
                queue<int> q;
                q.push(adj);
                while (!q.empty()) {
                    int top = q.front();
                    q.pop();
                    visited[top] = 1;
                    for (auto adj : g[top]) {
                        if (visited[adj] == 0)
                            q.push(adj);
                    }
                }
                for (auto adj : g[el]) {
                    if (visited[adj] == 0) {
                        res = -1;
                        printf("-1");
                        goto out;
                    } else {
                        if (adj == el) continue;
                        else {
                            printf("skloniti vezu %d i %d\n", el, adj);
                        }
                    }
                }
                // skloniti el<->0 vezu
                //printf("skloniti %d i %d\n", el, g[el][1]);
                //g[el] = g[el].erase(0);
                //g[0] = g[0].erase(el);
            }

        }
        out:
    }


    return 0;
}

/*
2
5 4 3
1 4 5
1 2
2 3
3 4
3 5
6 6 2
5 6
1 2
3 4
2 5
4 6
5 6
2 4
*/