Complete Tripartite
시간 제한2초메모리 제한1024 MB
무향 그래프의 정점을 세 개의 비어 있지 않은 그룹으로 나누어, 모든 간선이 그룹 사이에만 있고 그룹 안에는 없도록 만들 수 있는지 판정한다.
문제
You have a simple undirected graph consisting of vertices and edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let and be two some nonempty subsets of vertices that do not intersect. Let be true if and only if all the conditions are satisfied:
- There are no edges with both endpoints in vertex set .
- There are no edges with both endpoints in vertex set .
- For every two vertices and such that is in and is in , there is an edge between and .
Create three vertex sets (, , ) which satisfy the conditions below;
- All vertex sets should not be empty.
- Each vertex should be assigned to only one vertex set.
- , , are all true.
Is it possible to create such three vertex sets? If it's possible, print matching vertex set for each vertex.
입력
The first line contains two integers and (, ) --- the number of vertices and edges in the graph.
The -th of the next lines contains two integers and () --- it means there is an edge between and . The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
출력
If the answer exists, print integers. -th integer means the vertex set number (from to ) of -th vertex. Otherwise, print .
If there are multiple answers, print any.
힌트
In the first example, if , , and then vertex sets will satisfy all conditions. But you can assign vertices to vertex sets in a different way; Other answers like "2 3 3 1 1 1" will be accepted as well.

In the second example, it's impossible to make such vertex sets.