#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t-- > 0) {
    long long n, m;
    cin >> n >> m;
    set<long long> se;
    for (long long i = 1; i <= (3 * n); i++) {
      se.insert(i);
    }
    vector<long long> v;
    for (long long i = 1; i <= m; i++) {
      long long x, y;
      cin >> x >> y;
      if (se.find(x) != se.end() && se.find(y) != se.end()) {
        se.erase(x);
        se.erase(y);
        v.push_back(i);
      }
    }
    if (v.size() >= n) {
      cout << "Matching"
           << "\n";
      for (long long i = 0; i < n; i++) cout << v[i] << " ";
      cout << "\n";
    } else {
      cout << "IndSet"
           << "\n";
      long long cnt = 0;
      for (auto x : se) {
        if (cnt == n) break;
        cout << x << " ";
        cnt += 1;
      }
      cout << "\n";
    }
  }
}
