#include <bits/stdc++.h>
using namespace std;
int T;
int n, m;
int vis[300005];
int x[500005], y[500005];
int p;
queue<int> ans;
int main() {
  scanf("%d", &T);
  while (T--) {
    p = 0;
    while (!ans.empty()) {
      vis[x[ans.front()]] = 0;
      vis[y[ans.front()]] = 0;
      ans.pop();
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x[i], &y[i]);
      if (vis[x[i]] || vis[y[i]]) continue;
      vis[x[i]] = 1;
      vis[y[i]] = 1;
      p++;
      ans.push(i);
    }
    if (p >= n) {
      printf("Matching\n");
      for (int i = 1; i <= n; i++) {
        vis[x[ans.front()]] = 0;
        vis[y[ans.front()]] = 0;
        printf("%d ", ans.front());
        ans.pop();
      }
    } else {
      printf("IndSet\n");
      int k = n;
      for (int i = 1; i <= 3 * n; i++) {
        if (vis[i]) continue;
        k--;
        if (k >= 0)
          printf("%d ", i);
        else
          break;
      }
    }
    printf("\n");
  }
  return 0;
}
