#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<long long> vis(3 * n + 1);
    vector<long long> mat;
    vector<long long> st;
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      if (!vis[u] && !vis[v]) {
        vis[u]++, vis[v]++;
        mat.push_back(i + 1);
      }
    }
    for (long long i = 1; i < 3 * n + 1; i++) {
      if (!vis[i]) st.push_back(i);
    }
    if (mat.size() >= n) {
      cout << "Matching\n";
      for (long long i = 0; i < n; i++) cout << mat[i] << " ";
    } else if (st.size() >= n) {
      cout << "IndSet\n";
      for (long long i = 0; i < n; i++) cout << st[i] << " ";
    } else {
      cout << "Impossible";
    }
    cout << "\n";
  }
  return 0;
}
