#include <bits/stdc++.h>
using namespace std;
void scan() {}
template <typename T, typename... Args>
void scan(T &a, Args &...args) {
  cin >> a;
  scan(args...);
}
void sortt(long long &a, long long &b, long long &c) {
  if (b < a) swap(a, b);
  if (c < b) swap(b, c);
  if (b < a) swap(a, b);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long tz;
  cin >> tz;
  while (tz--) {
    ;
    long long n, m;
    ;
    { scan(n, m); };
    ;
    long long u, v;
    long long make_pair[3 * n + 1];
    vector<long long> ans1, ans2;
    memset(make_pair, 0, sizeof(make_pair));
    for (long long i = 1; i <= m; i++) {
      cin >> u >> v;
      if (!make_pair[u] && !make_pair[v]) {
        make_pair[u] = 1;
        make_pair[v] = 1;
        ans1.push_back(i);
      }
    }
    if (ans1.size() >= n) {
      cout << "Matching\n";
      for (long long i = 0; i < n; i++) cout << ans1[i] << ' ';
      cout << '\n';
    } else {
      long long k = 0, i = 1;
      cout << "IndSet\n";
      while (k < n) {
        while (make_pair[i]) i++;
        cout << i << ' ';
        k++;
        i++;
      }
      cout << "\n";
    }
  }
}
