#include <bits/stdc++.h>
using namespace std;
const long double E = 2.71828182845904523536;
const long double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long inf = 1LL << 30;
const int N = 300300;
vector<int> ans;
bool cov[N];
int n, m;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    n *= 3;
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (cov[u] || cov[v]) continue;
      cov[u] = cov[v] = 1;
      ans.push_back(i);
    }
    int k = n / 3;
    if (ans.size() >= k)
      printf("Matching\n");
    else {
      ans.clear();
      printf("IndSet\n");
      for (int i = 1; i <= n; i++)
        if (!cov[i]) ans.push_back(i);
    }
    for (int i = 0; i < k; i++) printf("%d%c", ans[i], " \n"[i == k - 1]);
    ans.clear();
    for (int i = 1; i <= n; i++) cov[i] = 0;
  }
  return 0;
}
