/*
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);
      }
   }