#include <bits/stdc++.h>
using namespace std;
vector<int> eg;
bool vis[300010];
int main() {
  int _;
  scanf("%d", &_);
  while (_--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n * 3; i++) vis[i] = 1;
    eg.clear();
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (vis[u] && vis[v]) {
        vis[u] = vis[v] = 0;
        eg.push_back(i);
      }
    }
    if (eg.size() >= n) {
      puts("Matching");
      for (int i = 0; i < n; i++) {
        printf("%d ", eg[i]);
      }
      puts("");
    } else {
      puts("IndSet");
      int cnt = 0;
      for (int i = 1; i <= n * 3; i++) {
        if (vis[i]) {
          cnt++;
          printf("%d ", i);
          if (cnt == n) break;
        }
      }
      puts("");
    }
  }
}
