// practice with rainboy
import java.io.*;
import java.util.*;

public class CF1199E extends PrintWriter {
	CF1199E() { super(System.out); }
	static class Scanner {
		Scanner(InputStream in) { this.in = in; } InputStream in;
		int k, l; byte[] bb = new byte[1 << 15];
		byte getc() {
			if (k >= l) {
				k = 0;
				try { l = in.read(bb); } catch (IOException e) { l = 0; }
				if (l <= 0) return -1;
			}
			return bb[k++];
		}
		int nextInt() {
			byte c = 0; while (c <= 32) c = getc();
			int a = 0;
			while (c > 32) { a = a * 10 + c - '0'; c = getc(); }
			return a;
		}
	}
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1199E o = new CF1199E(); o.main(); o.flush();
	}

	void main() {
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			boolean[] used = new boolean[n * 3];
			int[] ee = new int[n];
			int k = 0;
			for (int h = 0; h < m; h++) {
				int i = sc.nextInt() - 1;
				int j = sc.nextInt() - 1;
				if (used[i] || used[j])
					continue;
				used[i] = used[j] = true;
				if (k < n)
					ee[k++] = h;
			}
			if (k == n) {
				println("Matching");
				for (int h = 0; h < k; h++)
					print(ee[h] + 1 + " ");
				println();
			} else {
				println("IndSet");
				k = 0;
				for (int i = 0; i < n * 3 && k < n; i++)
					if (!used[i]) {
						print(i + 1 + " ");
						k++;
					}
				println();
			}
		}
	}
}
