#include <bits/stdc++.h>
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i, s, t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i, t, s) for(int i = (int)(t); i >= (int)(s); i--)
#define lson rt << 1
#define rson rt << 1 | 1
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double lb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> VI;
typedef std::vector<ll> VL;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> rbtree;
ll gcd(ll x, ll y){ return y % x == 0 ? x : gcd(y % x, x); }
template<class T>T my_abs(T a){ if(a < 0) a = -a; return a; }
inline ll read(){
    ll ret = 0, sign = 1;
    char c = getchar();
    while(c < '0' || c > '9'){ if(c == '-') sign = -1; c = getchar();}
    while(c >= '0' && c <= '9'){ ret = ret * 10 + c - '0'; c = getchar(); }
    return ret * sign;
}
inline void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

//void expand_stack_space(){
//    int size = 256 << 20; // 256MB
//    char *p = (char*)malloc(size) + size;
//    __asm__("movl %0, %%esp\n" :: "r"(p));
//}
const int maxn = 1e5 + 7;
int vis[maxn], n, m;
int main(){
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int T;
    scanf("%d", &T);
    while(T--){
        scanf("%d%d", &n, &m);
        for(int i = 1; i <= 3 * n; i++) vis[i] = 0;
        vector<int> res;
        for(int i = 1; i <= m; i++){
            int u, v;
            scanf("%d%d", &u, &v);
            if(!vis[u] && !vis[v]){
                vis[u] = vis[v] = 1;
                res.push_back(i);
            }
        }
        if(sz(res) >= n){
            puts("Matching");
            for(int i = 0; i < n; i++) printf("%d%c", res[i], i == n - 1 ? '\n' : ' ');
            continue;
        }
        res.clear();
        for(int i = 1; i <= 3 * n; i++) if(!vis[i]) res.push_back(i);
        puts("Indset");
        for(int i = 1; i <= n; i++) printf("%d%c", res[i - 1], i == n ? '\n' : ' ');
    }
    return 0;
}
