#include <bits/stdc++.h>
using namespace std;
const int N = 202020;
const int V = 3;
int ou[N], ov[N], co[N];
void del(int i, int o, vector<vector<array<int, 2> > > &G) {
  int j;
  if (i < 0)
    j = ou[-i];
  else
    j = ov[i];
  int x = G[o].back()[1];
  if (x < 0)
    ov[-G[o].back()[1]] = j;
  else
    ou[G[o].back()[1]] = j;
  swap(G[o].back(), G[o][j]);
  G[o].pop_back();
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int t;
  cin >> t;
  for (; t--;) {
    int n, m, k;
    cin >> n >> m >> k;
    priority_queue<array<int, 2> > q;
    vector<vector<array<int, 2> > > G(n + 1);
    vector<set<int> > S(n + 1);
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      G[u].push_back({v, i});
      G[v].push_back({u, -i});
      ou[i] = G[u].size() - 1;
      ov[i] = G[v].size() - 1;
    }
    for (int i = 1; i <= n; i++) {
      q.push({-(int)G[i].size(), i});
      if ((int)G[i].size() > V * k)
        for (array<int, 2> j : G[i]) S[i].insert(j[0]);
    }
    while (!q.empty() && -q.top()[0] < k - 1) {
      int x = -q.top()[0];
      int i = q.top()[1];
      q.pop();
      if (x != (int)G[i].size()) continue;
      for (array<int, 2> j : G[i]) {
        del(j[1], j[0], G);
        q.push({-(int)G[j[0]].size(), j[0]});
      }
      G[i].clear();
    }
    int ans = 0, cg = 0;
    while (!q.empty() && -q.top()[0] < k) {
      int x = -q.top()[0];
      int i = q.top()[1];
      q.pop();
      if (x != (int)G[i].size()) continue;
      if (x == k - 1) {
        bool ok = 1;
        for (array<int, 2> j : G[i]) co[j[0]]++;
        for (array<int, 2> j : G[i]) {
          if ((int)G[j[0]].size() <= V * k) {
            for (array<int, 2> o : G[j[0]])
              if (co[o[0]]) co[o[0]]++;
          } else {
            for (array<int, 2> o : G[i])
              if (S[j[0]].count(o[0])) co[o[0]]++;
          }
        }
        for (array<int, 2> j : G[i]) {
          if (co[j[0]] < k - 1) ok = 0;
          co[j[0]] = 0;
        }
        if (ok) {
          cg = i;
          ans = 2;
          break;
        }
      }
      for (array<int, 2> j : G[i]) {
        del(j[1], j[0], G);
        q.push({-(int)G[j[0]].size(), j[0]});
      }
      G[i].clear();
    }
    if (ans) {
      cout << "2\n" << cg << ' ';
      for (array<int, 2> i : G[cg]) cout << i[0] << ' ';
      cout << '\n';
    } else {
      vector<int> ans;
      for (int i = 1; i <= n; i++)
        if ((int)G[i].size() >= k) ans.push_back(i);
      if (ans.empty())
        cout << "-1\n";
      else {
        cout << "1 " << ans.size() << '\n';
        for (int i : ans) cout << i << ' ';
        cout << '\n';
      }
    }
  }
  return 0;
}
