#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
inline void solve() {
  scanf("%d%d", &n, &m);
  vector<int> ck(3 * n + 1, 0), ans;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    if (!ck[x] && !ck[y]) ck[x] = ck[y] = 1, ans.push_back(i + 1);
  }
  if (ans.size() >= n) {
    puts("Matching");
    for (int i = 0; i < n; i++) printf("%d ", ans[i]);
    puts("");
  } else {
    puts("IndSet");
    for (int i = 1, j = 0; i <= 3 * n && j < n; ++i)
      if (!ck[i]) printf("%d ", i), ++j;
    puts("");
  }
}
int main() {
  int T;
  scanf("%d", &T);
  for (int tt = 0; tt < T; ++tt) solve();
}
