#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
const int maxn = 1000005;
struct node {
  int u, v, wei, id;
  node() {}
  node(int a, int b, int c, int d) {
    u = a;
    v = b;
    wei = c;
    id = d;
  }
} edge[maxn];
int book[maxn], b[maxn], a[maxn];
vector<int> g[maxn], ans1, ans2;
bool cmp1(int x, int y) { return g[x].size() < g[y].size(); }
bool cmp2(node x, node y) { return x.wei < y.wei; }
int matching(int n, int m) {
  ans2.clear();
  for (int i = 1; i <= 3 * n; i++) book[i] = 0;
  for (int i = 1; i <= m; i++) {
    int u = edge[i].u;
    int v = edge[i].v;
    int id = edge[i].id;
    if (ans2.size() < n && !book[u] && !book[v]) {
      ans2.push_back(id);
      book[u]++;
      book[v]++;
    }
  }
  if (ans2.size() == n) {
    printf("Matching\n");
    for (int i = 0; i < n; i++) printf("%d ", ans2[i]);
    printf("\n");
    return 1;
  } else {
    printf("IndSet\n");
    int count = 0;
    for (int i = 1; i <= 3 * n; i++) {
      if (count < n && !book[i]) {
        printf("%d ", i);
        count++;
      }
    }
    printf("\n");
    return 1;
  }
  return 0;
}
int ma(int x, int y) {
  if (x < y) swap(x, y);
  return x;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= 3 * n; i++) g[i].clear();
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
      edge[i] = node(u, v, 0, i);
    }
    for (int i = 1; i <= m; i++)
      edge[i].wei = max(g[edge[i].u].size(), g[edge[i].v].size());
    if (matching(n, m)) continue;
    printf("Impossible\n");
  }
  return 0;
}
