#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    long long n, m, i, j;
    cin >> n >> m;
    set<long long> s;
    for (i = 1; i <= 3 * n; i++) s.insert(i);
    vector<long long int> ver;
    for (i = 1; i <= m; i++) {
      long long x, y;
      cin >> x >> y;
      if (s.find(x) != s.end() && s.find(y) != s.end()) {
        ver.push_back(i);
        s.erase(x);
        s.erase(y);
      }
    }
    if (ver.size() >= n) {
      cout << "Matching\n";
      for (i = 0; i < n; i++) cout << ver[i] << " ";
      cout << "\n";
    } else if (s.size() >= n) {
      cout << "IndSet\n";
      long long cnt = 0;
      for (auto i : s) {
        cnt++;
        if (cnt > n) break;
        cout << i << " ";
      }
      cout << "\n";
    } else
      cout << "Impossible\n";
  }
  return 0;
}
