#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    int ma[300010] = {};
    vector<int> a;
    scanf("%d%d", &n, &m);
    for (int i = 1, u, v; i <= m; ++i) {
      scanf("%d%d", &u, &v);
      if (!ma[u] && !ma[v]) ma[u] = ma[v] = 1, a.emplace_back(i);
    }
    if (a.size() >= n) {
      printf("Matching\n");
      for (int i : a) printf("%d ", i);
      puts("");
    } else {
      printf("IndSet\n");
      int c = 0;
      for (int i = 1; i <= 3 * n; ++i) {
        if (!ma[i]) printf("%d ", i), ++c;
        if (c == n) break;
      }
      puts("");
    }
  }
  return 0;
}
