#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
      cin >> a[i].first >> a[i].second;
    }
    vector<bool> used(3 * n);
    vector<int> p, ind;
    for (int i = 0; i < m; i++) {
      int v1 = a[i].first - 1, v2 = a[i].second - 1;
      if (!used[v1] && !used[v2]) {
        p.push_back(i);
        used[v1] = 1;
        used[v2] = 1;
        continue;
      }
    }
    for (int i = 0; i < 3 * n; i++) {
      if (!used[i]) {
        ind.push_back(i);
      }
    }
    if (p.size() >= n) {
      cout << "Matching\n";
      for (int i = 0; i < n; i++) {
        cout << p[i] + 1 << " ";
      }
    } else if (ind.size() >= n) {
      cout << "IndSet\n";
      for (int i = 0; i < n; i++) {
        cout << ind[i] + 1 << " ";
      }
    } else {
      cout << "Impossible";
    }
    cout << "\n";
  }
  return 0;
}
