#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int MAX_N = 3e5 + 5;
bool used[MAX_N];
void solve() {
  int n, m;
  cin >> n >> m;
  int N = 3 * n;
  fill(used, used + N, false);
  vector<int> ans;
  for (int i = 0; i < m; ++i) {
    int v, u;
    cin >> v >> u;
    --v, --u;
    if (!used[v] && !used[u]) {
      ans.push_back(i);
      used[v] = true;
      used[u] = true;
    }
  }
  if ((int)ans.size() < n) {
    ans.clear();
    for (int v = 0; v < N; ++v) {
      if (!used[v]) {
        ans.push_back(v);
      }
    }
    cout << "IndSet\n";
  } else {
    cout << "Matching\n";
  }
  assert((int)ans.size() >= n);
  for (int i = 0; i < n; ++i) {
    cout << ans[i] + 1 << " ";
  }
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tests = 1;
  cin >> tests;
  while (tests--) {
    solve();
  }
  return 0;
}
