#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long i, j, k, m, n;
    cin >> n >> m;
    long long vis[3 * n + 5];
    for (i = 1; i <= (3 * n); i++) vis[i] = 0;
    vector<long long> matching;
    for (int i = 0; i < m; ++i) {
      long long u, v;
      cin >> u >> v;
      if ((vis[u]) || (vis[v])) continue;
      vis[u] = 1;
      vis[v] = 1;
      matching.push_back(i + 1);
    }
    if (matching.size() >= n) {
      cout << "Matching\n";
      for (i = 0; i < n; i++) cout << matching[i] << " ";
      cout << "\n";
    } else {
      cout << "IndSet\n";
      k = 0;
      for (i = 1; i <= 3 * n; i++) {
        if (vis[i] == 0) {
          k++;
          cout << i << " ";
          if (k == n) {
            cout << "\n";
            break;
          }
        }
      }
    }
  }
}
