#include <bits/stdc++.h>
using namespace std;
int n, m, u[500005], v[500005];
bool h[300005];
vector<int> ans;
int main() {
  int _;
  scanf("%d", &_);
  while (_--) {
    scanf("%d%d", &n, &m);
    fill(h, h + 3 * n + 3, 0);
    for (int i = 1; i <= m; i++) scanf("%d%d", v + i, u + i);
    ans.clear();
    for (int i = 1; i <= m; i++)
      if (!h[u[i]] && !h[v[i]]) ans.push_back(i), h[u[i]] = h[v[i]] = 1;
    if (ans.size() >= n)
      printf("Matching\n");
    else {
      printf("IndSet\n");
      ans.clear();
      for (int i = 1; i <= 3 * n; i++)
        if (!h[i]) ans.push_back(i);
    }
    for (int i = 0; i < n; i++) printf("%d%c", ans[i], " \n"[i + 1 == n]);
  }
  return 0;
}
