#include <bits/stdc++.h>
using namespace std;
const int INF32 = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int mod2 = 1e9 + 7;
const int mod = 2520;
const int N = 5e5 + 5;
bool vis[N];
vector<int> mat, ind;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    mat.clear();
    ind.clear();
    memset(vis, false, sizeof(bool) * 4 * n);
    int u, v;
    for (int i = 1; i <= m; ++i) {
      cin >> u >> v;
      if (!vis[u] && !vis[v] && mat.size() < n) {
        vis[u] = vis[v] = true;
        mat.emplace_back(i);
      }
    }
    if (mat.size() == n) {
      cout << "Matching" << '\n';
      for (int i : mat) cout << i << ' ';
      cout << '\n';
      continue;
    }
    for (int i = 1; i <= 3 * n; ++i) {
      if (!vis[i]) {
        ind.emplace_back(i);
        if (ind.size() == n) break;
      }
    }
    if (ind.size() == n) {
      cout << "IndSet" << '\n';
      for (int i : ind) cout << i << ' ';
      cout << '\n';
      continue;
    }
    cout << "Impossible" << '\n';
  }
  return 0;
}
