#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int N, M;
    cin >> N >> M;
    vector<bool> A(3 * N);
    vector<int> Val;
    int cnt = 0;
    for (int x = 0; x < M; x++) {
      int v, u;
      cin >> v >> u;
      v--, u--;
      if (!A[v] and !A[u]) {
        Val.push_back(x + 1);
        A[v] = A[u] = true;
        cnt++;
      }
    }
    if (cnt >= N) {
      cout << "Matching" << endl;
      for (int x = 0; x < N; x++) cout << Val[x] << " ";
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      int cnt = 0;
      for (int x = 0, cnt = 0; x < 3 * N and cnt < N; x++) {
        if (A[x]) continue;
        cout << x + 1 << " ";
        cnt++;
      }
      cout << endl;
    }
  }
  return 0;
}
