#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 <= 3 * n; i++) vis[i] = 0;
    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 = 0; i < n; i++) printf("%d ", bian[i]);
      printf("\n");
      continue;
    }
    printf("IndSet\n");
    for (int i = 1, j = 0; i <= 3 * n && j < n; i++) {
      if (!vis[i]) printf("%d ", i), j++;
    }
    printf("\n");
  }
}
