#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 5;
int Left[MX], Right[MX], visited[MX];
int main() {
  int testcases;
  scanf("%d", &testcases);
  vector<int> ans;
  while (testcases--) {
    int nodes, edges;
    scanf("%d %d", &nodes, &edges);
    ans.clear();
    for (int i = 1; i <= nodes * 3; i++) visited[i] = 0;
    for (int i = 1; i <= edges; i++) {
      scanf("%d %d", Left + i, Right + i);
      if (visited[Left[i]] == 0 && visited[Right[i]] == 0) {
        ans.push_back(i);
        visited[Left[i]] = visited[Right[i]] = 1;
      }
    }
    if (ans.size() >= nodes) {
      puts("Matching");
      for (int i = 0; i < nodes; i++) {
        if (i) putchar(' ');
        printf("%d", ans[i]);
      }
      puts("");
      continue;
    }
    ans.clear();
    for (int i = 1; i <= 3 * nodes; i++) {
      if (!visited[i]) {
        ans.push_back(i);
      }
      if (ans.size() == nodes) break;
    }
    puts("IndSet");
    for (int i = 0; i < nodes; i++) {
      if (i) putchar(' ');
      printf("%d", ans[i]);
    }
    puts("");
  }
  return 0;
}
