#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 35;
bool matched[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    n *= 3;
    for (int i = 0; i < n; i++) {
      matched[i] = false;
    }
    vector<int> mm;
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      if (!matched[x] && !matched[y]) {
        matched[x] = true;
        matched[y] = true;
        mm.push_back(i);
      }
    }
    if (mm.size() >= n / 3) {
      cout << "Matching" << endl;
      for (int i = 0; i < n / 3; i++) {
        cout << mm[i] + 1 << " ";
      }
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (!matched[i]) {
          cnt++;
          cout << i + 1 << " ";
          if (cnt == n / 3) {
            break;
          }
        }
      }
      cout << endl;
    }
  }
  return 0;
}
