#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long maxn = 1000 * 1001;
set<pair<long long, long long> > s;
vector<long long> g[maxn];
vector<long long> match, indset;
long long mark[maxn];
long long n, m, q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    cin >> n >> m;
    for (long long i = 1; i <= 3 * n; i++) mark[i] = 0;
    for (long long i = 1; i <= m; i++) {
      long long u, v;
      cin >> u >> v;
      if (mark[u] == 0 && mark[v] == 0) {
        mark[u] = 1;
        mark[v] = 1;
        indset.push_back(i);
      }
    }
    if ((indset.size()) >= n) {
      cout << "Matching\n";
      for (long long i = 0; i < n; i++) cout << indset[i] << " ";
    } else {
      long long ans = 0;
      cout << "IndSet\n";
      for (long long i = 1; i <= 3 * n; i++)
        if (mark[i] == 0 && ans < n) {
          ans++;
          cout << i << " ";
        }
    }
    cout << "\n";
  }
}
