#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long n1 = n;
    n *= 3;
    vector<long long> used(n), mt;
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      u--, v--;
      if (!used[u] && !used[v]) used[u] = used[v] = 1, mt.push_back(i + 1);
    }
    if (mt.size() >= n1) {
      cout << "Matching\n";
      for (long long i = 0; i < n1; i++) cout << mt[i] << ' ';
      cout << '\n';
    } else {
      long long cnt = 0;
      cout << "IndSet\n";
      for (long long i = 0; i < n && cnt < n1; i++)
        if (!used[i]) cout << i + 1 << ' ', cnt++;
      cout << '\n';
    }
  }
  return 0;
}
