#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 30;
bool visit[N];
inline int read() {
  int x;
  scanf("%d", &x);
  return x;
}
void solve() {
  int n = read();
  int m = read();
  for (int i = 1; i <= n * 3; i++) visit[i] = false;
  vector<int> edges;
  for (int i = 1; i <= m; i++) {
    int u = read();
    int v = read();
    if (!visit[u] && !visit[v]) {
      visit[u] = visit[v] = true;
      edges.push_back(i);
    }
  }
  if (edges.size() >= n) {
    puts("Matching");
    for (int i = 0; i < n; i++) {
      printf("%d ", edges[i]);
    }
    puts("");
  } else {
    puts("IndSet");
    int cnt = 0;
    for (int i = 1; i <= n * 3; i++) {
      if (visit[i]) continue;
      printf("%d ", i);
      if (++cnt == n) break;
    }
    puts("");
  }
}
int main() {
  int T = read();
  while (T--) {
    solve();
  }
  return 0;
}
