#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > g(3 * n);
  vector<bool> used(3 * n, false);
  vector<pair<int, int> > edges;
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    g[from].push_back(to);
    g[to].push_back(from);
    edges.push_back(make_pair(from, to));
  }
  int matching = 0;
  for (const auto& e : edges) {
    bool fl = true;
    for (int to : g[e.first]) {
      if (used[to]) {
        fl = false;
        break;
      }
    }
    for (int to : g[e.second]) {
      if (used[to]) {
        fl = false;
        break;
      }
    }
    if (fl) {
      matching++;
      used[e.first] = used[e.second] = true;
    }
  }
  int cnt = n;
  if (matching < n) {
    cout << "IndSet\n";
    for (int i = 0; cnt > 0; i++)
      if (!used[i]) cout << i + 1 << ' ', cnt--;
  } else {
    cout << "Matching\n";
    for (int i = 0; cnt > 0; i++)
      if (used[edges[i].first] && used[edges[i].second])
        cout << i + 1 << ' ', cnt--;
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
