#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 10;
vector<int> IndSet, Match;
bool vis[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof(vis));
    IndSet.clear();
    Match.clear();
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (!vis[u] and !vis[v]) {
        vis[u] = vis[v] = 1;
        Match.push_back(i);
      }
    }
    int cnt = 0;
    for (int i = 1; i <= 3 * n; i++)
      if (!vis[i]) IndSet.push_back(i);
    if (IndSet.size() >= n) {
      printf("IndSet\n");
      for (int i = 0; i < n; i++) printf("%d ", IndSet[i]);
      printf("\n");
    } else {
      printf("Matching\n");
      for (int i = 0; i < n; i++) printf("%d ", Match[i]);
      printf("\n");
    }
  }
  return 0;
}
