#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t;
  cin >> t;
  for (; t > 0; t--) {
    long long n, m;
    cin >> n >> m;
    n *= 3;
    vector<bool> a((size_t)n, false);
    vector<long long> b;
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      u--, v--;
      if (!a[u] && !a[v]) {
        a[u] = true, a[v] = true;
        b.push_back(i);
      }
    }
    if ((long long)b.size() >= n / 3) {
      cout << "Matching"
           << "\n";
      long long j = 0;
      for (long long i : b) {
        cout << i + 1 << " ";
        j++;
        if (j >= n / 3) {
          break;
        }
      }
      cout << "\n";
    } else {
      cout << "IndSet"
           << "\n";
      for (long long i = 0, j = 0; i < n && j < n / 3; i++) {
        if (!a[i]) {
          cout << i + 1 << " ";
          j++;
        }
      }
      cout << "\n";
    }
  }
  return 0;
}
