/**akshaykumar99**/

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

#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int MOD=1e9+7 ;
const long long INF=1e15;
const long long LINF=LLONG_MAX;

typedef long long ll;
typedef long double ld;
typedef vector<ll> lvc;
typedef pair<ll,ll> lpr;

int main()
{
    IOS();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--)
    {
        int nn,m,i;
        cin>>nn>>m;
        int n=3*nn;
        bool vis[n+1]={false};
        vector<int> v;
        f(i,0,m)
        {
          int x,y;
          cin>>x>>y;
          if(!vis[x] && !vis[y])
          {
            v.pu(i+1);
            vis[x]=true;
            vis[y]=true;
          }  
        }
        if(v.size()>=nn)
        {
          cout<<"MATCHING\n";
          f(i,0,nn)
            cout<<v[i]<<" ";
        }
        else
        {
          cout<<"INDSET\n";
          int xx=0;
          f(i,1,n+1)
          {
            if(!vis[i])
            {
              cout<<i<<" ";
              xx++;
            }
            if(xx==nn)
              break;
          }
        }
        cout<<"\n";

    }
    return 0;
  }