#include <bits/stdc++.h>
using namespace std;
void f() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int n, m;
    cin >> n >> m;
    vector<bool> covered(3 * n + 1);
    int covers = 0;
    vector<int> matching;
    for (int j = 0; j < m; j++) {
      int u, v;
      cin >> u >> v;
      if (covered[u] == 0 && covered[v] == 0) {
        matching.push_back(j + 1);
        covered[u] = 1;
        covered[v] = 1;
        covers += 2;
      }
    }
    if (matching.size() >= n) {
      cout << "Matching" << endl;
      for (int j = 0; j < n; j++) {
        cout << matching[j];
        if (j != n - 1) cout << " ";
      }
    } else if (covers >= n) {
      cout << "IndSet" << endl;
      for (int i = 1; i < 3 * n + 1; i++) {
        if (covered[i]) {
          cout << i;
          if (covers != 1) cout << " ";
          covers--;
        }
      }
    } else
      cout << "Impossible";
    cout << endl;
  }
}
int main() {
  f();
  return 0;
}
