#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(int x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const int maxn = 1e6 + 10;
const int inf = 1e9;
const double eps = 1e-8;
const int mod = 1e9 + 7;
int d[maxn], c[maxn], n, m;
void solve() {
  read(n), read(m);
  int t = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    read(x), read(y);
    if (!d[x] && !d[y]) d[x]++, d[y]++, c[i] = 1, t++;
  }
  if (t >= n) {
    puts("Matching");
    for (int i = 1, p = 1; p <= n; i++)
      if (c[i]) printf("%d ", i), p++;
  } else {
    puts("IndSet");
    for (int i = 1, p = 1; p <= n; i++)
      if (!d[i]) printf("%d ", i), p++;
  }
  puts("");
}
void clear() {
  for (int i = 1; i <= 3 * n; i++) d[i] = 0;
  for (int i = 1; i <= m; i++) c[i] = 0;
}
int main() {
  int t;
  read(t);
  while (t--) solve(), clear();
  return 0;
}
