#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 500050;
vector<int> bian, dian;
int vis[maxn * 3];
int main() {
  int t, n, m, tmp;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &tmp, &m);
    n = tmp * 3;
    for (int i = 1; i <= n; i++) vis[i] = 0;
    bian.clear();
    dian.clear();
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (!vis[x] && !vis[y]) {
        vis[x] = vis[y] = 1;
        bian.push_back(i);
      }
    }
    if (bian.size() >= tmp) {
      printf("Matching\n");
      for (int j = 0; j < tmp; j++) printf("%d ", bian[j]);
      printf("\n");
    } else {
      for (int i = 1; i <= n; i++) {
        if (!vis[i]) dian.push_back(i);
      }
      if (dian.size() >= tmp) {
        printf("IndSet\n");
        for (int j = 0; j < tmp; j++) printf("%d ", dian[j]);
        printf("\n");
      } else
        printf("Impossible\n");
    }
  }
  return 0;
}
