1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <vector>

using namespace std;

void exile(int sages[], int n, int k) {

	int min = sages[1];
	for (int i = 2; i <= n; i++)
		if (sages[i] < min) min = sages[i];

	if (min >= k) cout << -1 << "\n";
	else {
		vector<int> to_exile;
		for (int i = 1; i <= n; i++)
			if (sages[i] == min) to_exile.push_back(i);

		cout << min+1 << " " << to_exile.size() << "\n";
		for (int j : to_exile)
			cout << j << " ";
		cout << "\n";
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t, n, m, k;
	cin >> t;

	for (int i = 0; i < t; i++) {

		cin >> n >> m >> k;
		int sages[n+1];

		for (int i = 1; i <= n; i++)
			sages[i] = m;

		int a, b;
		for (int i = 0; i < m; i++) {
			cin >> a >> b;
			sages[a]--;
			sages[b]--;
		}

		exile(sages, n, k);
	}

	return 0;
}