#include <bits/stdc++.h>
using namespace std;
const int vernum = 300050;
const int edgenum = 500050;
int T;
int n, m, a, b;
bool flag[vernum];
bool flage[edgenum];
int edgetot;
int main() {
  scanf("%d", &T);
  while (T) {
    memset(flag + 1, 0, n * 3);
    edgetot = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &a, &b);
      if (!flag[a] & !flag[b]) {
        edgetot++;
        flag[a] = 1;
        flag[b] = 1;
        flage[i] = 1;
      } else
        flage[i] = 0;
    }
    if (edgetot >= n) {
      puts("Matching");
      for (int i = 1, j = 1; j <= n; i++) {
        if (flage[i]) {
          j++;
          printf("%d ", i);
        }
      }
    } else {
      puts("IndSet");
      for (int i = 1, j = 1; j <= n; i++) {
        if (!flag[i]) {
          j++;
          printf("%d ", i);
        }
      }
      puts("");
    }
    T--;
  }
  return 0;
}
