#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2, inf = 1e9 + 10;
int was[N];
vector<int> match;
vector<pair<int, int>> a[N];
void solve(int u) {
  for (auto v : a[u])
    if (was[v.first] == 0) {
      match.push_back(v.second);
      was[v.first] = 1;
      was[u] = 1;
      return;
    }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  for (int test = 0; test < q; ++test) {
    int n, m;
    cin >> n >> m;
    match.clear();
    for (int i = 0; i < 3 * n; ++i) a[i].clear(), was[i] = 0;
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      a[u - 1].push_back({v - 1, i});
      a[v - 1].push_back({u - 1, i});
    }
    for (int i = 0; i < 3 * n; ++i)
      if (was[i] == 0) solve(i);
    if (match.size() >= n) {
      cout << "Matching\n";
      for (int i = 0; i < n; ++i) cout << match[i] + 1 << " ";
      cout << "\n";
      continue;
    }
    cout << "IndSet\n";
    int cnt = 0;
    for (int i = 0; cnt < n; ++i)
      if (was[i] == 0) cout << i + 1 << " ", ++cnt;
    cout << "\n";
  }
}
