#include "island.h"
#include <iostream>
typedef long long ll;
typedef double lf;
using namespace std;
const int MAXN = 310;
int n;
bool e[MAXN][MAXN];
int fa[MAXN];
inline int Find(int k) { return k == fa[k] ? k : fa[k] = Find(fa[k]); }
inline void Union(int u, int v) { u = Find(u), v = Find(v); if (u != v) fa[v] = u; }
void solve(int N, int LMT)
{
n = N;
for (int i = 1; i <= n; i++) fa[i] = i;
for (int i = 1; i < n; i++)
{
int u = query(1, i), c = 1;
while (Find(u) != Find(1))
{
int v = query(u, c); c++;
e[u][v] = e[v][u] = 1, Union(v, u);
}
}
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
if (e[i][j]) answer(i, j);
}