#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define jh(x, y) x ^= y ^= x ^= y
#define loc(x, y) (x - 1) * m + y
#define rg register
#define inl inline
#define PI 3.141592654
typedef long long ll;
const int N = 4e5 + 5, INF = 0x3f3f3f3f, mod = 998244353;
using namespace std;
namespace fast_IO {
	inl ll read() {
		rg char c;
		rg ll x = 0;
		rg bool flag = false;
		while ((c = getchar()) == ' ' || c == '\n' || c == '\r');
		if (c == EOF)return c; if (c == '-')flag = true; else x = c ^ 48;
		while ((c = getchar()) != ' ' && c != '\n' && c != '\r' && ~c)
			x = (x << 1) + (x << 3) + (c ^ 48);
		if (flag)return -x; return x;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg ll x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
}
bool flag[N];
int edge[N];

int main() {
	rg int T = fast_IO::read();
	while (T--) {
		rg int n = fast_IO::read(), m = fast_IO::read(), tot = 0;
		memset(flag, 0, sizeof(int) * (n * 3 + 1)); *edge = 0;
		for (rg int i = 1; i <= m; ++i) {
			rg int x = fast_IO::read(), y = fast_IO::read();
			if (!flag[x] && !flag[y])flag[x] = flag[y] = true, tot += 2, edge[++*edge] = i;
		}
		if (3 * n - tot >= n) {
			puts("IndSet");
			for (rg int i = 1, num = 1; i <= 3 * n && num <= n; ++i)
				if (!flag[i])fast_IO::write(i), putchar(num == n ? '\n' : ' '), ++num;
		}
		else if (*edge >= n) {
			puts("Matching");
			for (rg int i = 1; i <= n; ++i)
				fast_IO::write(i), putchar(i == n ? '\n' : ' ');
		}
		else puts("Impossible");
	}
	return 0;
}
