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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// clang-format off
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()

template<class C> void mini(C &a5, C b5) { a5 = min(a5, b5); }
template<class C> void maxi(C &a5, C b5) { a5 = max(a5, b5); }

#ifdef LOCAL
const bool debug = true;
#else
const bool debug = false;
#define cerr if (true) {} else cout
#endif
// clang-format on

const int nax = 1010;

vector<int> edges[nax];
int degree[nax];

bool k_cover(int k, set<pair<int, int> > &kra);

bool k_cover_del(int k, pair<int, int> uu, set<pair<int, int> > &kra) {
	vector<pair<int, int> > backup;
	for (int _i = 0; _i < 2; _i++) {
		swap(uu.first, uu.second);
		int u = uu.first;
		if (u == 0) continue;
		for (int v : edges[u]) {
			int a = u, b = v;
			if (a > b) swap(a, b);
			auto it = kra.find({a, b});
			if (it == kra.end()) continue;
			backup.push_back(*it);
			kra.erase(it);
		}
	}
	bool res = k_cover(k, kra);
	kra.insert(ALL(backup));
	return res;
}

bool k_cover(int k, set<pair<int, int> > &kra) {
	if (k < 0) return false;
	if (kra.empty()) return true;
	if (k == 0) return false;
	
	auto p = *kra.begin();
	int u = p.first, v = p.second;
	
	return k_cover_del(k-1,{u,0},kra) || k_cover_del(k-1,{v,0},kra) || k_cover_del(k-2,{v,u},kra);
}

struct Solve {
	int n, m, k;
	set<pair<int, int> > kra;
	
	Solve() {
		cin >> n >> m >> k;
		
		for (int i = 0; i < m; i++) {
			int u, v;
			cin >> u >> v;
			if (u > v) swap(u, v);
			degree[u]++;
			degree[v]++;
			kra.insert({u, v});
		}
		
		int removed = 0;
		for (int i = 1; i <= n; i++) {
			if (degree[i] > k) removed++;
		}
		
		for (auto it=kra.begin(); it != kra.end();) {
			int u = it->first, v = it->second;
			if (degree[u] > k || degree[v] > k) {
				it = kra.erase(it);
				continue;
			}
			
			edges[u].push_back(v);
			edges[v].push_back(u);
			it++;
		}
		
		for (int i = 0; i <= k-removed; i++) {
			if (!k_cover(i, kra)) {
				continue;
			}
			vector<int> res;
			for (int j = 1; j <= n; j++) {
				if (degree[j] > k || k_cover_del(i-1, {j,0}, kra)) {
					res.push_back(j);
				}
			}
			cout << i+removed << " " << res.size() << "\n";
			for (int j : res) {
				cout << j << " ";
			}
			cout << "\n";
			return;
		}
		
		cout << "-1\n";
	}
	
	~Solve() {
		for (int i = 0; i <= n; i++) {
			edges[i].clear();
			degree[i] = 0;
		}
	}
};

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int t;
    cin >> t;
    while (t--) {
		Solve s;
	}
    
    return 0;
}/*
4
3 2 7
1 2
2 3
3 3 7
1 2
2 3
1 3
5 3 1
1 5
2 4
1 5
5 2 2
2 4
1 5
-----
1 1
2
2 3
1 2 3
-1
2 4
1 2 4 5

1
11 17 30
1 2
2 3
3 4
4 5
1 5
1 6
2 7
3 8
4 9
5 10
6 8
8 10
10 7
7 9
9 6
6 11
7 11
------
6 9
1 2 3 4 5 6 7 8 10

1
4 3 10
1 2
2 3
1 4
------
2 4
1 2 3 4

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

*/