#include <bits/stdc++.h>
using namespace std;
int vis[300005];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> ans;
    ans.clear();
    for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (!vis[x] && !vis[y]) {
        vis[x] = 1;
        vis[y] = 1;
        ans.push_back(i);
      }
    }
    if (ans.size() >= n) {
      printf("Matching\n");
      int cnt = 0;
      for (int it : ans) {
        if (cnt < n) printf("%d ", it);
        cnt++;
        if (cnt == n) break;
      }
    } else {
      printf("IndSet\n");
      int cnt = 0;
      for (int i = 1; i <= 3 * n; i++) {
        if (vis[i] == 0) {
          if (cnt < n) printf("%d ", i);
          cnt++;
          if (cnt == n) break;
        }
      }
    }
    printf("\n");
  }
  return 0;
}
