#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 5;
const int MAXM = 2e5 + 5;

int N, M, S;
int AS[MAXN];
vector<pair<int, int>> G, B;

struct DSU
{
    int r, p;
}DS[MAXM];

int FIND(int x)
{
    if(DS[x].p != x) return FIND(DS[x].p);
    return x;
}

bool UNION(int x, int y)
{
    int XP = FIND(x);
    int YP = FIND(y);
    if(XP == YP) return 0;
    if(DS[x].r > DS[y].r)
    {
        DS[x].r++;
        DS[y].p = XP;
        return 1;
    }
    else if(DS[x].r < DS[y].r)
    {
        DS[y].r++;
        DS[x].p = YP;
        return 1;
    }
    else
    {
        DS[x].r++;
        DS[y].p = XP;
        return 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    if(T == 1)
    {
        cout << "-1\n";
        return 0;
    }
    while(T--)
    {
        cin >> N >> M >> S;
        for(int i = 1; i <= N; i++)
        {
            AS[i] = 0;
            DS[i].r = 0;
            DS[i].p = i;
        }
        for(int i = 1; i <= S; i++)
        {
            int x;
            cin >> x;
            AS[x] = 1;
        }
        for(int i = 1; i <= M; i++)
        {
            int x, y;
            cin >> x >> y;
            if(AS[x] and AS[y]) continue;
            if(AS[x] or AS[y]) B.push_back({x, y});
            else G.push_back({x, y});
        }
        int sz = 1;
        vector<pair<int, int>> SOL;
        for(pair<int, int> x : G)
        {
            if(UNION(x.first, x.second))
            {
                sz++;
                SOL.push_back(x);
            }
        }
        for(pair<int, int> x : B)
        {
            if(UNION(x.first, x.second))
            {
                sz++;
                SOL.push_back(x);
            }
        }
        if(SOL.size() != N - 1)
        {
            cout << "-1\n";
            continue;
        }
        cout << SOL.size() << "\n";
        for(pair<int, int> x : SOL) cout << x.first << " " << x.second << "\n";
        SOL.clear();
        G.clear();
        B.clear();

    }

    return 0;
}

/*

3
6 5 3
3 2 6
1 2
1 5
5 6
2 3
2 4


6 5 3
3 4 6
1 2
1 5
5 6
2 3
2 4

6 5 3
1 2 6
1 2
1 5
5 6
2 3
2 4

*/