#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<long long> v[3 * n];
    vector<pair<long long, long long> > ed;
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      a--;
      b--;
      ed.push_back(make_pair(a, b));
      v[a].push_back(b);
      v[b].push_back(b);
    }
    if (m == 0) {
      cout << "IndSet"
           << "\n";
      for (long long i = 0; i < n; i++) cout << i + 1 << " ";
      cout << "\n";
      continue;
    }
    long long count = 0;
    bool mark[3 * n];
    memset(mark, 0, sizeof(mark));
    mark[ed[0].first] = 1;
    mark[ed[0].second] = 1;
    vector<long long> fin;
    fin.push_back(1);
    for (long long i = 1; i < m; i++) {
      if (mark[ed[i].first] == 1 || mark[ed[i].second] == 1) continue;
      mark[ed[i].first] = (mark[ed[i].second] = 1);
      fin.push_back(i + 1);
      count++;
    }
    if (count >= n) {
      cout << "Matching"
           << "\n";
      for (long long i = 0; i < n; i++) cout << fin[i] << " ";
      cout << "\n";
      continue;
    }
    cout << "IndSet"
         << "\n";
    count = 0;
    for (long long i = 0; i < 3 * n; i++) {
      if (mark[i] == 1) continue;
      count++;
      cout << i + 1 << " ";
      if (count == n) break;
    }
    cout << "\n";
  }
  return 0;
}
