import java.util.*;
import java.io.*;
public class EdF {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int t = Integer.parseInt(bf.readLine());
 		for(int i = 0;i<t;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int n = Integer.parseInt(st.nextToken());
	 		int m = Integer.parseInt(st.nextToken());
	 		Set<Integer> vertices = new HashSet<Integer>();
	 		Set<Integer> edges = new HashSet<Integer>();
	 		for(int j = 1;j<=3*n;j++){
	 			vertices.add(j);
	 		}
	 		for(int j =0;j<m;j++){
	 			StringTokenizer st1 = new StringTokenizer(bf.readLine());
	 			int v1 = Integer.parseInt(st1.nextToken());
	 			int v2 = Integer.parseInt(st1.nextToken());
	 			if (vertices.contains(v1) && vertices.contains(v2)){
	 				edges.add(j+1);
	 				vertices.remove(v1);
	 				vertices.remove(v2);
	 			}
	 		}
	 		if (edges.size() >=n){
	 			out.println("Matching");
	 			int count = 0;
	 			for(int j : edges){
	 				count++;
	 				out.print(j + " ");
	 				if (count == n)
	 					break;
	 			}
	 			out.println();
	 		}
	 		else{
	 			out.println("IndSet");
	 			int count = 0;
	 			for(int j : vertices){
	 				count++;
	 				out.print(j + " ");
	 				if (count == n)
	 					break;
	 			}
	 			out.println();
	 		}
 		}

 		out.println();

 		out.close();

 	}
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[n*3];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }

            if (numEdges == n) {
                System.out.println("Matching");
                for (int i : edges) System.out.print(i + " ");
                System.out.println();
            }
            else {
                System.out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; i++) {
                    if (!matched[i]) {
                        togo--;
                        System.out.print((i+1) + " ");
                    }
                }
                System.out.println();
            }

        }
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[3 * n];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; ++i) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }
            if (numEdges == n) {
                out.println("Matching");
                for (int x : edges) out.print(x + " ");
                out.println();
            } else {
                out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; ++i)
                    if (!matched[i]) {
                        --togo;
                        out.print(i + 1 + " ");
                    }
                out.println();
            }
        }
        out.close();
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[3 * n];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; ++i) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }
            if (numEdges == n) {
                out.println("Matching");
                for (int x : edges) out.print(x + " ");
                out.println();
            } else {
                out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; ++i)
                    if (!matched[i]) {
                        --togo;
                        out.print(i + 1 + " ");
                    }
                out.println();
            }
        }
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


package codeforces.div2.con_576;

import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[3 * n];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; ++i) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }
            if (numEdges == n) {
                System.out.println("Matching");
                for (int x : edges) System.out.print(x + " ");
                System.out.println();
            } else {
                System.out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; ++i)
                    if (!matched[i]) {
                        --togo;
                        System.out.print(i + 1 + " ");
                    }
                System.out.println();
            }
        }
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[3 * n];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; ++i) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }
            if (numEdges == n) {
                System.out.println("Matching");
                for (int x : edges) System.out.print(x + " ");
                System.out.println();
            } else {
                System.out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; ++i)
                    if (!matched[i]) {
                        --togo;
                        System.out.print(i + 1 + " ");
                    }
                System.out.println();
            }
        }
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


package codeforces.div2.con_576;

import java.io.*;
import java.lang.*;
import java.util.*;

public class MatchingVsIndependentSet {
    public static void main(String[] args) {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] matched = new boolean[3 * n];
            int[] edges = new int[n];
            int numEdges = 0;
            for (int i = 0; i < m; ++i) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                if (numEdges < n) {
                    if (!matched[u] && !matched[v]) {
                        matched[u] = true;
                        matched[v] = true;
                        edges[numEdges++] = i + 1;
                    }
                }
            }
            if (numEdges == n) {
                out.println("Matching");
                for (int x : edges) out.print(x + " ");
                out.println();
            } else {
                out.println("IndSet");
                int togo = n;
                for (int i = 0; i < matched.length && togo > 0; ++i)
                    if (!matched[i]) {
                        --togo;
                        out.print(i + 1 + " ");
                    }
                out.println();
            }
        }
    }

    private static int min(int a, int b) {
        return a < b ? a : b;
    }

    private static int max(int a, int b) {
        return a > b ? a : b;
    }

    private static int min(ArrayList<Integer> list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(ArrayList<Integer> list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    private static int min(int[] list) {
        int min = Integer.MAX_VALUE;
        for (int el : list) {
            if (el < min) {
                min = el;
            }
        }
        return min;
    }

    private static int max(int[] list) {
        int max = Integer.MIN_VALUE;
        for (int el : list) {
            if (el > max) {
                max = el;
            }
        }
        return max;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EMatchingVsIndependentSet solver = new EMatchingVsIndependentSet();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMatchingVsIndependentSet {
        ArrayList<pair>[] arrayList;
        boolean[] visited;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int t = in.scanInt();
            while (t-- > 0) {
                int n = in.scanInt();
                int m = in.scanInt();
                arrayList = new ArrayList[3 * n + 1];
                visited = new boolean[3 * n + 1];
                for (int i = 0; i <= 3 * n; i++) arrayList[i] = new ArrayList<>();
                for (int i = 0; i < m; i++) {
                    int u = in.scanInt();
                    int v = in.scanInt();
                    arrayList[u].add(new pair(v, i));
                    arrayList[v].add(new pair(u, i));
                }
                ArrayList<Integer> mat = new ArrayList<>();
                for (int i = 1; i <= 3 * n; i++) {
                    if (visited[i]) continue;
                    for (pair yy : arrayList[i]) {
                        int y = yy.v;
                        if (visited[y]) continue;
                        mat.add(yy.index);
                        visited[i] = visited[y] = true;
                        break;
                    }
                }

                if (mat.size() >= n) {
                    out.println("Matching");
                    for (int i = 0, j = 0; i < mat.size() && j < n; i++, j++) out.print((mat.get(i) + 1) + " ");
                    out.println();
                } else {
                    out.println("IndSet");
                    for (int i = 1, j = 0; i <= 3 * n && j < n; i++, j++) if (visited[i]) out.print(i + " ");
                    out.println();
                }

            }
        }

        class pair {
            int v;
            int index;

            public pair(int v, int index) {
                this.v = v;
                this.index = index;
            }

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EMatchingVsIndependentSet solver = new EMatchingVsIndependentSet();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMatchingVsIndependentSet {
        ArrayList<pair>[] arrayList;
        boolean[] visited;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int t = in.scanInt();
            while (t-- > 0) {
                int n = in.scanInt();
                int m = in.scanInt();
                arrayList = new ArrayList[3 * n + 1];
                visited = new boolean[3 * n + 1];
                for (int i = 0; i <= 3 * n; i++) arrayList[i] = new ArrayList<>();
                for (int i = 0; i < m; i++) {
                    int u = in.scanInt();
                    int v = in.scanInt();
                    arrayList[u].add(new pair(v, i));
                    arrayList[v].add(new pair(u, i));
                }
                ArrayList<Integer> mat = new ArrayList<>();
                for (int i = 1; i <= 3 * n; i++) {
                    if (visited[i]) continue;
                    for (pair yy : arrayList[i]) {
                        int y = yy.v;
                        if (visited[y]) continue;
                        mat.add(yy.index);
                        visited[i] = visited[y] = true;
                        break;
                    }
                }

                if (mat.size() >= n) {
                    out.println("Matching");
                    for (int i = 0, j = 0; i < mat.size() && j < n; i++, j++) out.print((mat.get(i) + 1) + " ");
                    out.println();
                } else {
                    out.println("IndSet");
                    for (int i = 1, j = 0; i <= 3 * n && j < n; i++)
                        if (!visited[i]) {
                            out.print(i + " ");
                            j++;
                        }
                    out.println();
                }

            }
        }

        class pair {
            int v;
            int index;

            public pair(int v, int index) {
                this.v = v;
                this.index = index;
            }

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EMatchingVsIndependentSet solver = new EMatchingVsIndependentSet();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMatchingVsIndependentSet {
        ArrayList<pair>[] arrayList;
        boolean[] visited;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int t = in.scanInt();
            loop:
            while (t-- > 0) {
                int n = in.scanInt();
                int m = in.scanInt();
                arrayList = new ArrayList[3 * n + 1];
                visited = new boolean[3 * n + 1];
                for (int i = 0; i <= 3 * n; i++) arrayList[i] = new ArrayList<>();
                for (int i = 0; i < m; i++) {
                    int u = in.scanInt();
                    int v = in.scanInt();
                    arrayList[u].add(new pair(v, i));
                    arrayList[v].add(new pair(u, i));
                }

                ArrayList<Integer> mat = new ArrayList<>();

                for (int i = 1; i <= 3 * n; i++) {
                    if (visited[i]) continue;
                    for (pair yy : arrayList[i]) {
                        int y = yy.v;
                        if (visited[y]) continue;
                        mat.add(yy.index);
                        visited[i] = visited[y] = true;
                    }
                }

                if (mat.size() >= n) {
                    out.println("Matching");
                    for (int i = 0, j = 0; i < mat.size() && j < n; i++, j++) out.print((mat.get(i) + 1) + " ");
                    out.println();
                } else {
                    out.println("IndSet");
                    for (int i = 1, j = 0; i <= 3 * n && j < n; i++, j++) if (visited[i]) out.print(i + " ");
                    out.println();
                }

            }
        }

        class pair {
            int v;
            int index;

            public pair(int v, int index) {
                this.v = v;
                this.index = index;
            }

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.*;
import java.util.*;

public class E implements Runnable {
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}

	int[] deg;
	ArrayList<Edge>[] adj;
	Edge[] list;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int T = fs.nextInt();
		while(T-->0) {
			int n = fs.nextInt()*3;
			int m = fs.nextInt();
			int g = n/3;
			deg = new int[n];
			list = new Edge[m];
			adj = new ArrayList[n];
			for(int i = 0; i < n; i++) adj[i] = new ArrayList<>();

			for(int i = 0; i < m; i++) {
				int u = fs.nextInt()-1, v = fs.nextInt()-1;
				adj[u].add(new Edge(u, v, i));
				adj[v].add(new Edge(v, u, i));
				list[i] = new Edge(u, v, i);
				deg[u]++; deg[v]++;
			}
			Integer[] a = new Integer[n];
			for(int i = 0; i < n; i++) a[i] = i;
			Arrays.sort(a, (x, y) -> Integer.compare(deg[x], deg[y]));
			int[] set = new int[g];
			int ptr = 0;

			boolean[] done = new boolean[n];
			for(int i = 0; i < n && ptr < g; i++) {
				int u = a[i];
				if(done[u]) continue;
				done[u] = true;
				set[ptr++] = u+1;
				for(Edge e : adj[u]) done[e.v] = true;
			}
			if(ptr == g) {
				out.println("IndSet");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(set[i]);
				}
				out.println();
				continue;
			}

			Arrays.sort(list);
			done = new boolean[n];
			int[] match = new int[g];
			ptr = 0;
			for(int i = 0; i < m && ptr < g; i++) {
				Edge now = list[i];
				if(done[now.u] || done[now.v]) continue;
				done[now.u] = done[now.v] = true;
				match[ptr++] = list[i].id+1;
			}

			if(ptr == g) {
				out.println("Matching");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(match[i]);
				}
				out.println();
				continue;
			}

			out.println("Impossible");

		}

		out.close();
	}

	class Edge implements Comparable<Edge> {
		int id, u, v;
		Edge(int a, int b, int i) {
			u = a; v = b;
			id = i;
		}
		public int compareTo(Edge e) {
			return Integer.compare(deg[u]+deg[v], deg[e.u]+deg[e.v]);
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class E implements Runnable {
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}

	int[] deg;
	ArrayList<Edge>[] adj;
	Edge[] list;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int T = fs.nextInt();
		while(T-->0) {
			int n = fs.nextInt()*3;
			int m = fs.nextInt();
			int g = n/3;
			deg = new int[n];
			list = new Edge[m];
			adj = new ArrayList[n];
			for(int i = 0; i < n; i++) adj[i] = new ArrayList<>();

			for(int i = 0; i < m; i++) {
				int u = fs.nextInt()-1, v = fs.nextInt()-1;
				adj[u].add(new Edge(u, v, i));
				adj[v].add(new Edge(v, u, i));
				list[i] = new Edge(u, v, i);
				deg[u]++; deg[v]++;
			}

			TreeSet<Node> nodes = new TreeSet<>();
			for(int i = 0; i < n; i++) nodes.add(new Node(i, deg[i]));

//			Integer[] a = new Integer[n];
//			for(int i = 0; i < n; i++) a[i] = i;
//			Arrays.sort(a, (x, y) -> Integer.compare(deg[x], deg[y]));
			int[] set = new int[g];
			int ptr = 0;

			boolean[] done = new boolean[n];
			for(int i = 0; i < n && ptr < g; i++) {
				Node now = nodes.pollFirst();
				int u = now.id;
				if(done[u]) continue;
				done[u] = true;
				set[ptr++] = u+1;
				for(Edge e : adj[u]) {
					if(!done[e.v]) {
						done[e.v] = true;
						for(Edge ee : adj[e.v]) {
							if(done[ee.v]) continue;
							nodes.remove(new Node(ee.v, deg[ee.v]));
							deg[ee.v]--;
							nodes.add(new Node(ee.v, deg[ee.v]));
						}
					}
				}
			}
			if(ptr == g) {
				out.println("IndSet");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(set[i]);
				}
				out.println();
				continue;
			}

			Arrays.sort(list);
			done = new boolean[n];
			int[] match = new int[g];
			ptr = 0;
			for(int i = 0; i < m && ptr < g; i++) {
				Edge now = list[i];
				if(done[now.u] || done[now.v]) continue;
				done[now.u] = done[now.v] = true;
				match[ptr++] = list[i].id+1;
			}

			if(ptr == g) {
				out.println("Matching");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(match[i]);
				}
				out.println();
				continue;
			}

			out.println("Impossible");

		}

		out.close();
	}

	class Node implements Comparable<Node> {
		int id, deg;
		Node(int a, int b) {
			id = a; deg = b;
		}
		public int compareTo(Node n) {
			int c = Integer.compare(deg, n.deg);
			if(c == 0) c = Integer.compare(id, n.id);
			return c;
		}
	}

	class Edge implements Comparable<Edge> {
		int id, u, v;
		Edge(int a, int b, int i) {
			u = a; v = b;
			id = i;
		}
		public int compareTo(Edge e) {
			return Integer.compare(deg[u]+deg[v], deg[e.u]+deg[e.v]);
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.io.*;
import java.util.*;

public class E implements Runnable {
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}

	int[] deg;
	ArrayList<Edge>[] adj;
	Edge[] list;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int T = fs.nextInt();
		while(T-->0) {
			int n = fs.nextInt()*3;
			int m = fs.nextInt();
			int g = n/3;
			deg = new int[n];
			list = new Edge[m];
			adj = new ArrayList[n];
			for(int i = 0; i < n; i++) adj[i] = new ArrayList<>();

			for(int i = 0; i < m; i++) {
				int u = fs.nextInt()-1, v = fs.nextInt()-1;
				adj[u].add(new Edge(u, v, i));
				adj[v].add(new Edge(v, u, i));
				list[i] = new Edge(u, v, i);
				deg[u]++; deg[v]++;
			}

			int[] match = new int[g];
			int ptr = 0;

			boolean[] done = new boolean[n];
			Arrays.sort(list);
			for(int i = 0; i < m && ptr < g; i++) {
				Edge now = list[i];
				if(done[now.u] || done[now.v]) continue;
				done[now.u] = done[now.v] = true;
				match[ptr++] = list[i].id+1;
			}

			if(ptr == g) {
				out.println("Matching");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(match[i]);
				}
				out.println();
				continue;
			}

			int[] set = new int[g];
			ptr = 0;
			for(int i = 0; i < n && ptr < g; i++) {
				if(!done[i]) {
					set[ptr++] = i+1;
				}
			}

			if(ptr == g) {
				out.println("IndSet");
				for(int i = 0; i < g; i++) {
					if(i > 0) out.print(" ");
					out.print(set[i]);
				}
				out.println();
			}

		}

		out.close();
	}

	class Node implements Comparable<Node> {
		int id, deg;
		Node(int a, int b) {
			id = a; deg = b;
		}
		public int compareTo(Node n) {
			int c = Integer.compare(deg, n.deg);
			if(c == 0) c = Integer.compare(id, n.id);
			return c;
		}
	}

	class Edge implements Comparable<Edge> {
		int id, u, v;
		Edge(int a, int b, int i) {
			u = a; v = b;
			id = i;
		}
		public int compareTo(Edge e) {
			return Integer.compare(deg[u]+deg[v], deg[e.u]+deg[e.v]);
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1199E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         StringBuilder sb = new StringBuilder();
         while(T-->0)
         {
            st = new StringTokenizer(infile.readLine());
            int N = Integer.parseInt(st.nextToken());
            int M = Integer.parseInt(st.nextToken());
            boolean[] seen = new boolean[4*N];
            ArrayList<Integer> ls = new ArrayList<Integer>();
            for(int i=0; i < M; i++)
            {
               st = new StringTokenizer(infile.readLine());
               int a = Integer.parseInt(st.nextToken());
               int b = Integer.parseInt(st.nextToken());
               if(!seen[a] && !seen[b])
               {
                  seen[a] = true;
                  seen[b] = true;
                  ls.add(i+1);
               }
            }
            if(ls.size() >= N)
            {
               sb.append("Matching\n");
               for(int x: ls)
                  sb.append(x+" ");
            }
            else
            {
               sb.append("IndSet\n");
               ls = new ArrayList<Integer>();
               for(int i=1; i <= 3*N; i++)
                  if(!seen[i])
                     ls.add(i);
               for(int x: ls)
                  sb.append(x+" ");
            }
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1199E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         StringBuilder sb = new StringBuilder();
         while(T-->0)
         {
            st = new StringTokenizer(infile.readLine());
            int N = Integer.parseInt(st.nextToken());
            int M = Integer.parseInt(st.nextToken());
            boolean[] seen = new boolean[4*N];
            ArrayList<Integer> ls = new ArrayList<Integer>();
            for(int i=0; i < M; i++)
            {
               st = new StringTokenizer(infile.readLine());
               int a = Integer.parseInt(st.nextToken());
               int b = Integer.parseInt(st.nextToken());
               if(!seen[a] && !seen[b])
               {
                  seen[a] = true;
                  seen[b] = true;
                  ls.add(i+1);
               }
            }
            if(ls.size() >= N)
            {
               sb.append("Matching\n");
               for(int x: ls)
                  sb.append(x+" ");
            }
            else
            {
               sb.append("IndSet\n");
               ls = new ArrayList<Integer>();
               for(int i=1; i <= 3*N; i++)
                  if(!seen[i])
                  {
                     ls.add(i);
                     if(ls.size() == N)
                        break;
                  }
               for(int x: ls)
                  sb.append(x+" ");
            }
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1199E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         StringBuilder sb = new StringBuilder();
         while(T-->0)
         {
            st = new StringTokenizer(infile.readLine());
            int N = Integer.parseInt(st.nextToken());
            int M = Integer.parseInt(st.nextToken());
            boolean[] seen = new boolean[4*N];
            ArrayList<Integer> ls = new ArrayList<Integer>();
            for(int i=0; i < M; i++)
            {
               st = new StringTokenizer(infile.readLine());
               int a = Integer.parseInt(st.nextToken());
               int b = Integer.parseInt(st.nextToken());
               if(!seen[a] && !seen[b])
               {
                  seen[a] = true;
                  seen[b] = true;
                  ls.add(i+1);
               }
            }
            if(ls.size() >= N)
            {
               sb.append("Matching\n");
               int cnt = 0;
               for(int x: ls)
               {
                  sb.append(x+" ");
                  cnt++;
                  if(cnt == N)
                     break;
               }
            }
            else
            {
               sb.append("IndSet\n");
               ls = new ArrayList<Integer>();
               for(int i=1; i <= 3*N; i++)
                  if(!seen[i])
                  {
                     ls.add(i);
                     if(ls.size() == N)
                        break;
                  }
               for(int x: ls)
                  sb.append(x+" ");
            }
            sb.append("\n");
         }
         System.out.print(sb);
      }
   }


/*input

4
1 2
1 3
1 2
1 2
1 3
1 2
2 5
1 2
3 1
1 4
5 1
1 6
2 15
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

*/
import java.io.*;
import java.util.*;

public class mymy
{

	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);
	static InputStream inputStream = System.in;
	static InputReader br = new InputReader(inputStream);

	static int n;

	static int[] vis;

	public static void main(String[] args)throws IOException
	{

 		int t=br.nextInt();

 		while(t-->0)
 		{
 			n=br.nextInt()*3;

 			int m=br.nextInt();

 			vis=new int[n];

 			ArrayList<Integer> matching=new ArrayList<Integer>();

 			for(int i=0;i<m;i++)
 			{
 				int l=br.nextInt()-1;
 				int r=br.nextInt()-1;

 				if(vis[l]==0 && vis[r]==0) {matching.add(i+1);vis[l]=1;vis[r]=1;}
 			}

 			int indx=0;
 			n/=3;
 			if(matching.size()>=n)
 			{
 				out.println("Matching");
 				while(n-->0) out.print(matching.get(indx++)+" ");
 				out.println();
 			}
 			else
 			{
 				out.println("IndSet");
 				while(n>0) if(vis[indx++]==0) {out.print(indx+" ");n--;}
 				out.println();
 			}

 		}

		out.close();

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}

	}

}


import java.io.*;
import java.util.*;

public class E_MatchingVsIndependentSet {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {

        private void solve(InputReader inp, PrintWriter out) {
            int t = inp.nextInt();
            for (int i = 0; i < t; i++) solve2(inp, out);
        }

        private void solve2(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), m = inp.nextInt();
            ArrayList<Integer>[] graph = new ArrayList[3*n];
            ArrayList<Edge> edges = new ArrayList<>();
            for (int i = 0; i < 3*n; i++) graph[i] = new ArrayList<>();
            for (int i = 1; i <= m; i++) {
                int u = inp.nextInt() - 1, v = inp.nextInt() - 1;
                graph[u].add(v);
                graph[v].add(u);
                edges.add(new Edge(u , v, i));
            }
            HashSet<Integer> set = new HashSet<>();
            ArrayList<Edge> matching = new ArrayList<>();
            for (Edge e: edges) {
                if (!set.contains(e.u) && !set.contains(e.v)) {
                    matching.add(e);
                    set.add(e.u);
                    set.add(e.v);
                }
            }
            if (matching.size() >= n) {
                out.println("Matching");
                for (int i = 0; i < n; i++) out.print(matching.get(i).id + " ");
                out.print('\n');
            } else {
                out.println("IndSet");
                int cnt = 0;
                for (int i = 0; i < 3*n && cnt < n; i++) {
                    if (!set.contains(i)) {
                        out.print((i + 1) + " ");
                        cnt++;
                    }
                }
                out.print('\n');
            }
        }

        class Edge {
            int u, v, id;
            public Edge(int u, int v, int id) {
                this.u = u;
                this.v = v;
                this.id = id;
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


import java.io.*;
import java.util.*;

public class E_MatchingVsIndependentSet {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {

        private void solve(InputReader inp, PrintWriter out) {
            int t = inp.nextInt();
            for (int i = 0; i < t; i++) solve2(inp, out);
        }

        private void solve2(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), m = inp.nextInt();
            ArrayList<Integer>[] graph = new ArrayList[3*n];
            ArrayList<Edge> edges = new ArrayList<>();
            for (int i = 0; i < 3*n; i++) graph[i] = new ArrayList<>();
            for (int i = 1; i <= m; i++) {
                int u = inp.nextInt() - 1, v = inp.nextInt() - 1;
                graph[u].add(v);
                graph[v].add(u);
                edges.add(new Edge(u , v, i));
            }
            HashSet<Integer> set = new HashSet<>();
            ArrayList<Edge> matching = new ArrayList<>();
            for (Edge e: edges) {
                if (!set.contains(e.u) && !set.contains(e.v)) {
                    matching.add(e);
                    set.add(e.u);
                    set.add(e.v);
                }
            }
            if (matching.size() >= n) {
                out.println("Matching");
                for (Edge e: matching) out.print(e.id + " ");
                out.print('\n');
            } else {
                out.println("IndSet");
                for (int i = 0; i < 3*n; i++) {
                    if (!set.contains(i)) out.print((i + 1) + " ");
                }
                out.print('\n');
            }
        }

        class Edge {
            int u, v, id;
            public Edge(int u, int v, int id) {
                this.u = u;
                this.v = v;
                this.id = id;
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;

public class P1199E {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int caseNum = scanner.nextInt();
        while (caseNum-- > 0) {
            int n = scanner.nextInt();
            ArrayList<LinkedList<Integer>> links = new ArrayList<>(3 * n);
            for (int i = 0; i < 3 * n; ++i)
                links.add(new LinkedList<>());
            int m = scanner.nextInt();
            for (int i = 0; i < m; ++i) {
                int u = scanner.nextInt() - 1;
                int v = scanner.nextInt() - 1;
                links.get(u).add(v);
                links.get(v).add(u);
            }
            int[] d = new int[3 * n];
            LinkedList<Integer> ans = new LinkedList<>();
            for (int i = 0; i < 3 * n; ++i) {
                if (d[i] == 0) {
                    LinkedList<Integer> odd = new LinkedList<>();
                    LinkedList<Integer> even = new LinkedList<>();
                    Queue<Integer> queue = new LinkedList<>();
                    d[i] = 1;
                    queue.offer(i);
                    while (!queue.isEmpty()) {
                        int u = queue.poll();
                        if (d[u] % 2 == 0)
                            even.add(u);
                        else
                            odd.add(u);
                        for (int v : links.get(u)) {
                            if (d[v] == 0) {
                                d[v] = d[u] + 1;
                                queue.offer(v);
                            }
                        }
                    }
                    if (odd.size() > even.size())
                        ans.addAll(odd);
                    else
                        ans.addAll(even);
                    if (ans.size() >= n)
                        break;
                }
            }
            writer.println("IndSet");
            int k = 0;
            for (int u : ans) {
                writer.print(u + " ");
                if (++k == n)
                    break;
            }
            writer.println();
        }

        writer.close();
    }

    private static int bitQuery(int[] bit, int x) {
        int max = 0;
        for (; x >= 0; x = (x & (x + 1)) - 1)
            max = Math.max(max, bit[x]);
        return max;
    }

    private static void bitUpdate(int[] bit, int x, int val) {
        for (; x < bit.length; x = x | (x + 1))
            bit[x] = Math.max(bit[x], val);
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }

        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class P1199E {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int caseNum = scanner.nextInt();
        while (caseNum-- > 0) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            boolean[] covered = new boolean[3 * n];
            int[][] edges = new int[m][2];
            ArrayList<Integer> matchEdges = new ArrayList<>(m);
            for (int i = 0; i < m; ++i) {
                int u = scanner.nextInt() - 1;
                int v = scanner.nextInt() - 1;
                if (!covered[u] && !covered[v]) {
                    covered[u] = covered[v] = true;
                    matchEdges.add(i + 1);
                }
            }
            if (matchEdges.size() >= n) {
                writer.println("Matching");
                for (int i = 0; i < n; ++i)
                    writer.print(matchEdges.get(i) + " ");
            } else {
                writer.println("IndSet");
                for (int i = 0, cnt = 0; i < 3 * n; ++i)
                    if (!covered[i]) {
                        writer.print((i + 1) + " ");
                        if (++cnt == n)
                            break;
                    }
            }
            writer.println();
        }

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }

        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    void solve() {
       int t = ni();
       while(t-->0) {
           int n = ni(), m = ni();
           boolean vis[] = new boolean[3 * n + 1];
           ArrayList<Integer> ans = new ArrayList<>();
           for (int i = 1; i <= m; i++) {
               int u = ni(), v = ni();
               if (!vis[u] && !vis[v] && ans.size() < n) {
                   ans.add(i);
                   vis[u] = true;
                   vis[v] = true;
               }
           }
           if (ans.size() == n) {
               pw.println("Matching");
               for (int u : ans) pw.println(u);
           } else {
               pw.println("IndSet");
               for (int i = 1; i <= 3 * n; i++) {
                   if (!vis[i]) pw.println(i);
               }
           }
       }

    }
    long M = (long) 1e9 + 7;

    // END
    PrintWriter pw;
    StringTokenizer st;
    BufferedReader br;

    void run() throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }

}


import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    void solve() {
       int t = ni();
       while(t-->0) {
           int n = ni(), m = ni();
           boolean vis[] = new boolean[3 * n + 1];
           ArrayList<Integer> ans = new ArrayList<>();
           for (int i = 1; i <= m; i++) {
               int u = ni(), v = ni();
               if (!vis[u] && !vis[v] && ans.size() < n) {
                   ans.add(i);
                   vis[u] = true;
                   vis[v] = true;
               }
           }
           if (ans.size() == n) {
               pw.println("Matching");
               for (int u : ans) pw.println(u);
           } else {
               pw.println("IndSet");
               int cc=n;
               for (int i = 1; i <= 3 * n && cc>0; i++) {
                   if (!vis[i]){
                       cc--;
                       pw.println(i);
                   }
               }
           }
       }

    }
    long M = (long) 1e9 + 7;

    // END
    PrintWriter pw;
    StringTokenizer st;
    BufferedReader br;

    void run() throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    String ns() {
        while (st == null || !st.hasMoreElements()) {

            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 7;
int t, n, m;
vector<pair<int, int>> graph[N], edges;
vector<int> res;
bool was[N];

void dfs(int v, bool in) {
  was[v] = 1;
  for (auto i : graph[v]) {
    if (was[i.first]) {
      continue;
    }
    if (in) {
      dfs(i.first, 0);
    }
    else {
      dfs(i.first, 1);
      res.push_back(i.second);
      in = 1;
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      graph[a].emplace_back(b, i);
      graph[b].emplace_back(a, i);
      edges.emplace_back(a, b);
    }
    for (int i = 0; i < 3 * n; ++i) {
      if (!was[i]) {
        dfs(i, 0);
      }
    }
    if (res.size() >= n) {
      cout << "Matching\n";
    }
    else {
      cout << "IndSet\n";
      fill(was, was + 3 * n, 0);
      for (auto i : res) {
        was[edges[i].first] = 1;
        was[edges[i].second] = 1;
      }
      res.clear();
      for (int i = 0; i < 3 * n; ++i) {
        if (!was[i]) {
          res.push_back(i);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << res[i] + 1 << " ";
    }
    cout << "\n";
    for (int i = 0; i < 3 * n; ++i) {
      graph[i].clear();
    }
    fill(was, was + 3 * n, 0);
    res.clear();
    edges.clear();
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 7;
int t, n, m;
vector<pair<int, int>> graph[N], edges;
vector<int> res;
bool was[N];

void dfs(int v, bool in) {
  was[v] = 1;
  for (auto i : graph[v]) {
    if (was[i.first]) {
      continue;
    }
    if (in) {
      dfs(i.first, 0);
    }
    else {
      dfs(i.first, 1);
      res.push_back(i.second);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      graph[a].emplace_back(b, i);
      graph[b].emplace_back(a, i);
      edges.emplace_back(a, b);
    }
    for (int i = 0; i < 3 * n; ++i) {
      if (!was[i]) {
        dfs(i, 0);
      }
    }
    if (res.size() >= n) {
      cout << "Matching\n";
    }
    else {
      cout << "IndSet\n";
      fill(was, was + 3 * n, 0);
      for (auto i : res) {
        was[edges[i].first] = 1;
        was[edges[i].second] = 1;
      }
      res.clear();
      for (int i = 0; i < 3 * n; ++i) {
        if (!was[i]) {
          res.push_back(i);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << res[i] + 1 << " ";
    }
    cout << "\n";
    for (int i = 0; i < 3 * n; ++i) {
      graph[i].clear();
    }
    fill(was, was + 3 * n, 0);
    res.clear();
    edges.clear();
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 7;
int t, n, m;
vector<pair<int, int>> graph[N], edges;
vector<int> res;
bool was[N];

void dfs(int v, bool in) {
  was[v] = 1;
  for (auto i : graph[v]) {
    if (was[i.first]) {
      continue;
    }
    if (in) {
      dfs(i.first, 0);
    }
    else {
      dfs(i.first, 1);
      res.push_back(i.second);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      graph[a].emplace_back(b, i);
      graph[b].emplace_back(a, i);
      edges.emplace_back(a, b);
    }
    for (int i = 0; i < 3 * n; ++i) {
      if (!was[i]) {
        dfs(i, 0);
      }
    }
    if (res.size() >= n) {
      cout << "Matching\n";
    }
    else {
      cout << "IndSet\n";
      fill(was, was + 3 * n, 0);
      for (auto i : res) {
        was[edges[i].first] = 1;
        was[edges[i].second] = 1;
      }
      res.clear();
      for (int i = 0; i < 3 * n; ++i) {
        if (!was[i]) {
          res.push_back(i);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << i + 1 << " ";
    }
    cout << "\n";
    for (int i = 0; i < 3 * n; ++i) {
      graph[i].clear();
    }
    fill(was, was + 3 * n, 0);
    res.clear();
    edges.clear();
  }

  return 0;
}


#include <bits/stdc++.h>

//log n * (q + n)
using namespace std;

/*
 * collect edges to set in greedy way by any order.
 * all vertexes that are not part of set is independent
 * return on which fits condition of n
 * paired vrtx = vtx not in pairedVrtxSet;
*/

void processGraph(int n, int u) {
    vector<int> vrt;
    vrt.reserve(n * 3);
    unordered_set<int> paired;
    vector<int> pairedEdgeNums;

    for(int i = 0; i < u; ++i) {
        int left, right;
        cin >> left >> right;
        if (!paired.count(left) && !paired.count(right)) {
            paired.insert(left);
            paired.insert(right);
            pairedEdgeNums.push_back(i + 1);
        }
        vrt.push_back(left);
        vrt.push_back(right);
    }

    if (paired.size() >= n * 2) {
        cout << "Matching" << endl;
        for(int i = 0; i < n; ++i) {
            cout << pairedEdgeNums[i] << " ";
        }
    } else {
        cout << "IndSet" << endl;
        for(int i = 0, howManyPrint = 0; howManyPrint < n && i < vrt.size(); ++i) {
            if (!paired.count(vrt[i])) {
                cout << i / 2 + 1 << " ";
                ++howManyPrint;
            }
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int graphCount;
    cin >> graphCount;

    for(int i = 0; i < graphCount; ++i) {
        int n, u;
        cin >> n >> u;
        processGraph(n, u);
    }

    return 0;
}


#include <bits/stdc++.h>

//log n * (q + n)
using namespace std;

/*
 * collect edges to set in greedy way by any order.
 * all vertexes that are not part of set is independent
 * return on which fits condition of n
 * paired vrtx = vtx not in pairedVrtxSet;
*/

void processGraph(int n, int u) {
    vector<int> vrt;
    vrt.reserve(n * 3);
    unordered_set<int> paired;

    for(int i = 0; i < n * 3; ++i) {
        int left, right;
        cin >> left >> right;
        if (!paired.count(left) && !paired.count(right)) {
            paired.insert(left);
            paired.insert(right);
        }
        vrt.push_back(left);
        vrt.push_back(right);
    }

    if (paired.size() >= n * 2) {
        cout << "Matched" << endl;
        auto it = paired.begin();
        for(int i = 0; i < n; ++i, ++it) {
            cout << *it << " ";
        }
    } else {
        cout << "IndSet" << endl;
        for(int i = 0, howManyPrint = 0; howManyPrint < n && i < vrt.size(); ++i) {
            if (!paired.count(vrt[i])) {
                cout << vrt[i] << " ";
                ++howManyPrint;
            }
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int graphCount;
    cin >> graphCount;

    for(int i = 0; i < graphCount; ++i) {
        int n, u;
        cin >> n >> u;
        processGraph(n, u);
    }

    return 0;
}


#include <bits/stdc++.h>

//log n * (q + n)
using namespace std;

/*
 * collect edges to set in greedy way by any order.
 * all vertexes that are not part of set is independent
 * return on which fits condition of n
 * paired vrtx = vtx not in pairedVrtxSet;
*/

void processGraph(int n, int u) {
    vector<int> vrt;
    vrt.reserve(n * 3);
    unordered_set<int> paired;

    for(int i = 0; i < n * 3; ++i) {
        int left, right;
        cin >> left >> right;
        if (!paired.count(left) && !paired.count(right)) {
            paired.insert(left);
            paired.insert(right);
        }
        vrt.push_back(left);
        vrt.push_back(right);
    }

    if (paired.size() >= n * 2) {
        cout << "Matching" << endl;
        auto it = paired.begin();
        for(int i = 0; i < n; ++i, ++it) {
            cout << *it << " ";
        }
    } else {
        cout << "IndSet" << endl;
        for(int i = 0, howManyPrint = 0; howManyPrint < n && i < vrt.size(); ++i) {
            if (!paired.count(vrt[i])) {
                cout << vrt[i] << " ";
                ++howManyPrint;
            }
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int graphCount;
    cin >> graphCount;

    for(int i = 0; i < graphCount; ++i) {
        int n, u;
        cin >> n >> u;
        processGraph(n, u);
    }

    return 0;
}


#include <bits/stdc++.h>

//log n * (q + n)
using namespace std;

/*
 * collect edges to set in greedy way by any order.
 * all vertexes that are not part of set is independent
 * return on which fits condition of n
 * paired vrtx = vtx not in pairedVrtxSet;
*/

void processGraph(int n, int u) {
    unordered_set<int> paired;
    vector<int> pairedEdgeNums;
    pairedEdgeNums.reserve(n);

    for(int i = 0; i < u; ++i) {
        int left, right;
        cin >> left >> right;
        if (!paired.count(left) && !paired.count(right)) {
            paired.insert(left);
            paired.insert(right);
            pairedEdgeNums.push_back(i + 1);
        }
    }

    if (paired.size() >= n * 2) {
        cout << "Matching" << endl;
        for(int i = 0; i < n; ++i) {
            cout << pairedEdgeNums[i] << " ";
        }
    } else {
        cout << "IndSet" << endl;
        for(int i = 1, howManyPrint = 0; howManyPrint < n && i <= n * 3; ++i) {
            if (!paired.count(i)) {
                cout << i << " ";
                ++howManyPrint;
            }
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int graphCount;
    cin >> graphCount;

    for(int i = 0; i < graphCount; ++i) {
        int n, u;
        cin >> n >> u;
        processGraph(n, u);
    }

    return 0;
}


#include <bits/stdc++.h>

//log n * (q + n)
using namespace std;

/*
 * collect edges to set in greedy way by any order.
 * all vertexes that are not part of set is independent
 * return on which fits condition of n
 * paired vrtx = vtx not in pairedVrtxSet;
*/

void processGraph(int n, int u) {
    vector<int> vrt;
    vrt.reserve(n * 3);
    unordered_set<int> paired;
    vector<int> pairedEdgeNums;
    pairedEdgeNums.reserve(n);

    for(int i = 0; i < u; ++i) {
        int left, right;
        cin >> left >> right;
        if (!paired.count(left) && !paired.count(right)) {
            paired.insert(left);
            paired.insert(right);
            pairedEdgeNums.push_back(i + 1);
        }
        vrt.push_back(left);
        vrt.push_back(right);
    }

    if (paired.size() >= n * 2) {
        cout << "Matching" << endl;
        for(int i = 0; i < n; ++i) {
            cout << pairedEdgeNums[i] << " ";
        }
    } else {
        cout << "IndSet" << endl;
        for(int i = 0, howManyPrint = 0; howManyPrint < n && i < vrt.size(); ++i) {
            if (!paired.count(i+1)) {
                cout << i + 1 << " ";
                ++howManyPrint;
            }
        }
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int graphCount;
    cin >> graphCount;

    for(int i = 0; i < graphCount; ++i) {
        int n, u;
        cin >> n >> u;
        processGraph(n, u);
    }

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

#include <unordered_map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia

#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, m, T;
vector<pii> g[N];
int main(){
    dracarys
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) g[i].clear();
        for (int i = 1; i <= m; ++i) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(make_pair(b, i));
            g[b].push_back(make_pair(a, i));
        }
        set<int> st;
        vector<int> ans;
        bool ind = false;
        for (int i = 1; i <= 3 * n; ++i) {
            bool ok = true;
            for (pii to : g[i]) {
                if (st.count(to.first)) {
                    st.erase(to.first);
                    ans.push_back(to.second);
                    ok = false;
                    break;
                }
            }
            if (ok == false)
                continue;
            st.insert(i);
            if (st.size() >= n) {
                cout << "IndSet\n";
                for (int to : st)
                    cout << to << " ";
                cout << "\n";
                ind = true;
                break;
            }
        }
        if (ind == false) {
            cout << "Matching\n";
            for (int i = 0; i < n; ++i)
                cout << ans[i] << " ";
            cout << "\n";
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

#include <unordered_map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia

#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, m, T;
vector<pii> g[N];
int main(){
    dracarys
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int i = 1; i <= 3 * n; ++i) g[i].clear();
        for (int i = 1; i <= m; ++i) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(make_pair(b, i));
            g[b].push_back(make_pair(a, i));
        }
        set<int> st;
        vector<int> ans;
        bool indSet = false;
        for (int i = 1; i <= 3 * n; ++i) {
            bool ok = true;
            for (pii to : g[i]) {
                if (st.count(to.first)) {
                    st.erase(to.first);
                    ans.push_back(to.second);
                    ok = false;
                    break;
                }
            }
            if (ok == false)
                continue;
            st.insert(i);
            if (st.size() >= n) {
                cout << "IndSet\n";
                for (int to : st)
                    cout << to << " ";
                cout << "\n";
                indSet = true;
                break;
            }
        }
        if (indSet == false) {
            cout << "Matching\n";
            for (int i = 0; i < n; ++i)
                cout << ans[i] << " ";
            cout << "\n";
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

#include <unordered_map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia

#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, m, T;
vector<pii> g[N];
int main(){
    dracarys
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) g[i].clear();
        for (int i = 1; i <= m; ++i) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(make_pair(b, i));
            g[b].push_back(make_pair(a, i));
        }
        set<int> st;
        vector<int> ans;
        bool ind = false;
        for (int i = 1; i <= 3 * n; ++i) {
            bool ok = true;
            for (pii to : g[i]) {
                if (st.count(to.first)) {
                    st.erase(to.first);
                    ans.push_back(to.second);
                    ok = false;
                    break;
                }
            }
            st.insert(i);
            if (st.size() >= n) {
                cout << "IndSet\n";
                for (int to : st)
                    cout << to << " ";
                cout << "\n";
                ind = true;
                break;
            }
        }
        if (ind == false) {
            cout << "Matching\n";
            for (int i = 0; i < n; ++i)
                cout << ans[i] << " ";
            cout << "\n";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;
	while(t-->0)
	{
		ll n,m;
		cin>>n>>m;
		set<ll> se;
		for(ll i=1;i<=(3*n);i++)
		{
			se.insert(i);
		}
		vector<ll> v;
		for(ll i=1;i<=m;i++)
		{
			ll x,y;
			cin>>x>>y;
			if(se.find(x)!=se.end() && se.find(y)!=se.end())
			{
				se.erase(x);
				se.erase(y);
				v.push_back(i);
			}
		}
		if(v.size()>=n)
		{
			cout<<"Matching"<<"\n";
			for(ll i=0;i<n;i++)
				cout<<v[i]<<" ";
			cout<<"\n";
		}
		else
		{
			cout<<"IndSet"<<"\n";
			ll cnt=0;
			for(auto x:se)
			{
				if(cnt==n)
					break;
				cout<<x<<" ";
				cnt+=1;
			}
			cout<<"\n";

		}
	}

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main(){
	ll t;
	cin>>t;
	while(t-->0)
	{
		ll n,m;
		cin>>n>>m;
		set<ll> se;
		for(ll i=1;i<=(3*n);i++)
		{
			se.insert(i);
		}
		vector<ll> v;
		for(ll i=1;i<=m;i++)
		{
			ll x,y;
			cin>>x>>y;
			if(se.find(x)!=se.end() && se.find(y)!=se.end())
			{
				se.erase(x);
				se.erase(y);
				v.push_back(i);
			}
		}
		if(v.size()>=n)
		{
			cout<<"Matching"<<"\n";
			for(ll i=0;i<n;i++)
				cout<<v[i]<<" ";
			cout<<"\n";
		}
		else
		{
			cout<<"IndSet"<<"\n";
			ll cnt=0;
			for(auto x:se)
			{
				if(cnt==n)
					break;
				cout<<x<<" ";
				cnt+=1;
			}
			cout<<"\n";

		}
	}

}


#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
int sqrtM(int a)
{
    return sqrt(a);
}
int dis(int x1,int y1,int x2,int y2)
{
    return sqrtM((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}
int main()
{
    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    int d=dis(x1,y1,x2,y2);
    if(abs(x2-x1)==abs(y2-y1))
    {
        cout<<x2<<" "<<y1<<" "<<x1<<" "<<y2;
    }
    else if(x1==x2)
    {
        cout<<(x1+d)<<" "<<y1<<" "<<(x1+d)<<" "<<y2;
    }
    else if(y1==y2)
    {
        cout<<x1<<" "<<(y1+d)<<" "<<x2<<" "<<(y1+d);
    }
    else
        cout<<"-1";
return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <cmath>
#include<math.h>
using namespace std;
int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double x =abs( x1 - x2);
	double y = abs(y1 - y2);
	int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
	int dist;
	if (x1 != x2 && y1 != y2 && x != y)
	{
		cout << -1 << endl;
	}
	else if (x1 == x2 && y1 != y2)
	{
		dist = sqrt((x*x) + (y*y));
		x3 = x1 + dist;
		x4 = x2 + dist;
		y3 = y1;
		y4 = y2;
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
	else if (y1 == y2 && x1 != x2)
	{
		dist = sqrt((x*x) + (y*y));
		y3 = y1 + dist;
		y4 = y2 + dist;
		x3 = x1;
		x4 = x2;
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
	else if (x1 != x2 && y1 != y2 && x == y)
	{
		dist = sqrt(((x*x) + (y*y))/2);
		if (x1 > x2)
		{
			x3 = x1 - dist;
			y3 = y1;
			x4 = x2 + dist;
			y4 = y2;
		}
		else if (x1 < x2)
		{
			x4 = x2 - dist;
			y4 = y2;
			x3 = x1 + dist;
			y3 = y1;
		}
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
}


#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
using namespace std;
int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double x = x1 - x2;
	double y = y1 - y2;
	double x3, y3, x4, y4;
	int d = (x*x) + (y*y);
	double dist;
	if (x1 != x2 && y1 != y2 && x != y)
	{
		cout << -1 << endl;
	}
	else if (x1 == x2 && y1 != y2)
	{
		dist = sqrt(d);
		x3 = x1 + dist;
		x4 = x2 + dist;
		y3 = y1;
		y4 = y2;
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
	else if (y1 == y2 && x1 != x2)
	{
		dist = sqrt(d);
		y3 = y1 + dist;
		y4 = y2 + dist;
		x3 = x1;
		x4 = x2;
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
	else if (x1 != x2 && y1 != y2 && x == y)
	{
		double f;
		f = d / 2;
		dist = sqrt(d);
		if (x1 > x2)
		{
			x3 = x1 - dist;
			y3 = y1;
			x4 = x2 + dist;
			y4 = y2;
		}
		else if (x1 < x2)
		{
			x4 = x2 - dist;
			y4 = y2;
			x3 = x1 + dist;
			y3 = y1;
		}
		cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	}
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	struct point{
		int x, y;
	};
	point a, b, c, d;
	int max_x, max_y, min_x, min_y, d_x, d_y;
	cin >> a.x >> a.y >> b.x >> b.y;
	float slope;

	if ( (b.x - a.x ) * 1.0 / ( b.y - a.y ) == 0)
	{
		if ( a.y > b.y )
		{ max_y = a.y; min_y = b.y; }
		else
		{ max_y = b.y; min_y = a.y; }
		d_y = max_y - min_y;
		c.x = a.x + d_y;
		d.x = c.x;
		c.y = max_y;
		d.y = min_y;

		cout << d.x << " " << d.y << " " << c.x << " " << c.y << endl;

	}
	else
	{

			slope=((b.y -a.y) * 1.0 / (b.x - a.x) );
			if(( slope != 0 ) && ( slope != 1 ))
				cout << "-1\n";
			else
			{

				if ( slope == 0)
				{
					if ( a.x > b.x)
					{ max_x = a.x; min_x = b.x;

					}
					else
					{ max_x  = b.x; min_x = a.x;}

					d_x = max_x - min_x;
					c.x = min_x;
					c.y = a.y + d_x;
					d.x = max_x;
					d.y = c.y ;

				}
				if ( abs(slope) == 1)
				{
					if (a.x > b.x)
					{ max_x = a.x; min_x = b.x; }
					else
					{ max_x = b.x; min_x = a.x; }
					if ( a.y > b.y )
					{ max_y = a.y; min_y = b.y; }
					else
					{ max_y = b.y; min_y = a.y; }
					d_x = max_x - min_x;
					c.x = min_x;
					c.y = min_y + d_x;
					d.x = max_x;
					d.y = min_y;

				}
				if ( slope == -1)
				    cout << -d.x << " " << -d.y << " " << -c.x << " " << -c.y << endl;
				else
				    cout << d.x << " " << d.y << " " << c.x << " " << c.y << endl;

			}
	}
return 0;
}


#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
int main()
{
	struct point{
		int x, y;
	};
	point a, b, c, d;
	int max_x, max_y, min_x, min_y, d_x, d_y;
	cin >> a.x >> a.y >> b.x >> b.y;
	int slope;

	if ( (b.x - a.x ) * 1.0 / ( b.y - a.y ) == 0)
	{
		if ( a.y > b.y )
		{ max_y = a.y; min_y = b.y; }
		else
		{ max_y = b.y; min_y = a.y; }
		d_y = max_y - min_y;
		c.x = a.x + d_y;
		d.x = c.x;
		c.y = max_y;
		d.y = min_y;

		cout << d.x << " " << d.y << " " << c.x << " " << c.y << endl;

	}
	else
	{

			slope=((b.y -a.y) / (b.x - a.x) );
			if(( slope != 0 ) && ( slope != 1 ))
				cout << "-1\n";
			else
			{

				if ( slope == 0)
				{
					if ( a.x > b.x)
					{ max_x = a.x; min_x = b.x;

					}
					else
					{ max_x  = b.x; min_x = a.x;}

					d_x = max_x - min_x;
					c.x = min_x;
					c.y = a.y + d_x;
					d.x = max_x;
					d.y = c.y ;

				}
				if ( abs(slope) == 1)
				{
					if (a.x > b.x)
					{ max_x = a.x; min_x = b.x; }
					else
					{ max_x = b.x; min_x = a.x; }
					if ( a.y > b.y )
					{ max_y = a.y; min_y = b.y; }
					else
					{ max_y = b.y; min_y = a.y; }
					d_x = max_x - min_x;
					c.x = min_x;
					c.y = min_y + d_x;
					d.x = max_x;
					d.y = min_y;

				}
				cout << d.x << " " << d.y << " " << c.x << " " << c.y << endl;

			}
	}
return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    struct point{
        int x, y;
    };
    point a, b, c, d;
    int delta;
    cin >> a.x >> a.y >> b.x >> b.y;
            if ( a.y == b.y )
            {
                delta = abs( a.x - b.x);
                c.x = a.x;
                c.y = a.y + delta;
                d.x = b.x;
                d.y = b.y + delta;
            }
            else
                if ( a.x == b.x)
                {
                    delta = abs(a.y - b.y);
                    c.y = a.y;
                    c.x = a.x + delta;
                    d.y = b.y;
                    d.x = b.x + delta;
                }
                else
                 {
                     delta = abs ( a.x - b.x);
                     if ( (a.x > a.y)&& (b.y > a.y))
                     {
                     c.x = a.x;
                     c.y = a.y + delta;
                     d.x = a.x + delta;
                     d.y = a.y;
                     }
                     else
                     {
                         c.x = a.x;
                         c.y = a.y - delta;
                         d.x = a.x + delta;
                         d.y = b.y;
                     }
                 }

            cout << c.x << " " << c.y << " " << d.x << " " << d.y << endl;
        }

   return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    struct point{
        int x, y;
    };
    point a, b, c, d;
    int delta;
    cin >> a.x >> a.y >> b.x >> b.y;
            if ( a.y == b.y )
            {
                delta = abs( a.x - b.x);
                c.x = a.x;
                c.y = a.y + delta;
                d.x = b.x;
                d.y = b.y + delta;
            }
            else
                if ( a.x == b.x)
                {
                    delta = abs(a.y - b.y);
                    c.y = a.y;
                    c.x = a.x + delta;
                    d.y = b.y;
                    d.x = b.x + delta;
                }
                else
                 {
                     delta = abs ( a.x - b.x);
                     if ( (a.x > a.y)&& (b.y > a.y))
                     {
                     c.x = a.x;
                     c.y = a.y + delta;
                     d.x = a.x + delta;
                     d.y = a.y;
                     }
                     else
                     {
                         c.x = a.x;
                         c.y = a.y - delta;
                         d.x = a.x + delta;
                         d.y = b.y;
                     }
                 }

            cout << c.x << " " << c.y << " " << d.x << " " << d.y << endl;
        }

}