#include <bits/stdc++.h>
using namespace std;
ifstream f("joc5.in");
ofstream g("joc5.out");
struct query {
  int type, p, x;
};
int v[400005];
int freq[400005], sp[400005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<bool> used(3 * n + 5, 0);
    vector<int> edges;
    for (int i = 1; i <= m; i++) {
      int x, y;
      cin >> x >> y;
      if (used[x] == 0 && used[y] == 0) {
        edges.push_back(i);
        used[x] = 1;
        used[y] = 1;
      }
    }
    if (edges.size() < n) {
      cout << "IndSet" << '\n';
      int cnt = 0;
      for (int i = 1; i <= 3 * n; i++) {
        if (used[i] == 0) {
          cout << i << " ";
          cnt++;
        }
        if (cnt == n) break;
      }
      cout << '\n';
    } else {
      cout << "Matching" << '\n';
      for (int i = 0; i < n; i++) {
        cout << edges[i] << " ";
      }
      cout << '\n';
    }
  }
}
