#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[300005];
bool visited[300005];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  long long n, m, a, b;
  vector<pair<long long, long long> > ed;
  vector<long long> edge, ans;
  while (t--) {
    long long count = 0;
    ed.clear();
    edge.clear();
    cin >> n >> m;
    for (long long i = 1; i <= n; i++) {
      visited[i] = false;
      adj[i].clear();
    }
    for (long long i = 0; i < m; i++) {
      cin >> a >> b;
      ed.push_back(make_pair(a, b));
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    for (long long i = 0; i < m; i++) {
      a = ed[i].first, b = ed[i].second;
      if (!visited[a] && !visited[b]) {
        visited[a] = true;
        visited[b] = true;
        edge.push_back(i + 1);
      }
    }
    long long si = edge.size();
    if (si >= n) {
      cout << "Matching" << endl;
      for (long long i = 0; i < n; i++) cout << edge[i] << " ";
      cout << endl;
      goto abc;
    }
    for (long long i = 1; i <= 3 * n; i++) {
      if (count >= n) break;
      if (!visited[i]) {
        ans.push_back(i);
        count++;
      }
    }
    cout << count << endl;
    if (count == n) {
      cout << "IndSet" << endl;
      for (long long i = 0; i < n; i++) cout << ans[i] << " ";
      cout << endl;
    } else
      cout << "Impossible" << endl;
  abc:;
  }
  return 0;
}
