#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, dd[N];
vector<pair<int, int>> ad[N];
void sol() {
  cin >> n >> m;
  n *= 3;
  for (int i = 1; i <= n; ++i) {
    dd[i] = 0;
    ad[i].clear();
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    ad[u].push_back({v, i});
    ad[v].push_back({u, i});
  }
  vector<int> in, ma;
  for (int i = 1; i <= n; ++i) {
    if (dd[i]) continue;
    pair<int, int> ss = {-1, -1};
    for (auto &j : ad[i]) {
      if (!dd[j.first]) ss = j;
    }
    if (ss.first > 0) {
      dd[i] = 1;
      dd[ss.first] = 1;
      ma.push_back(ss.second);
    } else {
      dd[i] = 1;
      in.push_back(i);
    }
  }
  if (ma.size() > in.size()) {
    cout << "Matching\n";
    for (int i = 0; i < n / 3; ++i) {
      cout << ma[i] << ' ';
    }
    cout << "\n";
  } else {
    cout << "Indset\n";
    for (int i = 0; i < n / 3; ++i) cout << in[i] << " ";
    cout << "\n";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    sol();
  }
}
