#include <bits/stdc++.h>
using namespace std;
void E() {
  int n, m;
  vector<int> ind;
  vector<int> match;
  set<int> s;
  cin >> n >> m;
  for (int k = 1; k <= m; k++) {
    int a, b;
    cin >> a >> b;
    if (s.find(a) != s.end() && s.find(b) != s.end()) {
      s.insert(a);
      s.insert(b);
      match.push_back(k);
    }
  }
  if (match.size() >= n) {
    cout << "Matching";
    for (int k = 0; k < n; k++) cout << match[k] << ' ';
    cout << endl;
    return;
  }
  for (int k = 1; k <= n; k++) {
    if (s.find(k) == s.end()) {
      ind.push_back(k);
    }
  }
  if (ind.size() >= n) {
    cout << "IndSet" << endl;
    for (int k = 0; k < n; k++) cout << ind[k] << ' ';
    cout << endl;
    return;
  }
  cout << "Impossible" << endl;
  return;
}
int main() {
  int q;
  cin >> q;
  while (q--) E();
  return 0;
}
