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