#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, p[maxn], cnt;
bool vis[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
    cnt = 0;
    int x, y;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x, &y);
      if (!vis[x] && !vis[y]) vis[x] = vis[y] = 1, p[++cnt] = i;
    }
    if (cnt >= n) {
      printf("Matching\n");
      for (int i = 1; i <= n; i++) printf("%d ", p[i]);
      putchar('\n');
      continue;
    }
    cnt = 0;
    for (int i = 1; i <= 3 * n; i++)
      if (!vis[i]) p[++cnt] = i;
    if (cnt >= n) {
      printf("IndSet\n");
      for (int i = 1; i <= n; i++) printf("%d ", p[i]);
      putchar('\n');
      continue;
    }
    printf("Impossible\n");
  }
  return 0;
}
