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