#include <bits/stdc++.h>
using namespace std::chrono;
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
long long max(A x, B y) {
  return x > y ? x : y;
}
template <typename A, typename B>
long long min(A x, B y) {
  return x < y ? x : y;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
struct dijkstra {
  int n;
  const long long inf = 4e18;
  vector<long long> dists;
  vector<vector<pair<long long, int>>> edges;
  void init(int second) {
    n = second;
    dists = vector<long long>(n);
    edges = vector<vector<pair<long long, int>>>(n);
  }
  void edge(int a, int b, long long wt) {
    edges[a].push_back(make_pair(wt, b));
    edges[b].push_back(make_pair(wt, a));
  }
  using ptype = pair<long long, int>;
  void run(int src) {
    fill(dists.begin(), dists.end(), inf);
    priority_queue<ptype, vector<ptype>, greater<ptype>> pq;
    dists[src] = 0;
    pq.push(make_pair(0, src));
    while (!pq.empty()) {
      ptype foc = pq.top();
      pq.pop();
      dists[foc.second] = min(dists[foc.second], foc.first);
      for (ptype x : edges[foc.second]) {
        long long d = dists[foc.second] + x.first;
        if (d < dists[x.second]) {
          dists[x.second] = d;
          pq.push(make_pair(d, x.second));
        }
      }
    }
  }
};
long long i, j;
const long long mod = 1e9 + 7;
long long n, q, Q, T, m, k, r, x, y, z, g;
string s1, s2;
vector<int> edges[300001];
bool mark[300001];
vector<int> mat, ind;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    mat.clear();
    ind.clear();
    cin >> n >> m;
    for (int i = 0; i < 3 * n; i++) mark[i] = 0;
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      edges[a].push_back(b);
      edges[b].push_back(a);
      if (!mark[a] && !mark[b]) {
        mat.push_back(i + 1);
        mark[a] = mark[b] = 1;
      }
    }
    if (mat.size() >= n) {
      cout << "Matching" << endl;
      for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << mat[i];
      }
      cout << endl;
    } else {
      cout << "IndSet" << endl;
      int cnt = 0, i = 0;
      while (i < 3 * n && cnt < n) {
        if (!mark[i]) {
          if (cnt) cout << " ";
          cout << i + 1;
          ++cnt;
        }
        ++i;
      }
      cout << endl;
    }
  }
}
