from sys import stdin
input = stdin.readline

T = int(input())

for _ in range(T):
    n, m = [int(i) for i in input().split()]
    
    ind_edg_v = [0]*(2*n)
    ind_edg_e = [0]*n
    num_edg = 0

    for i in range(m):
        v, w = [int(j) for j in input().split()]
        if v not in ind_edg_v and w not in ind_edg_v and num_edg < n:
            ind_edg_e[num_edg] = i+1
            ind_edg_v[2*num_edg], ind_edg_v[2*num_edg+1] = v, w
            
    if num_edg == n:
        print("Matching")
        print(' '.join(ind_edg_e))
    else:
        print("IndSet")
        for i in range(1, n+1):
            if i not in ind_edg_v:
                print(i, end = ' ')
        print()