#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
const long long N = 3e5 + 5;
vector<long long> edge;
long long edgeNum;
long long vis[N];
signed main() {
  long long T = read();
  while (T--) {
    long long n = read();
    long long m = read();
    edge.clear();
    edgeNum = 0;
    for (long long i = 1; i <= m; ++i) {
      long long u = read();
      long long v = read();
      if (!vis[u] && !vis[v]) {
        vis[u] = 1;
        vis[v] = 1;
        ++edgeNum;
        edge.push_back(i);
      }
    }
    if (edgeNum >= n) {
      puts("Matching");
      for (long long i = 0; i < n; ++i) printf("%d ", edge[i]);
      puts("");
    } else if (n * 3 - edgeNum * 2 >= n) {
      puts("IndSet");
      for (long long i = 1, cnt = 1; i <= 3 * n, cnt <= n; ++i)
        if (!vis[i]) printf("%d ", i), ++cnt;
      puts("");
    }
    for (long long i = 1; i <= n * 3; ++i) vis[i] = 0;
  }
  return 0;
}
