#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    bool taken[n + n + n + 1];
    memset(taken, false, sizeof(taken));
    vector<int> edges;
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      if (taken[a] || taken[b]) continue;
      taken[a] = true;
      taken[b] = true;
      edges.push_back(i + 1);
    }
    sort(edges.begin(), edges.end());
    if (edges.size() >= n) {
      cout << "Matching\n";
      for (int i = 0; i < n; i++) cout << edges[i] << " ";
    } else {
      cout << "IndSet\n";
      int cnt = 0;
      for (int i = 1; i <= 3 * n; i++) {
        if (taken[i]) continue;
        cnt++;
        cout << i << " ";
        if (cnt == n) break;
      }
    }
    cout << endl;
  }
  return 0;
}
