#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(20);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<long long> used(3 * n, false), res;
    for (long long i = 0; i < m; ++i) {
      long long u, v;
      cin >> u >> v;
      --u, --v;
      if (!used[u] && !used[v]) {
        res.push_back(i + 1);
        used[u] = used[v] = true;
      }
    }
    if (res.size() >= n) {
      cout << "Matching\n";
    } else {
      res.clear();
      for (long long i = 0; i < 3 * n; ++i)
        if (!used[i]) res.push_back(i + 1);
      cout << "IndSet\n";
    }
    res.resize(n);
    for (auto& i : res) cout << i << " ";
    cout << "\n";
  }
}
