#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
mt19937 rng(time(0));
void Alice(int n, int m, int A[], int B[]){
vector<int> p = {7, 6, 4, 0, 3, 1, 9, 2, 8, 5};
vector<array<int, 2>> t;
for (int i = 0; i < m; ++i) t.pb({A[i], B[i]});
for (int i = 0; i < n+2; ++i) {
for (int j = 0; j < 10; ++j) {
if ((i >> j) & 1) t.pb({i, n + 2 + j});
}
}
for (int j = 0; j < 9; ++j) t.pb({n + 2 + p[j], n + 2 + p[j+1]});
for (int i = 0; i < n; ++i) {
if (rng() & 1) t.pb({n, i});
if (rng() & 1) t.pb({n+1, i});
}
InitG(n + 12, t.size());
for (int i = 0; i < t.size(); ++i) {
MakeG(i, t[i][0], t[i][1]);
}
}
// https://www.youtube.com/watch?v=vUqzpujUU7c zeta z orz
#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1024;
vector<int> g[N];
int f[N];
void Bob(int V, int U, int C[], int D[]){
int n = V - 12;
for (int i = 0; i < U; ++i) {
g[C[i]].pb(D[i]);
g[D[i]].pb(C[i]);
}
vector<int> p = {7, 6, 4, 0, 3, 1, 9, 2, 8, 5};
vector<vector<int>> av;
for (int j = 0; j < 10; ++j) {
int c = 1 + (j != 0 && j != 9);
for (int i = 0; i < n+2; ++i) {
if ((i >> p[j]) & 1) ++c;
}
if (j) {
vector<vector<int>> t;
for (auto &x : av) {
for (auto &y : g[x.back()]) {
if (g[y].size() == c) {
bool ok = 1;
for (auto &z : x) {
if (z == y) {
ok = 0;
break;
}
}
if (ok) {
t.pb(x);
t.back().pb(y);
}
}
}
}
av = t;
}
else {
for (int i = 0; i < V; ++i) {
if (g[i].size() == c) av.pb({i});
}
}
}
for (int i = 0; i < 10; ++i) {
for (auto y : g[av[0][i]]) {
f[y] += (1 << p[i]);
}
}
vector<array<int, 2>> vr;
for (int i = 0; i < V; ++i) {
if (f[i] >= n) continue;
for (auto x : g[i]) {
if (f[x] < n && f[i] < f[x]) {
vr.pb({f[i], f[x]});
}
}
}
InitMap(n, vr.size());
for (auto [x, y] : vr) {
MakeMap(x, y);
}
}