#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  bool s[3 * n + 5];
  memset(s, true, sizeof(s));
  vector<int> match;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    if (s[u] && s[v]) {
      match.push_back(i + 1);
      s[u] = s[v] = false;
    }
  }
  if (match.size() >= n) {
    cout << "Matching"
         << "\n";
    for (int i = 0; i < n; ++i) cout << match[i] << " ";
  } else {
    cout << "IndSet"
         << " \n";
    for (int i = 1, cnt = 1; i <= 3 * n && cnt <= n; ++i)
      if (s[i]) {
        ++cnt;
        cout << i << " ";
      }
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int test;
  cin >> test;
  while (test--) solve();
}
