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