#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > edges;
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      edges.push_back({u, v});
    }
    int *visit = new int[3 * n];
    memset(visit, 0, 12 * n);
    vector<int> ans;
    for (int i = 0; i < m; i++) {
      if (!(visit[edges[i].first] || visit[edges[i].second])) {
        ans.push_back(i);
        visit[edges[i].first] = 1;
        visit[edges[i].second] = 1;
      }
    }
    if (ans.size() >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << " ";
      }
      cout << endl;
    } else {
      int count = 0;
      cout << "IndSet" << endl;
      for (int i = 0; (count < n) && (i < 3 * n); i++) {
        if (!visit[i]) {
          cout << i + 1 << " ";
          count++;
        }
      }
      cout << endl;
    }
    delete[] visit;
  }
}
