#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int maxn = 3e5 + 7;
const int maxm = 1e6 + 100;
int n, m, que[maxm], ql, qr, pre[maxn], tim = 0, _vis[maxn];
int match2[maxn];
struct edge {
  int v, nxt, id;
} e[maxm];
int h[maxn], tot = 0;
int match[maxn], f[maxn], tp[maxn], tic[maxn];
void init() {
  for (int i = 1; i <= n; i++) match[i] = match2[i] = tic[i] = h[i] = 0;
  tot = 0;
}
struct Edge {
  int x, y, id;
};
Edge es[maxm];
int nvis[maxn];
int main() {
  int T;
  T = read();
  while (T--) {
    n = read(), m = read();
    n = n * 3;
    if (1) {
      for (int i = 1; i <= n; i++) nvis[i] = 0;
      for (int i = 1; i <= m; ++i) {
        int x = read(), y = read();
        es[i] = Edge{x, y, i};
      }
      int cnt = 0;
      random_shuffle(es + 1, es + 1 + m);
      vector<int> ans;
      for (int i = 1; i <= m; i++) {
        if (!nvis[es[i].x] && !nvis[es[i].y]) {
          nvis[es[i].x] = nvis[es[i].y] = 1;
          ans.push_back(es[i].id);
          cnt++;
        }
        if (cnt == n / 3) break;
      }
      if (cnt == n / 3) {
        printf("Matching\n");
        for (int i = 0; i < n / 3; i++) {
          printf("%d", ans[i]);
          if (i != n / 3 - 1) printf(" ");
        }
      } else {
        printf("IndSet\n");
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
          if (!nvis[i]) {
            cnt++;
            printf("%d", i);
            if (cnt != n / 3) printf(" ");
          }
          if (cnt == n / 3) break;
        }
      }
      printf("\n");
      continue;
    }
  }
  return 0;
}
