#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
void inlld(long long &a) { scanf("%lld", &a); }
void ind(int &a) { scanf("%d", &a); }
int n, m, taken[N];
pair<int, int> edges[N];
vector<int> matching;
void main2() {
  matching.clear();
  ind(n);
  ind(m);
  for (int a = 1; a <= m; a++) {
    ind(edges[a].first);
    ind(edges[a].second);
    if (taken[edges[a].first] == 0 && taken[edges[a].second] == 0) {
      taken[edges[a].first] = 1;
      taken[edges[a].second] = 1;
      matching.push_back(a);
    }
  }
  if ((int)matching.size() >= n) {
    printf("Matching\n");
    for (int a = 0; a < n; a++) printf("%d ", matching[a]);
    printf("\n");
    return;
  }
  int gottem = 0;
  for (int a = 1; a <= 3 * n; a++) gottem += (1 - taken[a]);
  if (gottem < n) {
    printf("Impossible\n");
    return;
  }
  printf("IndSet\n");
  int cnt = 0;
  for (int a = 1; a <= 3 * n && cnt < n; a++)
    if (!taken[a]) {
      printf("%d ", a);
      cnt++;
    }
  printf("\n");
}
int main() {
  int t;
  ind(t);
  while (t--) main2();
  return 0;
}
