#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
} e[1000005];
int tot, mke[1000005], mkv[1000005], last[1000005];
inline void adde(int u, int v) {
  e[++tot] = (edge){v, last[u]}, last[u] = tot;
  return;
}
inline void inse(int u, int v) {
  adde(u, v), adde(v, u);
  return;
}
inline void sol(void) {
  int n, m, nn, u, v, mat = 0;
  scanf("%d%d", &n, &m), nn = n * 3, tot = 1;
  for (register int i = 1; i <= nn; ++i) last[i] = mkv[i] = 0;
  for (register int i = 1; i <= m; ++i) scanf("%d%d", &u, &v), inse(u, v);
  for (register int i = 1; i <= nn; ++i)
    if (!mkv[i]) {
      for (register int j = last[i]; j; j = e[j].next) {
        int ot = e[j].to;
        if (mkv[ot]) continue;
        mkv[i] = mkv[ot] = 1, mke[++mat] = j >> 1;
        break;
      }
    }
  if (mat >= n) {
    puts("Matching");
    for (register int i = 1; i <= n; ++i) {
      printf("%d ", mke[i]);
    }
    return puts(""), void();
  } else {
    if (nn - (mat << 1) < n) return puts("Impossible"), void();
    puts("IndSet"), mat = 0;
    for (register int i = 1; i <= nn && mat < n; ++i) {
      if (!mkv[i]) printf("%d ", i), ++mat;
    }
    return puts(""), void();
  }
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) sol();
  return 0;
}
