#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> used(3 * n + 1);
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      if (used[u] || used[v]) continue;
      used[u] = used[v] = true;
    }
    int cnt = count((used).begin(), (used).end(), true);
    cout << (cnt >= n ? "Matching" : "IndSet") << '\n';
    bool target = cnt >= n;
    int need = n;
    int i = 0;
    while (need) {
      if (used[i] == target) {
        cout << i << " ";
        --need;
      }
      ++i;
    }
    cout << '\n';
  }
  return 0;
}
