#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)2e5 + 10;
const int MOD = 1000000007;

int n, m, x;
vector<vector<int>> g;
vector<int> inf;
int rem; int in;
vector<bool> vis;

void dfs(int u){
    in++;
    vis[u] = true;
    for(auto & x: g[u]){
        if(x == rem) continue;
        if(!vis[x])
            dfs(x);
    }
}

void solve(){
    cin >> n >> m >> x;
    g = vector<vector<int>>(n + 1, vector<int>());
    inf = vector<int>(x);
    for(int i = 0; i < x; ++i)
        cin >> inf[i];
    for(int i = 0, x, y; i < m; ++i){
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    //start by removing every node
    sort(inf.begin(), inf.end());
    int mx = 0;
    int id = 0;
    vis = vector<bool>(n + 1, false);
    for(int i = 0; i < x; ++i){
        in = 1;
        rem = inf[i];
        fill(vis.begin(), vis.end(), false);
        for(int j = 0; j < x; ++j){
            if(j == i) continue;
            if(!vis[inf[j]]){
                dfs(inf[j]);
            }
        }
        int ans = n - in;
        if( ans > mx){
            mx = ans;
            id = inf[i];
        }
    }
    cout << mx << " " << id << '\n';
    
}   

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int t; cin >> t;
    while(t--)
        solve();
    return 0;
}