#include "split.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<int>adj[N];
int col[N], C[3], val[3], lst = 0;
bool visited[N];
int deg[N], sz[N], root = -1, A, B, NN;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res(n, 0);
NN = n;
for (int i = 0; i < p.size(); i++) {
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
deg[p[i]]++;
deg[q[i]]++;
}
vector<pair<int, int>>o;
o.push_back({ a, 0 });
o.push_back({ b, 1 });
o.push_back({ c, 2 });
sort(o.begin(), o.end());
A = o[0].first;
B = o[1].first;
val[0] = a;
val[1] = b;
val[2] = c;
for (int i = 0; i < n; i++) {
queue<int>q;
q.push(i);
C[o[0].second] = 1;
col[i] = o[0].second + 1;
visited[i] = 1;
while (!q.empty()) {
if (C[o[0].second] == o[0].first) break;
auto node = q.front();
q.pop();
for(auto j : adj[node]){
if(visited[j]) continue;
C[o[0].second]++;
q.push(j);
col[j] = o[0].second + 1;
visited[j] = 1;
if(C[o[0].second] == o[0].first) break;
}
}
int node = -1;
for(int j = 0; j < n; j++){
if(visited[j]) continue;
node = j;
break;
}
while(!q.empty()) q.pop();
q.push(node);
col[node] = o[1].second + 1;
C[o[1].second]++;
visited[node] = 1;
while(!q.empty()){
if (C[o[1].second] == o[1].first) break;
auto node = q.front();
q.pop();
for(auto j : adj[node]){
if(visited[j]) continue;
C[o[1].second]++;
q.push(j);
col[j] = o[1].second + 1;
visited[j] = 1;
if(C[o[1].second] == o[1].first) break;
}
}
if(C[o[0].second] == o[0].first && C[o[1].second] == o[1].first){
for(int i = 0; i < n; i++){
if(col[i]){
res[i] = col[i];
}else{
res[i] = o[2].second + 1;
}
}
return res;
}
for(int j = 0; j < n; j++){
col[j] = 0;
visited[j] = 0;
}
C[0] = C[1] = C[2] = 0;
}
return res;
}