#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct pi {
  int v, id;
};
vector<pi> ve[N];
vector<int> ans;
vector<int> e;
int ind[N];
bool vis[N];
bool chos[N];
bool choe[N];
struct node {
  int v, indeg;
};
node pt[N];
queue<int> qe;
bool cmp(const node &a, const node &b) { return a.indeg < b.indeg; }
void sol(int n) {
  for (int j = 1; j <= 3 * n; j++) {
    int i = pt[j].v;
    if (chos[i]) continue;
    chos[i] = true;
    for (auto p : ve[i]) chos[p.v] = true;
    ans.push_back(i);
  }
}
void pre(int n) {
  for (int j = 1; j <= 3 * n; j++) {
    int i = pt[j].v;
    if (choe[i]) continue;
    int nowp = -1;
    int indx;
    for (auto p : ve[i]) {
      if (choe[p.v]) continue;
      if (nowp == -1) nowp = p.v, indx = p.id;
      if (ind[nowp] >= ind[p.v]) nowp = p.v, indx = p.id;
    }
    choe[i] = true;
    choe[nowp] = true;
    e.push_back(indx);
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d %d", &n, &m);
    ans.clear();
    e.clear();
    for (int i = 1; i <= n * 3; i++) {
      ve[i].clear();
      ind[i] = 0;
      vis[i] = 0;
      chos[i] = 0;
      choe[i] = 0;
    }
    int u, v;
    int pos = -1;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      ve[u].push_back({v, i});
      ve[v].push_back({u, i});
      ind[u]++, ind[v]++;
    }
    for (int i = 1; i <= 3 * n; i++) {
      pt[i] = {i, ind[i]};
    }
    sort(pt + 1, pt + 1 + n, cmp);
    sol(n);
    pre(n);
    if (ans.size() >= n) {
      puts("IndSet");
      for (int i = 0; i < n; i++) {
        printf("%d ", ans[i]);
      }
      puts("");
    } else if (e.size() >= n) {
      puts("Matching");
      for (int i = 0; i < n; i++) {
        printf("%d ", e[i]);
      }
      puts("");
    } else {
      puts("Impossible");
    }
  }
}
