#include <bits/stdc++.h>
using namespace std;
vector<int> _edge;
set<int> se, to_del;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int t, n, m, i, j, k, x, y, z, a, b, c;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    n *= 3;
    se.clear();
    _edge.clear();
    for (i = 1; i <= n; ++i) se.insert(i);
    for (i = 1; i <= m; ++i) {
      cin >> x >> y;
      if (se.find(x) != se.end() && se.find(y) != se.end()) {
        se.erase(x);
        se.erase(y);
        _edge.push_back(i);
      }
    }
    n = n / 3;
    if (_edge.size() >= n) {
      cout << "Matching" << endl;
      for (i = 0; i < _edge.size() && i < n; ++i) cout << _edge[i] << " ";
      cout << endl;
    } else if (se.size() >= n) {
      cout << "IndSet" << endl;
      i = 0;
      for (auto it : se) {
        cout << it << " ";
        i += 1;
        if (i == n) break;
      }
      cout << endl;
    } else
      cout << "Impossible" << endl;
  }
  return 0;
}
