#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
inline void writebl(long long x) {
  write(x);
  putchar(' ');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
const long long N = 2e5 + 5, M = N << 1, inf = 0x3f3f3f3f;
vector<long long> E[N];
long long n, m, in[N], k, vis[N];
signed main() {
  long long T = read();
  while (T--) {
    n = read(), m = read(), k = read();
    for (register long long i = (1); i <= (n); ++i) E[i].clear(), in[i] = 0;
    for (register long long i = (1); i <= (m); ++i) {
      long long u = read(), v = read();
      E[u].push_back(v);
      in[u]++;
      E[v].push_back(u);
      in[v]++;
    }
    queue<long long> q;
    while (!q.empty()) q.pop();
    for (register long long i = (1); i <= (n); ++i) vis[i] = 0;
    for (register long long i = (1); i <= (n); ++i) {
      sort(E[i].begin(), E[i].end());
      if (in[i] < k) {
        q.push(i);
        vis[i] = 1;
      }
    }
    vector<long long> ans;
    ans.clear();
    while (!q.empty() && ans.empty()) {
      long long u = q.front();
      q.pop();
      vis[u] = 2;
      if (k * (k - 1) <= m * 2 && in[u] == k - 1 && ans.empty()) {
        ans.push_back(u);
        for (long long i = 0; i < E[u].size(); ++i)
          if (vis[E[u][i]] != 2) ans.push_back(E[u][i]);
        bool op = 1;
        for (long long i = 0; i < ans.size() && op; ++i)
          for (long long j = 0; j < ans.size() && op; ++j) {
            long long u = ans[i], v = ans[j];
            if (u == v)
              break;
            else if (!binary_search(E[u].begin(), E[u].end(), v)) {
              op = 0;
              break;
            }
          }
        if (!op) ans.clear();
      }
      for (long long i = 0; i < E[u].size(); ++i) {
        long long v = E[u][i];
        --in[v];
        if (in[v] < k && vis[v] == 0) {
          vis[v] = 1;
          q.push(v);
        }
      }
    }
    if (!ans.empty()) {
      writeln(2);
      for (long long i = 0; i < ans.size(); ++i) writebl(ans[i]);
      puts("");
      continue;
    }
    long long cnt = 0;
    for (register long long i = (1); i <= (n); ++i)
      if (vis[i] == 0) cnt++;
    if (cnt > 0) {
      writebl(1);
      writeln(cnt);
      for (register long long i = (1); i <= (n); ++i)
        if (vis[i] == 0) writebl(i);
      puts("");
      continue;
    }
    puts("-1");
  }
}
