#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    set<int> used;
    vector<int> matching;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      if (used.find(u) == used.end() && used.find(v) == used.end()) {
        used.insert(u);
        used.insert(v);
        matching.push_back(i + 1);
      }
    }
    if ((int)matching.size() >= n) {
      cout << "Matching" << '\n';
      for (int i = 0; i < n; i++) {
        if (i) cout << ' ';
        cout << matching[i];
      }
      cout << '\n';
      continue;
    }
    int cnt = 0;
    cout << "IndSet\n";
    for (int i = 1; i <= 3 * n; i++) {
      if (used.find(i) == used.end()) {
        if (cnt) cout << ' ';
        cnt++;
        cout << i;
        if (cnt == n) break;
      }
    }
    cout << '\n';
  }
  return 0;
}
