#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const long long mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
long long n, m, vis[N];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= 3 * n; i++) vis[i] = 0;
  vector<long long> match;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (!vis[u] && !vis[v]) {
      vis[u] = 1;
      vis[v] = 1;
      match.push_back(i);
    }
  }
  if (match.size() >= n) {
    cout << "Matching"
         << "\n";
    for (int i = 0; i < n; i++) cout << match[i] << " ";
    cout << "\n";
    ;
  } else {
    cout << "IndSet"
         << "\n";
    for (int i = 1, j = 0; i <= 3 * n; i++) {
      if (vis[i]) continue;
      if (j == n) break;
      cout << i << " ";
      j++;
    }
    cout << "\n";
    ;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(15);
  ;
  int test = 1;
  cin >> test;
  for (int i = 1; i <= test; i++) {
    solve();
  }
}
