#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const long long inf = 1e9 + 7;
long long n, m;
bool vis[maxn];
int from[maxn], to[maxn];
vector<int> ans1, ans2;
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%I64d%I64d", &n, &m);
    for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
    ans1.clear();
    ans2.clear();
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &from[i], &to[i]);
    }
    for (int i = 1; i <= m; i++) {
      if (!vis[from[i]] && !vis[to[i]]) {
        ans1.push_back(i);
        vis[from[i]] = vis[to[i]] = 1;
      }
    }
    if (ans1.size() >= n) {
      puts("Matching");
      for (int i = 1; i <= n; i++) {
        printf("%d", ans1[i - 1]);
        if (i != n)
          printf(" ");
        else
          puts("");
      }
      continue;
    }
    for (int i = 1; i <= 3 * n; i++) {
      if (!vis[i]) ans2.push_back(i);
    }
    if (ans2.size() >= n) {
      puts("IndSet");
      for (int i = 1; i <= n; i++) {
        printf("%d", ans2[i - 1]);
        if (i == n)
          puts("");
        else
          printf(" ");
      }
      continue;
    }
    puts("Impossible");
  }
  return 0;
}
