#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int x;
  cin >> x;
  return x;
}
long long int nxtl() {
  long long int x;
  cin >> x;
  return x;
}
void SieveOfEratosthenes(int n, vector<int> &primes) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int power(long long int x, long long int y, long long int mod) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod);
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
long long int f[200001];
long long int pow(long long int a, long long int b, long long int MOD) {
  long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
long long int InverseEuler(long long int n, long long int MOD) {
  return pow(n, MOD - 2, MOD);
}
long long int C(long long int n, long long int r, long long int MOD) {
  return (f[n] *
          ((InverseEuler(f[r], MOD) * InverseEuler(f[n - r], MOD)) % MOD)) %
         MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t = nxt();
  while (t--) {
    int n = nxt(), m = nxt();
    n *= 3;
    int n2 = n / 3;
    set<int> s;
    vector<int> edge;
    for (int i = 1; i <= m; i++) {
      int u = nxt(), v = nxt();
      if (s.count(u) == 0 && s.count(v) == 0) {
        edge.push_back(i);
        s.insert(u);
        s.insert(v);
      }
    }
    if (edge.size() >= n2) {
      cout << "Matching\n";
      for (int i = 0; i < n2; i++) cout << edge[i] << " ";
      cout << endl;
    } else if (s.size() <= 2 * n2) {
      cout << "IndSet\n";
      int c = 0;
      for (int i = 1; i <= n && c < n2; i++) {
        if (s.count(i) == 0) {
          c++;
          cout << i << " ";
        }
      }
      cout << endl;
    } else
      cout << "Impossible\n";
  }
  return 0;
}
