import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedInputStream(System.in));
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pr = new PrintWriter(new BufferedOutputStream(System.out));
	static Scanner sc = new Scanner(System.in);

//		long tic = System.currentTimeMillis();
//		long toc = System.currentTimeMillis();
//		System.out.println("Elapsed time: " + (toc - tic) + " ms");
	public static void main(String[] args) {
		int T = nextInt();
		while (T-- > 0) {
			int n = nextInt();
			int m = nextInt();
			int ver[] = new int[3 * n + 5];
			ArrayList<Integer> ans = new ArrayList<>();
			for (int i = 1; i <= m; i++) {
				int x = nextInt();
				int y = nextInt();
				if (ver[x] == 0 && ver[y] == 0) {
					ver[x] = ver[y] = 1;
					ans.add(i);
				}
			}
			if (ans.size() >= n) {
				pr.println("Matching");
				for (int i = 0; i < n; i++) {
					pr.print(ans.get(i) + " ");
				}
				pr.println();
			} else {
				pr.println("IndSet");
				for (int i = 1, j = 0; i < 3 * n && j < n; i++)
					if (ver[i] == 0) {
						pr.print(i + " ");
						j++;
					}
				pr.println();
			}
		}
		pr.flush();

	}

	static int nextNum() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int) st.nval;
	}

	static int log2(long x) {
		int flag = 1;
		int log = 0;
		while (x > flag) {
			flag <<= 1;
			log++;
		}
		return log;
	}

	static long phi(int x) {
		long res = x;
		for (long i = 2; i <= Math.sqrt(x); i++) {
			if (x % i == 0) {
				while (x % i == 0)
					x /= i;
				res = res / i * (i - 1);
			}
		}
		if (x > 1)
			res = res / x * (x - 1);
		return res;
	}

	static long pow(long a, long b, long mod) {
		if (b == 0)
			return 1;
		if (b == 1)
			return a;
		if ((b & 1) == 0)
			return pow(a * a % mod, b >> 1, mod);
		else
			return a * pow(a * a % mod, b >> 1, mod) % mod;
	}

	static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		} else {
			return gcd(b, a % b);
		}
	}

	static int nextInt() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int) st.nval;
	}

	static double nextDouble() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return st.nval;
	}

	static String next() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return st.sval;
	}

	static long nextLong() {
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (long) st.nval;
	}
}

class Node {
	int a;
	int b;
	int c;

	public Node() {
	}

	public Node(int a, int b, int c) {
		super();
		this.a = a;
		this.b = b;
		this.c = c;
	}

	@Override
	public String toString() {
		return "Node [a=" + a + ", b=" + b + "]";
	}
}