//#include #include #include #include #include using namespace std; #define endl '\n' #define int long long #define MAXN 1000005 ifstream cin("escape.in"); ofstream cout("escape.out"); int br, edges, v1, v2, start, ex, st2; vector graph[MAXN]; bool izh[MAXN]; int one[MAXN], two[MAXN]; bool avail[MAXN]; queue > q; int way; int u[MAXN]; inline void init(){ for(int i = 1; i <= br; ++i){ graph[i] = vector(); izh[i] = 0; avail[i] = 0; } } void bfs(int start, int* arr){ ++way; q.push({start, 0}); while(!q.empty()){ int v, d; tie(v, d) = q.front(); q.pop(); if(u[v] == way) continue; u[v] = way; arr[v] = d; for(int att : graph[v]){ if(u[att] == way) continue; q.push({att, d + 1}); } } } bool flag; vector route; void dfs(int v){ route.push_back(v); u[v] = way; if(izh[v]){ flag = true; cout << route.size() << endl; for(int i : route){ cout << i << ' '; } cout << endl; return; } for(int att : graph[v]){ if(!avail[att]) continue; if(u[att] == way) continue; if(route.size() != one[att]) continue; dfs(att); if(flag) return; } } inline void solve(){ cin >> br >> edges >> v1 >> v2 >> start; for(int i = 0; i < edges; ++i){ int from, to; cin >> from >> to; graph[from].push_back(to); graph[to].push_back(from); } cin >> ex; for(int i = 0; i < ex; ++i){ int input; cin >> input; izh[input] = 1; if(i == 0) st2 = input; } bfs(start, one); bfs(st2, two); for(int i = 1; i <= br; ++i){ if(one[i] * v2 < two[i] * v1) avail[i] = 1; } flag = false; ++way; route = vector(); dfs(start); if(!flag){ cout << -1 << endl; } init(); } signed main(){ cin.tie(0); ios::sync_with_stdio(false); int tests; cin >> tests; while(tests--){ solve(); } return 0; }