#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m, k = 0;
    int ma[300010];
    vector<int> a;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= 3 * n; ++i) ma[i] = 0;
    for (int i = 1, u, v; i <= m; ++i) {
      scanf(" %d%d", &u, &v);
      if (!ma[u] && !ma[v]) ma[u] = ma[v] = 1, a.push_back(i);
    }
    int c = 0;
    if (a.size() >= n) {
      printf("Matching\n");
      for (int i : a) {
        printf("%d ", i), ++c;
        if (c == n) break;
      }
    } else {
      printf("IndSet\n");
      for (int i = 1; i <= 3 * n; ++i) {
        if (!ma[i]) printf("%d ", i), ++c;
        if (c == n) break;
      }
    }
    puts("");
  }
  return 0;
}
