#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
bool vis[N];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    vector<int> bian, dian;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d %d", &u, &v);
      if (!vis[u] && !vis[v]) {
        vis[u] = 1;
        vis[v] = 1;
        bian.push_back(i);
      }
    }
    if (bian.size() >= n) {
      printf("Matching\n");
      for (int i : bian) printf("%d ", i);
      printf("\n");
      continue;
    }
    printf("IndSet\n");
    for (int i = 1; i <= 3 * n; i++) {
      if (!vis[i]) printf("%d ", i);
      vis[i] = 0;
    }
    printf("\n");
  }
}
