#include <bits/stdc++.h>
using namespace std;
bool usedV[300000];
bool usedE[500000];
int main() {
  int T;
  cin >> T;
  for (int epoch = 0; epoch < T; epoch++) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n * 3; i++) usedV[i] = false;
    int ans = 0;
    for (int i = 0; i < m; i++) {
      usedE[i] = false;
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      if (!usedV[a] && !usedV[b]) {
        ans++;
        usedV[a] = true;
        usedV[b] = true;
        usedE[i] = true;
      }
    }
    if (ans >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < m; i++)
        if (usedE[i]) cout << i + 1 << " ";
    } else {
      cout << "IndSet" << endl;
      for (int i = 0; i < n * 3; i++)
        if (!usedV[i]) cout << i + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
