#include <bits/stdc++.h>
using namespace std;
int t;
int n, m;
vector<int> match;
vector<int> ind_set;
int vis[100000 * 3 + 5];
void ini() {
  match.clear();
  ind_set.clear();
  memset(vis, 0, sizeof(vis));
}
int main() {
  int u, v;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &m);
    ini();
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      if (!vis[u] && !vis[v]) {
        match.push_back(i);
        vis[u] = 1;
        vis[v] = 1;
      }
    }
    for (int i = 1; i <= n * 3; i++)
      if (!vis[i]) ind_set.push_back(i);
    if (match.size() >= n) {
      printf("Matching\n");
      for (int i = 0; i < n; i++) printf("%d ", match[i]);
      printf("\n");
    } else if (ind_set.size() >= n) {
      printf("Indset\n");
      for (int i = 0; i < n; i++) printf("%d ", ind_set[i]);
      printf("\n");
    } else {
      printf("Impossible\n");
    }
  }
}
