#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n, m, i, j, cnt, a, b, fl[320000], ans[510000];
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i <= 3 * n; i++) fl[i] = 0;
    cnt = 1;
    for (int i = 1; i <= m; i++) {
      cin >> a >> b;
      if (!fl[a] && !fl[b]) {
        ans[cnt++] = i;
        fl[a] = 1;
        fl[b] = 1;
      }
    }
    if (cnt > n) {
      cout << "Matching\n";
      for (int i = 1; i <= n; i++) cout << ans[i] << " ";
      cout << endl;
    } else {
      cout << "IndSet\n";
      j = 1;
      for (i = 1; i <= 3 * n; i++) {
        if (j > n) break;
        if (!fl[i]) {
          cout << i << " ";
          j++;
        }
      }
      cout << endl;
    }
  }
  return 0;
}
