#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % (long long int)1e9 + 7;
    ;
    a = (a * a) % (long long int)1e9 + 7;
    ;
    b = b >> 1;
  }
  return res % (long long int)1e9 + 7;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    vector<long long int> ch(3 * n + 1, 0);
    vector<long long int> indSet;
    vector<long long int> matching;
    for (long long int i = 1; i <= m; i++) {
      long long int a, b;
      cin >> a >> b;
      if (ch[a] == 0 && ch[b] == 0) {
        matching.push_back(i);
        ch[a] = 1;
        ch[b] = 1;
      }
    }
    if (matching.size() >= n) {
      cout << "Matching\n";
      for (long long int i = 0; i < n; i++) {
        cout << matching[i] << " ";
      }
      cout << "\n";
    } else {
      cout << "IndSet\n";
      long long int count = 0;
      for (long long int i = 1; i <= 3 * n && count < n; i++) {
        if (ch[i] == 0) {
          cout << i << " ";
          count++;
        }
      }
      cout << "\n";
    }
  }
}
