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
// Marcin Knapik

#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define f first
#define s second
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()

using ll = long long;
using vi = vector<int>;

int n, m, k;


void solve () {
    cin >> n >> m >> k;

    vi ory(n);
    int OR = 0;
    int mini = 31;

    assert(m <= 30);

    int whole_set = (1 << m) - 1;

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

        ory[a] += (1 << i);
        ory[b] += (1 << i);
    }

    for(int mask = 1; mask < (1 << n); mask++){
        if(__builtin_popcount(mask) > mini)
            continue;

        int temp_or = 0;
        for(int j = 0; j < n; j++){
            if(mask & (1 << j)){
                temp_or |= ory[j];
            }
        }

        if(temp_or == whole_set){
            if(__builtin_popcount(mask) < mini){
                OR = mask;
                mini = __builtin_popcount(mask);
            } else {
                OR |= mask;
            }
        }
    }

    if(mini <= k){
        cout << mini << ' ' << __builtin_popcount(OR) << '\n';
        for(int i = 0; i < n; i++){
            if(OR & (1 << i)){
                cout << i + 1 << ' ';
            }
        }
        cout << '\n';
    } else {
        cout << -1 << '\n';
    }
}

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tests = 1;
    cin >> tests;

    for (int test = 1; test <= tests; test++) {
        solve();
    }

    return 0;
}