#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3 * 1e5 + 10;
const long long INF = 1e9 + 10;
const int MOD = 998244353;
int t, n, m;
void solve() {
  cin >> n >> m;
  n *= 3;
  vector<bool> was(n, 0);
  vector<int> match;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (was[x] == 0 && was[y] == 0) {
      was[x] = 1;
      was[y] = 1;
      match.push_back(i);
    }
  }
  if (match.size() >= n / 3) {
    cout << "Matching\n";
    for (int i = 0; i < n / 3; i++) cout << match[i] + 1 << ' ';
  } else {
    cout << "IndSet\n";
    for (int i = 0, cnt = 0; i < n; i++) {
      if (was[i] == 0 && cnt < n / 3) {
        cnt++;
        cout << i + 1 << ' ';
      }
    }
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
