#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
const int maxn = 3 * 1e5 + 10;
bool ok[maxn];
int main() {
  int t, n, m;
  cin >> t;
  while (t--) {
    ans.clear();
    scanf("%d", &n), scanf("%d", &m);
    int x, y;
    for (int i = 1; i <= 3 * n; i++) ok[i] = false;
    for (int i = 1; i <= m; i++) {
      scanf("%d", &x), scanf("%d", &y);
      if (!ok[x] && !ok[y]) {
        ans.push_back(i);
        ok[x] = ok[y] = true;
      }
    }
    if (ans.size() >= n) {
      cout << "Matching" << '\n';
      for (int i = 0; i < n; i++) cout << ans[i] << " ";
      cout << endl;
    } else {
      cout << "IndSet" << '\n';
      int k = 0;
      for (int i = 1; i <= 3 * n; i++) {
        if (k >= n) break;
        if (!ok[i]) {
          cout << i << " ";
          k++;
        }
      }
      cout << endl;
    }
  }
  return 0;
}
