#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, long long> > > adj(300005);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    for (int i = 1; i <= 3 * n; i++) {
      adj[i].clear();
    }
    for (int i = 1; i <= m; i++) {
      long long x, y;
      cin >> x >> y;
      adj[x].push_back({y, i});
      adj[y].push_back({x, i});
    }
    vector<long long> mat, used(3 * n + 1, 0);
    for (int i = 1; i <= 3 * n; i++) {
      if (used[i] == 1) {
        continue;
      }
      for (int j = 0; j < (long long)adj[i].size(); j++) {
        if (!used[adj[i][j].first]) {
          mat.push_back(adj[i][j].second);
          used[i] = used[adj[i][j].first] = 1;
          break;
        }
      }
    }
    if (mat.size() >= n) {
      cout << "Matching"
           << "\n";
      for (int i = 0; i < n; i++) {
        cout << mat[i] << " ";
      }
      cout << "\n";
    } else {
      long long cnt = 0;
      cout << "IndSet"
           << "\n";
      for (int i = 1; i <= 3 * n && cnt < n; i++) {
        if (used[i] == 1) {
          continue;
        }
        cout << i << " ";
        cnt++;
      }
      cout << "\n";
    }
  }
}
