#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
bool final[3 * MAXN];
int main() {
  int n, m, tn, t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &m);
    tn = 3 * n;
    for (int i = 0; i <= tn; i++) final[i] = false;
    int a, b, cnt = 0;
    int pp[5 * MAXN];
    for (int i = 0; i <= m; i++) pp[i] = 0;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &a, &b);
      if (!final[a] && !final[b]) {
        cnt++;
        pp[i] = 1;
        final[a] = true;
        final[b] = true;
      }
    }
    if (cnt >= n) {
      printf("Matching\n");
      int c = 0;
      for (int i = 1; i <= m; i++) {
        if (pp[i]) {
          printf("%d ", i);
          c++;
          if (c == n) break;
        }
      }
      printf("\n");
    } else {
      int c = 0;
      printf("IndSet\n");
      for (int i = 1; i <= tn; i++) {
        if (!final[i]) {
          printf("%d ", i);
          c++;
          if (c == n) break;
        }
      }
      printf("\n");
    }
  }
}
