#include <bits/stdc++.h>
using namespace std;
int n, m, flag;
int ans[500010];
bool vis[500010];
inline void prework() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= 3 * n; i++) vis[i] = false;
  ans[0] = 0;
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if (!vis[u] && !vis[v]) {
      vis[u] = vis[v] = true;
      ans[++ans[0]] = i;
    }
  }
  if (ans[0] >= n) {
    flag = 1;
    return;
  }
  flag = 2;
  ans[0] = 0;
  for (int i = 1; i <= 3 * n; i++)
    if (!vis[i]) ans[++ans[0]] = i;
  ;
}
inline void mainwork() {}
inline void print() {
  if (flag == 1)
    puts("Matching");
  else
    puts("IndSet");
  for (int i = 1; i <= n; i++) printf("%d%c", ans[i], (i == n) ? '\n' : ' ');
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) {
    prework();
    mainwork();
    print();
  }
  return 0;
}
