#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
inline int addmod(int x, int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
inline int submod(int x, int y) {
  return (x % 1000000007 - y % 1000000007 + 1000000007) % 1000000007;
}
inline int mulmod(int x, int y) {
  return (x % 1000000007 * 1LL * y % 1000000007) % 1000000007;
}
inline int nextSubMask(int i, int mask) { return (i - 1) & mask; }
template <typename T>
void we_r_done(T mssg) {
  cout << mssg;
  exit(0);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    int n3 = n * 3;
    vector<bool> done(n3 + 1, false);
    vector<int> E;
    for (int i = 0; i < m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (done[x] || done[y]) continue;
      E.push_back(i + 1);
      done[x] = done[y] = true;
    }
    vector<int> V;
    for (int i = 1; i <= n3; i++) {
      if (done[i] == false) V.push_back(i);
    }
    if (V.size() >= n) {
      printf("IndSet\n");
      while (V.size() > n) V.pop_back();
      for (int i : V) printf("%d ", i);
    } else {
      printf("Matching\n");
      while (E.size() > n) E.pop_back();
      for (int i : E) printf("%d ", i);
    }
    printf("\n");
  }
  return 0;
}
