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());
        }
    }
}
