#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
const long long inf = 1e18;
const long long mod = 1e9 + 7;
double pi = acos(-1.0);
bool label[310000] = {false};
vector<int> M, I;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    M.clear();
    I.clear();
    for (int i = 1; i <= 3 * n; i++) label[i] = false;
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      if ((!label[u]) && (!label[v]) && M.size() < n) {
        label[u] = label[v] = true;
        M.push_back(i);
      }
    }
    for (int i = 1; i <= 3 * n; i++)
      if ((!label[i]) && I.size() < n) I.push_back(i);
    if (M.size() == n) {
      cout << "Matching" << endl;
      for (int i = 0; i < M.size(); i++) cout << M[i] << " ";
      cout << endl;
      continue;
    }
    if (I.size() == n) {
      cout << "IndSet" << endl;
      for (int i = 0; i < I.size(); i++) cout << I[i] << " ";
      cout << endl;
      continue;
    }
    cout << "Impossible" << endl;
  }
}
