#include <bits/stdc++.h>
using namespace std;
void E() {
  int n, m;
  vector<int> ind;
  vector<int> match;
  vector<int> viz;
  scanf("%d %d", &n, &m);
  viz.resize(3 * n + 3, 0);
  for (int k = 1; k <= m; k++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (viz[a] == 0 && viz[b] == 0) {
      viz[a] = 1;
      viz[b] = 1;
      match.push_back(k);
    }
  }
  if (match.size() >= n) {
    printf("Matching\n");
    for (int k = 0; k < n; k++) printf("%d ", match[k]);
    printf("\n");
    return;
  }
  for (int k = 1; k <= 3 * n; k++) {
    if (viz[k] == 0) {
      ind.push_back(k);
    }
  }
  if (ind.size() >= n) {
    printf("IndSet\n");
    for (int k = 0; k < n; k++) printf("%d ", ind[k]);
    printf("\n");
    return;
  }
  printf("Impossible\n");
  return;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) E();
  return 0;
}
