#include <bits/stdc++.h>
using namespace std;
const int maxn = 3E5 + 10;
vector<int> ans;
int t, n, m;
int vis[maxn];
int main() {
  scanf("%d", &t);
  while (t--) {
    ans.clear();
    scanf("%d%d", &n, &m);
    n = n * 3;
    for (int i = 0; i <= n; i++) vis[i] = 0;
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (vis[u] == 0 && vis[v] == 0) {
        ans.push_back(i);
        vis[u] = vis[v] = 1;
      }
    }
    if (ans.size() >= n / 3) {
      puts("Matching");
      for (int i = 0; i < n / 3; i++) {
        printf("%d ", ans[i]);
      }
      puts("");
    } else {
      puts("IndSet");
      int cnt = 0;
      for (int i = 1; i <= n && cnt < n / 3; i++) {
        if (vis[i]) continue;
        printf("%d ", i);
      }
      puts("");
    }
  }
  return 0;
}
