#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; vector> Graph(N); for(int i=0; i> u >> v; u--; v--; Graph.at(u).insert(v); Graph.at(v).insert(u); } priority_queue,vector>,greater<>> Q; vector V(N); for(int i=0; i> T; while(T.size() < N-2){ auto [v,pos] = Q.top(); Q.pop(); if(V.at(pos) != v) continue; if(v == 3){ auto itr = Graph.at(pos).begin(); int v1 = pos; int v2 = *itr; itr++; int v3 = *itr; itr++; int v4 = *itr; itr++; Graph.at(v2).erase(v1); Graph.at(v3).erase(v1); Graph.at(v4).erase(v1); V.at(v2)--,V.at(v3)--,V.at(v4)--,V.at(v1) -= 3; Q.push({V.at(v2),v2}); Q.push({V.at(v3),v3}); Q.push({V.at(v4),v4}); T.push_back({v1,v2,v3,v4}); } else if(v == 2){ auto itr = Graph.at(pos).begin(); int v1 = pos; int v2 = *itr; itr++; int v3 = *itr; itr++; T.push_back({v1,v2,v3,-1}); } } vector C(N,-1),left(N-2,4); left.at(N-3) = 0; vector> Group(N); for(int i=0; i st; auto paint = [&](int pos,int c) -> void { C.at(pos) = c; for(auto g : Group.at(pos)){ left.at(g)--; if(left.at(g) == 1) st.push(g); } }; { auto [v1,v2,v3,v4] = T.back(); paint(v1,0); paint(v2,1); paint(v3,2); } while(st.size()){ auto g = st.top(); st.pop(); if(left.at(g) == 0) continue; assert(left.at(g) == 1); auto [v1,v2,v3,v4] = T.at(g); int use = 15; if(C.at(v1) != -1) use -= 1<