#include <bits/stdc++.h>
using namespace std;
int n;
int vis[500000];
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
    int m;
    cin >> m;
    vector<int> output;
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      if (vis[u] == 0 && vis[v] == 0) {
        vis[u] = 1;
        vis[v] = 1;
        output.push_back(i);
      }
    }
    if (output.size() >= n) {
      cout << "Matching" << endl;
      int count = 1;
      for (int i = 0; i < output.size(); i++) {
        cout << output[i] << " ";
        if (count == n) break;
        count++;
      }
    } else {
      cout << "IndSet" << endl;
      int count = 1;
      for (int i = 1; i <= 3 * n; i++) {
        if (!vis[i]) {
          cout << i << " ";
          count++;
        }
        if (count == n + 1) break;
      }
    }
    cout << endl;
  }
  return 0;
}
