#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
void inlld(long long &a) { scanf("%lld", &a); }
void ind(int &a) { scanf("%d", &a); }
int n, m, taken[N];
vector<int> matching;
void main2() {
  matching.clear();
  ind(n);
  ind(m);
  for (int a = 0; a <= 3 * n; a++) taken[a] = 0;
  for (int a = 1; a <= m; a++) {
    int u, v;
    ind(u);
    ind(v);
    if (taken[u] == 0 && taken[v] == 0) {
      taken[u] = 1;
      taken[v] = 1;
      matching.push_back(a);
    }
  }
  if (matching.size() >= n) {
    printf("Matching\n");
    for (int a = 0; a < n; a++) printf("%d ", matching[a]);
    printf("\n");
    return;
  }
  printf("IndSet\n");
  int cnt = 0;
  for (int a = 1; a <= 3 * n; a++)
    if (!taken[a]) {
      printf("%d ", a);
      cnt++;
      if (cnt == n) break;
    }
  printf("\n");
}
int main() {
  int t;
  ind(t);
  while (t--) main2();
  return 0;
}
