시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB0000.000%

문제

The tram network in my town is made of tram stations and lines that connect them.

One tram line consists of a sequence of distinct stations and there is always a direct line between two consecutive stations on a line. Every two stations are connected with a line in a unique way. Also, there is always a way to get from one train station to another by using the city tram.

In an effort to help their citizens our dilligent town officials have decided to paint every tram with a colour (marked by numbers from 1 to B) so all the trams on the same line have the same colour, but all the trams that pass through the same station must be differently coloured.

Since our town's budget is very small, we need to use as little of different colours as possible.

Please, please help us! We need a program that will determine some way to paint our trams, so that the number different colours is minimal. 

입력

In the first line of the input are two integers, N and M separated by a single space, 1 ≤ N ≤ 1000, 1 ≤ M ≤ 20000, the number of stations and the number of tram lines.

The next M lines describe the tram lines.

Each description begins with an integer R, the number of the tram stations through which the line passes (including the start and stop stations, which are mutually different). All the numbers in the descriptions are separated by a single space.

Note: the size of the input file will always be smaller than 2 MB. 

출력

In the first line of the output file you have to write the minimal number of the colours used to that will be used paint our town.

In the second line you have to write M numbers, separated by a single space. These numbers should present one of the possible ways to paint the trams, each number for one station, the first number is the colour of the first station etc.

예제 입력 1

6 3
3 1 2 3
3 4 5 6
4 1 2 5 6

예제 출력 1

2
1 1 2

예제 입력 2

6 4
6 1 2 3 4 5 6
3 2 3 4
2 5 4
2 5 6

예제 출력 2

3
1 2 3 2

예제 입력 3

8 4
3 3 2 1
3 2 5 6
4 4 5 6 7
2 8 4

예제 출력 3

2
1 2 1 2