#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> us(3 * n), ans;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (!us[a] && !us[b]) {
      us[a] = 1;
      us[b] = 1;
      ans.push_back(i);
    }
  }
  if (ans.size() >= n) {
    cout << "Matching" << endl;
    for (int i = 0; i < n; i++) {
      cout << ans[i] + 1 << " ";
    }
    cout << endl;
    return;
  }
  cout << "IndSet" << endl;
  int cnt = 0;
  for (int i = 0; i < 3 * n; i++) {
    if (cnt == n) break;
    if (!us[i]) {
      cout << i + 1 << " ";
      cnt++;
    }
  }
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
