#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T, n, m, A, B, store[N * 5], tot;
bool check[N * 3];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    tot = 0;
    for (register int i = 1; i <= 3 * n; i++) check[i] = false;
    for (register int i = 1; i <= m; i++) {
      scanf("%d%d", &A, &B);
      if (!check[A] && !check[B]) check[A] = check[B] = true, store[++tot] = i;
    }
    if (tot >= n) {
      printf("Matching\n");
      for (register int i = 1; i <= n; i++)
        printf("%d%c", store[i], i == n ? '\n' : ' ');
    } else {
      printf("IndSet\n");
      for (register int i = 1, all = 0; i <= 3 * n && all < n; i++)
        if (!check[i]) printf("%d%c", i, ++all == n ? '\n' : ' ');
    }
  }
  return 0;
}
