#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> matching;
    set<int> mv;
    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      u--;
      v--;
      if (mv.find(u) == mv.end() && mv.find(v) == mv.end()) {
        matching.push_back(i);
        mv.insert(u);
        mv.insert(v);
      }
    }
    if (matching.size() >= n) {
      printf("Matching\n");
      for (int i = 0; i < n; i++) printf("%d ", matching[i] + 1);
      printf("\n");
    } else {
      printf("IndSet\n");
      vector<int> is;
      for (int i = 0; i < 3 * n; i++)
        if (mv.find(i) == mv.end()) is.push_back(i);
      for (int i = 0; i < n; i++) printf("%d ", is[i] + 1);
      printf("\n");
    }
  }
  return 0;
}
