#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int M = 1e9 + 5;
int n, m, k, a, b, vis[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int k = 1; k <= t; k++) {
    cin >> n >> m;
    vector<int> num;
    for (int i = 1; i <= m; i++) {
      cin >> a >> b;
      if (vis[a] != k && vis[b] != k) {
        num.push_back(i);
        vis[a] = vis[b] = k;
      }
    }
    if (num.size() >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < n; i++) cout << num[i] << " ";
    } else {
      cout << "IndSet" << endl;
      int now = 0;
      for (int i = 1; i <= 3 * n; i++) {
        if (vis[i] != k) cout << i << " ", now++;
        if (now == n) break;
      }
    }
    cout << endl;
  }
  return 0;
}
