#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int v, e;
    cin >> v >> e;
    bool ck[3 * v + 3];
    for (int i = 1; i <= 3 * v; i++) ck[i] = true;
    vector<int> sides;
    for (int i = 0; i < e; i++) {
      int a, b;
      cin >> a >> b;
      if (ck[a] && ck[b]) {
        sides.push_back(i + 1);
        ck[a] = false;
        ck[b] = false;
      }
    }
    if (sides.size() >= v) {
      cout << "Matching" << endl;
      for (int i = 0; i < v; i++) {
        cout << sides[i] << " ";
      }
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      int cnt = 0;
      for (int i = 1; i <= 3 * v; i++) {
        if (ck[i]) {
          cout << i << " ";
          cnt++;
        }
        if (cnt == v) break;
      }
      cout << endl;
    }
  }
}
