#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > side[(int)(3e5 + 100)];
int n, m, tot_side, side_co[(int)(3e5 + 100)];
bool visit[(int)(3e5 + 100)];
void run(int x) {
  if (visit[x]) return;
  for (int i = 0; i < side[x].size(); i++) {
    int v = side[x][i].first;
    if (!visit[v]) {
      visit[v] = 1;
      side_co[++tot_side] = side[x][i].second;
      visit[x] = 1;
      break;
    }
  }
}
void solve() {
  memset(visit, 0, sizeof(visit));
  tot_side = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= 3 * n; i++) side[i].clear();
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    side[u].push_back(make_pair(v, i));
    side[v].push_back(make_pair(u, i));
  }
  for (int i = 1; i <= 3 * n; i++) run(i);
  if (tot_side >= n) {
    printf("Matching\n");
    for (int i = 1; i <= n; i++) {
      printf("%d ", side_co[i]);
    }
    printf("\n");
    return;
  }
  printf("IndSet\n");
  int cnt = 0;
  for (int i = 1; i <= 3 * n && cnt < n; i++) {
    if (!visit[i]) {
      cnt++;
      printf("%d ", i);
    }
  }
  printf("\n");
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
}
