#include <bits/stdc++.h>
using namespace std;
int n, m;
bitset<300100> bs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc, a, b;
  cin >> tc;
  while (tc--) {
    cin >> n >> m;
    bs.reset();
    vector<int> matching;
    for (int i = int(1); i < int(m + 1); ++i) {
      cin >> a >> b;
      if (!bs[a] and !bs[b]) {
        bs.set(a);
        bs.set(b);
        matching.push_back(i);
      }
    }
    if (int(matching.size()) >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < n; ++i) cout << matching[i] << " ";
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      vector<int> vec;
      for (int i = 1; int(vec.size()) <= n and i <= 3 * n; ++i)
        if (!bs[i]) vec.push_back(i);
      for (int i = 0; i < n; ++i) cout << vec[i] << " ";
      cout << endl;
    }
  }
  return 0;
}
