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
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <iostream>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <numeric>
#include <ctime>

using namespace std;
typedef long long LL;
#define INF 1000000000
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FS first
#define SD second
#define MP make_pair
#define ZERO(t) memset(t, 0, sizeof(t))
#define MINUS(t) memset(t, -1, sizeof(t))
#define MOD 1000000007
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))

int DEG[1005];

int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m, k; scanf("%d%d%d", &n, &m, &k);
    FORE(i,1,n) DEG[i] = m;
    FOR(i,0,m) {
      int a, b; scanf("%d%d", &a, &b);
      --DEG[a];
      --DEG[b];
    }
    int mini = DEG[1];
    FORE(i,1,n) {
      mini = min(mini, DEG[i]);
    }

    
    int none = 0;
    FORE(i,1,n) none += DEG[i] == 0;
    if (none) {
      printf("1 %d\n",  none);
      FORE(i,1,n) if (DEG[i] == 0) printf("%d ", i);
      printf("\n");
      continue;
    }

    int g = 1;
    bool found = false;
    FORE(day,2,k) {
      int g2;
      for (g2 = g + 1; g2 <= m; ++g2) {
        int extra = g2 - g;
        if (n % 2 == 1) {
          int mis = (g2 * 2) / (n - 1);
          if ((g2 * 2) % (n - 1) != 0) ++mis;
          if (mis <= extra) break;
        }
        else {
          int mis = (g2 * 2) / (n - 2);
          if ((g2 * 2) % (n - 2) != 0) ++mis;
          mis -= mis / (n - 1);
          if (mis <= extra) break;
        }
      }
      int some = 0;
      FORE(i,1,n) if (DEG[i] < g2) {
        ++some;
      }
      if (some) {
        printf("%d %d\n", day, some);
        FORE(i,1,n) if (DEG[i] < g2) printf("%d ", i);
        printf("\n");
        found = true;
        break;   
      }
      g = g2;
    }
    if (!found) {
      printf("-1\n");
    }
  }
  
}