#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  int t, n, m, e0, e1;
  vector<int> edgs;
  bool v[3 * 500000 + 1] = {false};
  cin >> t;
  for (int i = 0; i < (t); i++) {
    cin >> n >> m;
    for (int j = 0; j < (m); j++) {
      cin >> e0 >> e1;
      if (!v[e0] && !v[e1]) {
        v[e0] = true;
        v[e1] = true;
        edgs.push_back(j + 1);
      }
    }
    if (edgs.size() >= n) {
      cout << "Matching" << endl;
      for (int j = 0; j < (n - 1); j++) {
        cout << edgs[j] << " ";
      }
      cout << edgs[n - 1] << endl;
    } else {
      cout << "IndSet" << endl;
      int cnt = 0;
      for (int j = 0; j < (3 * n + 1); j++) {
        if (cnt < n && v[j]) {
          cout << j + 1;
          cnt++;
          if (cnt < n) {
            cout << " ";
          } else {
            cout << endl;
          }
        }
      }
    }
    for (int j = 0; j < (3 * n + 1); j++) {
      v[j] = false;
    }
    edgs.clear();
  }
  return 0;
}
