#include <bits/stdc++.h>
using namespace std;
template <typename T>
void re(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - 48;
    c = getchar();
  }
  x *= f;
}
template <typename T>
void pr(T x) {
  if (x < 0) {
    putchar('-');
    x = ~x + 1;
  }
  if (x / 10) pr(x / 10);
  putchar(x % 10 + 48);
}
int t, n, m, edge[100000 * 3 + 5];
bool vis[100000 * 3 + 5];
int main() {
  re(t);
  while (t--) {
    re(n);
    re(m);
    memset(vis, 0, sizeof(vis));
    edge[0] = 0;
    for (int i = 1; i <= m; i++) {
      int u, v;
      re(u);
      re(v);
      if (!vis[u] && !vis[v]) {
        vis[u] = vis[v] = 1;
        edge[++edge[0]] = i;
      }
    }
    if (edge[0] >= n) {
      puts("Matching");
      for (int i = 1; i <= n; i++) {
        pr(edge[i]);
        putchar(' ');
      }
      putchar(10);
    } else {
      puts("IndSet");
      int num = 0;
      for (int i = 1; i <= n * 3; i++) {
        if (!vis[i]) {
          pr(i);
          putchar(' ');
          num++;
          if (num == n) break;
        }
      }
      putchar(10);
    }
  }
}
