#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    que;
int t, n, m, k;
unordered_set<int> se[100010];
vector<int> ans;
bool vis[100010];
void init() {
  ans.clear();
  for (int i = 1; i <= n; ++i) {
    vis[i] = 0;
    se[i].clear();
  }
  while (!que.empty()) que.pop();
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d%d", &n, &m, &k);
    init();
    for (int i = 1; i <= m; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      se[u].insert(v);
      se[v].insert(u);
    }
    if (k == 1) {
      printf("2\n1\n");
      continue;
    }
    for (int i = 1; i <= n; ++i) que.push(make_pair(se[i].size(), i));
    bool flag1 = 0, flag2 = 0;
    while (!que.empty()) {
      int sz = que.top().first, u = que.top().second;
      que.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      if (se[u].size() >= k) {
        flag1 = 1;
        break;
      }
      if (se[u].size() == k - 1 && (long long)k * (k - 1) / 2 <= m) {
        bool flag = 1;
        for (auto it1 = se[u].begin(); flag && it1 != se[u].end(); ++it1) {
          for (auto it2 = it1; flag && it2 != se[u].end(); ++it2) {
            if (it1 != it2)
              flag &= se[*it1].find(*it2) != se[*it1].end() &&
                      se[*it2].find(*it1) != se[*it2].end();
          }
        }
        if (flag) {
          flag2 = 1;
          ans.push_back(u);
          for (auto it = se[u].begin(); it != se[u].end(); ++it) {
            ans.push_back(*it);
          }
          break;
        }
      }
      for (auto it = se[u].begin(); it != se[u].end(); ++it) {
        se[*it].erase(u);
        que.push(make_pair(se[*it].size(), *it));
      }
      se[u].clear();
    }
    if (flag1) {
      printf("1 ");
      for (int i = 1; i <= n; ++i) {
        if (se[i].size() > 0) ans.push_back(i);
      }
      printf("%d\n", ans.size());
      for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
      printf("\n");
    } else if (flag2) {
      printf("2\n");
      for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
      printf("\n");
    } else
      printf("-1\n");
  }
  return 0;
}
