#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long N = 3e5 + 5;
long long n, m;
bitset<N> used;
vector<long long> ans;
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= 3 * n; i++) {
    used[i] = 0;
  }
  ans.clear();
  for (long long i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    if (used[u] == 0 and used[v] == 0) {
      used[u] = used[v] = 1;
      ans.push_back(i + 1);
    }
  }
  if ((long long)(ans.size()) >= n) {
    cout << "Matching\n";
    for (long long i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  } else {
    cout << "IndSet\n";
    long long cnt = 0;
    for (long long i = 1; i <= 3 * n and cnt < n; i++) {
      if (used[i] == 0) {
        cnt++;
        cout << i << " ";
      }
    }
    cout << endl;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tt;
  cin >> tt;
  while (tt--) solve();
  return 0;
}
