#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const long long N = 500000 + 5, K = 105;
const int si = (1 << 20);
int T;
int used[N];
int n, m;
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n * 3; ++i) used[i] = 0;
  vector<int> v;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    if (!used[x] && !used[y]) {
      used[x] = 1, used[y] = 1;
      v.push_back(i);
    }
  }
  if ((int)v.size() >= n) {
    cout << "Matching"
         << "\n";
    for (int i = 0; i < n; ++i) cout << v[i] << " ";
    cout << "\n";
  } else {
    vector<int> v2;
    cout << "IndSet"
         << "\n";
    for (int i = 1; i <= n * 3; ++i) {
      if (!used[i]) {
        v2.push_back(i);
        if ((int)v2.size() == n) break;
      }
    }
    if ((int)v2.size() == n)
      for (int i = 0; i < n; ++i) cout << v2[i] << " ";
    else
      cout << "Impossible";
    cout << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  cin >> T;
  while (T--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
