#include <bits/stdc++.h>
using namespace std;
const int mxn = 5e5 + 5;
int N, M;
int u[mxn], v[mxn];
bool used[mxn];
vector<int> match;
void init() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) cin >> u[i] >> v[i];
  for (int i = 1; i <= 3 * N; ++i) used[i] = 0;
  match.clear();
}
void sol() {
  for (int i = 0; i < M; ++i)
    if (!used[u[i]] && !used[v[i]]) {
      used[u[i]] = used[v[i]] = 1;
      match.push_back(i);
    }
  if (match.size() >= N) {
    cout << "Matching\n";
    for (int i = 0; i < N; ++i) cout << match[i] + 1 << " \n"[i + 1 == N];
  } else {
    int n = 0;
    cout << "IndSet\n";
    for (int i = 1; i <= 3 * N; ++i)
      if (!used[i]) {
        ++n;
        cout << i << " \n"[n == N];
        if (n == N) break;
      }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    init();
    sol();
  }
}
