#include <bits/stdc++.h>
using namespace std;
namespace io {
char buf[1 << 21], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 != p2) return *p1++;
  p1 = buf;
  p2 = p1 + fread(buf, 1, 1 << 21, stdin);
  return p1 == p2 ? EOF : *p1++;
}
template <class I>
inline void read(I &x) {
  x = 0;
  I f = 1;
  char c = gc();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = gc();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = gc();
  }
  x *= f;
}
template <class I>
inline void write(I x) {
  if (x == 0) {
    putchar('0');
    return;
  }
  I tmp = x > 0 ? x : -x;
  if (x < 0) putchar('-');
  int cnt = 0;
  while (tmp > 0) {
    buf[cnt++] = tmp % 10 + '0';
    tmp /= 10;
  }
  while (cnt > 0) putchar(buf[--cnt]);
}
}  // namespace io
using namespace io;
const int N = 300010;
int T, n, m;
int vis[N], ans[N], cnt;
int main() {
  read(T);
  memset(vis, -1, sizeof(vis));
  while (T--) {
    cnt = 0;
    read(n);
    read(m);
    for (int u, v, i = 1; i <= m; ++i) {
      read(u);
      read(v);
      if (vis[u] != T && vis[v] != T) {
        vis[u] = vis[v] = T;
        ans[++cnt] = i;
      }
    }
    if (cnt >= n) {
      puts("Matching");
      for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
      puts("");
    } else {
      cnt = 0;
      puts("IndSet");
      for (int i = 1; i <= 3 * n; ++i)
        if (vis[i] != T) ans[++cnt] = i;
      for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
      puts("");
    }
  }
}
