#include <bits/stdc++.h>
using namespace std;
struct node {
  int u, v;
};
node rds[2000001];
bool vis[2000001];
vector<int> match;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    scanf("%d%d", &n, &m);
    match.clear();
    for (int i = 1; i <= 3 * n; ++i) vis[i] = false;
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &rds[i].u, &rds[i].v);
    }
    for (int i = 0; i < m; ++i) {
      if (!vis[rds[i].u] && !vis[rds[i].v]) {
        vis[rds[i].u] = vis[rds[i].v] = true;
        match.push_back(i + 1);
      }
    }
    if (match.size() >= n) {
      printf("Matching\n");
      for (int i = 0; i < n; ++i) printf("%d ", match[i]);
    } else {
      printf("IndSet\n");
      int rest = n;
      for (int i = 1; i <= 3 * n; ++i)
        if (!vis[i]) {
          printf("%d ", i);
          --rest;
          if (!rest) break;
        }
    }
    printf("\n");
  }
}
