#include <bits/stdc++.h>
using namespace std;
int n, t, m;
int use[300005];
vector<int> sol;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= 3 * n; i++) use[i] = 0;
    sol.clear();
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (!use[x] && !use[y]) {
        use[x] = use[y] = 1;
        sol.push_back(i);
      }
    }
    if (sol.size() >= n) {
      printf("Matching\n");
      for (int i = 0; i < n; i++) cout << sol[i] << ' ';
    } else {
      int cat = 0;
      printf("IndSet\n");
      for (int i = 1; i <= 3 * n && cat < n; i++)
        if (!use[i]) {
          cat++;
          printf("%d ", i);
        }
    }
    printf("\n");
  }
  return 0;
}
