#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long int MOD = 998244353;
int color[300005];
vector<pair<int, int> > adj[300005];
vector<int> I, M;
void solve(int ks) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= 3 * n; i++) {
    color[i] = 0;
    adj[i].clear();
  }
  I.clear();
  M.clear();
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }
  for (int i = 1; i <= 3 * n; i++) {
    for (auto& p : adj[i]) {
      if (p.first >= i) continue;
      if (color[p.first] == 0) {
        color[p.first] = 1;
        color[i] = 1;
        M.push_back(p.second);
        break;
      }
    }
  }
  if ((int)M.size() >= n) {
    printf("Matching\n");
    for (int i = 0; i < n; i++) {
      if (i) printf(" ");
      printf("%d", M[i]);
    }
    printf("\n");
  } else {
    printf("IndSet\n");
    for (int i = 1; i <= 3 * n; i++) {
      if (color[i] == 0) {
        I.push_back(i);
      }
    }
    for (int i = 0; i < n; i++) {
      if (i) printf(" ");
      printf("%d", I[i]);
    }
    printf("\n");
  }
}
int main() {
  if (1) {
    int T;
    scanf("%d", &T);
    for (int ks = 1; ks <= T; ks++) {
      solve(ks);
      fprintf(stderr, "%d done\n", ks);
    }
  } else {
    solve(0);
  }
  return 0;
}
