#include <bits/stdc++.h>
using namespace std;
const int N = 500000 + 77;
int T, n, m;
bool M[N];
int Ev[N], Eu[N];
vector<int> Mt, I;
inline void Test() {
  Mt.clear();
  I.clear();
  scanf("%d %d", &n, &m);
  int t = n;
  n *= 3;
  for (int i = 1; i <= m; ++i) scanf("%d %d", &Ev[i], &Eu[i]);
  for (int i = 1; i <= m; ++i) {
    if (!M[Ev[i]] && !M[Eu[i]]) {
      Mt.push_back(i);
      M[Ev[i]] = M[Eu[i]] = 1;
    }
  }
  if ((int)Mt.size() < t) {
    for (int i = 1; i <= n; ++i)
      if (!M[i]) I.push_back(i);
  }
  for (int i = 1; i <= n; ++i) M[i] = 0;
  if ((int)Mt.size() >= t) {
    printf("Matching\n");
    for (int i = 1; i <= t; ++i) printf("%d ", Mt[i - 1]);
  } else {
    printf("IndSet\n");
    for (int i = 1; i <= t; ++i) printf("%d ", I[i - 1]);
  }
  printf("\n");
}
int main() {
  scanf("%d", &T);
  while (T--) Test();
  return 0;
}
