#include <bits/stdc++.h>
using namespace std;
int i, k, m, n, t, x, y, w[300018], z[150018];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (cin >> t; t--;) {
    cin >> n >> m;
    for (i = k = 0; i++ < m;) {
      cin >> x >> y;
      if (!w[x] && !w[y]) {
        z[++k] = i;
        w[x] = w[y] = 1;
      }
    }
    if (k < n) {
      cout << "IndSet" << '\n';
      for (i = 1, k = n; k; i++) {
        if (!w[i]) {
          cout << i << ' ';
          k--;
        }
      }
    } else {
      cout << "Matching" << '\n';
      for (i = 0; i++ < n;) cout << z[i] << ' ';
    }
    cout << '\n';
    for (i = 0; i++ < 3 * n;) w[i] = 0;
  }
}
