#include <bits/stdc++.h>
int n, m, u, v, t;
using namespace std;
void solve() {
  scanf("%d%d", &n, &m);
  vector<bool> check(3 * n + 1, 0);
  vector<int> ans;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if (!check[u] && !check[v]) check[u] = check[v] = 1, ans.push_back(i);
  }
  if (ans.size() >= n) {
    printf("Matching\n");
    for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  } else {
    printf("IndSet\n");
    for (int i = 1, j = 0; i <= 3 * n && j < n; i++)
      if (!check[i]) printf("%d ", i), j++;
  }
  printf("\n");
}
int main() {
  cin >> t;
  while (t--) solve();
  return 0;
}
