#include <bits/stdc++.h>
int vis[400050], rett[400050];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    scanf("%d%d", &n, &m);
    memset(vis, 0, sizeof(int) * (3 * n + 1));
    int cnt = 0;
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (!vis[u] && !vis[v]) {
        vis[u] = vis[v] = 1;
        rett[++cnt] = i;
      }
    }
    if (cnt >= n) {
      puts("Matching");
      for (int i = 1; i <= n; i++) {
        printf("%d ", rett[i]);
      }
      puts("");
    } else {
      puts("IndSet");
      cnt = 1;
      for (int i = 1; cnt <= n; i++) {
        if (!vis[i]) {
          cnt++;
          printf("%d ", i);
        }
      }
      puts("");
    }
  }
}
