#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n, m, tot;
int l[N], vis[N * 3];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
void solve() {
  n = read(), m = read();
  tot = 0;
  for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    if (!vis[x] && !vis[y]) {
      vis[x] = vis[y] = 1;
      l[++tot] = i;
    }
  }
  if (tot >= n) {
    puts("Matching");
    for (int i = 1; i <= n; i++) printf("%d ", l[i]);
    return puts(""), void();
  }
  int num = 0;
  puts("IndSet");
  for (int i = 1; i <= 3 * n; i++) {
    if (!vis[i]) printf("%d ", i), ++num;
    if (num == n) return puts(""), void();
  }
}
int main() {
  int t = read();
  while (t--) solve();
  return 0;
}
