#include <bits/stdc++.h>
using namespace std;
const int mxn = 5e5 + 5;
const int inf = 1e9;
int l[mxn], r[mxn];
vector<int> adj[mxn];
int match[mxn];
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= 3 * n; i++) {
    adj[i].clear();
    match[i] = -1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l[i], &r[i]);
    adj[l[i]].push_back(i);
    adj[r[i]].push_back(i);
  }
  vector<int> ed;
  for (int i = 1; i <= 3 * n; i++) {
    if (match[i] != -1) continue;
    for (int x : adj[i]) {
      int v = l[x] ^ r[x] ^ i;
      if (match[v] == -1) {
        match[v] = i;
        match[i] = v;
        ed.push_back(x);
        break;
      }
    }
  }
  if (ed.size() >= n) {
    printf("Matching\n");
    for (int i = 0; i < n; i++) {
      printf("%d ", ed[i]);
    }
    printf("\n");
    return;
  }
  printf("IndSet\n");
  int k = 0;
  for (int i = 1; i <= 3 * n; i++) {
    if (match[i] == -1) {
      printf("%d ", i);
      k++;
      if (k == n) break;
    }
  }
  printf("\n");
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
