// three points chart, quite simply, speaking at ideas: first of all the points are divided into three collections, under // judge the collection can not be null point in the set can not have a connection, and finally judge the lower number # the include <bits./stdc ++ H.> the using namespace STD; typedef Long Long I64; const int = 1E5 + MAXN 32; int n-, m, U, V, COL [MAXN]; SET <int> Grape [MAXN]; I64 ARR [. 8]; int main () { iOS :: sync_with_stdio (to false); cin.tie (0), cout.tie (0); CIN >> >> n-m; for (int I = 0; I =! m; I ++) { CIN >> >> U V; Grape [U] .insert (V); Grape [V] .insert (U); } COL [. 1] =. 1; for (int I = 2; I <= n-; I ++) IF (! Grape [. 1] .count (I)) COL [I] =. 1; for (int I = 2; I <= n-;++i) If the node i if // not accessed (COL [i]!) { COL [i] = 2; // to find a set of 2 for (int. 1 = J; J <= n-; J ++) { IF (! Grape [I] .count (J)) { IF (COL [J] ==. 1) { COUT << - <<. 1 '\ n-'; return 0; } COL [J] = 2; } } BREAK; } // the second mark for (int I =. 1; I <= n-; I ++) IF (COL [I]!) COL [I] =. 3; for (int I =. 1; I <= n-; ++ I) { for(auto v :Grape[i]) if(col[v] == col[i]) { cout<<-1<<'\n'; return 0; } }//集合内的边去重 for(int i=1;i<=n;++i) ++arr[col[i]]; if(!arr[1]||!arr[2]||!arr[3]) cout<<"-1"<<'\n'; else if((arr[1]*arr[2]+arr[1]*arr[3]+arr[2]*arr[3])!=m) cout<<-1<<"\n"; else{ for(int i=1;i<=n;++i) cout<<col[i]<<" "; cout<<'\n'; } }