#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 1;
bool dead[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    int mx = 3 * n;
    for (int i = 1; i < mx + 1; i++) dead[i] = 0;
    vector<int> ind;
    vector<int> mat;
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      if (!dead[x] and !dead[y]) {
        dead[x] = 1;
        dead[y] = 1;
        mat.push_back(i + 1);
      }
    }
    for (int i = 1; i <= mx; i++) {
      if (!dead[i]) {
        dead[i] = 1;
        ind.push_back(i);
      }
    }
    if (ind.size() >= n) {
      cout << "IndSet\n";
      for (int i = 0; i < n; i++) {
        cout << ind[i] << " ";
      }
      cout << "\n";
      continue;
    }
    if (mat.size() >= n) {
      cout << "Matching\n";
      for (int i = 0; i < n; i++) {
        cout << mat[i] << " ";
      }
      cout << "\n";
      continue;
    }
  }
  return 0;
}
