#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct pi {
  int v, id;
};
vector<pi> ve[N];
vector<int> e;
vector<int> s;
bool vis[N];
void sol(int n) {
  for (int i = 1; i <= 3 * n; i++) {
    if (!vis[i]) s.push_back(i);
  }
}
void pre(int n) {
  for (int i = 1; i <= 3 * n; i++) {
    if (vis[i]) continue;
    for (auto p : ve[i]) {
      if (vis[p.v]) continue;
      vis[i] = vis[p.v] = true;
      e.push_back(p.id);
      break;
    }
  }
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d %d", &n, &m);
    e.clear();
    for (int i = 1; i <= n * 3; i++) {
      ve[i].clear();
      vis[i] = 0;
    }
    int u, v;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      ve[u].push_back({v, i});
      ve[v].push_back({u, i});
    }
    pre(n);
    sol(n);
    if (s.size() >= n) {
      puts("IndSet");
      for (int i = 0; i < n; i++) {
        printf("%d ", s[i]);
      }
      puts("");
    } else if (e.size() >= n) {
      puts("Matching");
      for (int i = 0; i < n; i++) {
        printf("%d ", e[i]);
      }
      puts("");
    } else {
      puts("Impossible");
    }
  }
}
