#include <bits/stdc++.h>
using namespace std;
namespace io {
const int l = 1 << 20;
char buf[l], *s, *t;
char gc() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, l, stdin);
    return s == t ? EOF : *s++;
  }
  return *s++;
}
char c;
template <class IT>
inline void gi(IT &x) {
  x = 0;
  c = gc();
  while (c < '0' || c > '9') c = gc();
  while ('0' <= c && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ '0');
    c = gc();
  }
}
};  // namespace io
using io::gi;
const long long p = 1000000007ll;
const int N = 300005;
template <class IT>
void cmin(IT &a, IT b) {
  if (b < a) a = b;
}
template <class IT>
void cmax(IT &a, IT b) {
  if (a < b) a = b;
}
int t[N], a[N];
int main() {
  int q, n, n3, m, i, k, v, u;
  scanf("%d", &q);
  for (; q; --q) {
    scanf("%d%d", &n, &m);
    n3 = n + (n << 1);
    k = 0;
    for (i = 1; i <= n3; ++i) a[i] = 1;
    for (i = 1; i <= m; ++i) {
      scanf("%d%d", &v, &u);
      if (a[v] && a[u]) {
        a[v] = a[u] = 0;
        t[++k] = i;
      }
    }
    if (k >= n) {
      puts("Matching");
      for (i = 1; i <= n; ++i) printf("%d ", t[i]);
      puts("");
    } else {
      puts("IndSet");
      for (i = 1; i <= n3; ++i)
        if (a[i]) {
          printf("%d ", i);
          if (!(--n)) break;
        }
      puts("");
    }
  }
  return 0;
}
