#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  };
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> matching;
    vector<int> vis(3 * n + 1, 0);
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      if (!vis[u] and !vis[v]) {
        matching.push_back(i);
        vis[u] = vis[v] = 1;
      }
    }
    if (matching.size() >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < n; i++) cout << matching[i] << " ";
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      int seen = 0;
      for (int i = 1; i <= 3 * n and seen < n; i++) {
        if (!vis[i]) {
          cout << i << " ";
          seen++;
        }
      }
      cout << endl;
    }
  }
}
