import math
import pdb

T = int(input())
ver = []

#pdb.set_trace()
for _ in range(T):
	
	ver.clear()
	n, m = map(int, input().strip().split())
	n *= 3
	edge = []

	for __ in range(m):
	
		u, v = map(int, input().strip().split())
	
		if u not in ver and v not in ver:
			edge.append(__+1)
			ver.append(u)
			ver.append(v)
		
		if len(edge) == n//3:
			print("Matching")
			
			for x in edge: print(x, end = " ")
			
			for x in range(__ + 1,m):
				u, v = map(int, input().strip().split())

			break

	if len(edge) < n//3:
		asd = []
		for x in range(1,n+1):
			if x not in ver: asd.append(x+1)
			if len(asd) == n//3:
				print("IndSet")
				for x in asd: 
					print(x, end = " ")
					break

		if len(asd) < n//3: print("Impossible")
