#include <bits/stdc++.h>
using namespace std;
int T, n, m, edge[100010], cnt;
bool vis[300010];
int main() {
  scanf("%d", &T);
  while (T-- > 0) {
    scanf("%d %d", &n, &m), cnt = 0;
    memset(vis, false, sizeof(vis));
    for (int i = 1, u, v; i <= m; i++) {
      scanf("%d %d", &u, &v);
      if (vis[u] || vis[v]) continue;
      vis[u] = true, vis[v] = true;
      edge[++cnt] = i;
    }
    if (cnt >= n) {
      puts("Matching");
      for (int i = 1; i <= n; i++) printf("%d ", edge[i]);
      printf("\n");
    } else {
      puts("IndSet");
      for (int i = 1, tmp = 0; i <= 3 * n; i++) {
        if (vis[i]) continue;
        if (tmp >= n) break;
        printf("%d ", i), tmp++;
      }
      printf("\n");
    }
  }
}
