7986: The Great Revegetation

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:29 通过:11

题目描述

长时间的干旱使得Farmer John的N块草地上牧草匮乏。随着雨季即将到来,现在应当是重新种植的时候了。

在Farmer John的储物棚里有四个桶,每个桶里装着一种不同的草种。他想要在每块草地上播种其中一种草。作为一名奶农,Farmer John想要确保他的每头奶牛都能得到丰富的食谱。他的M头奶牛每一头都有两块喜爱的草地,他想要确保这两块草地种植不同种类的草,从而每头奶牛都可以有两种草可供选择。Farmer John知道没有一块草地受到多于3头奶牛的喜爱。

请帮助Farmer John选择每块草地所种的草的种类,使得所有奶牛的营养需求都得到满足。

输入格式(文件名:revegetate.in):

输入的第一行包含N(2≤N≤100)和M(1≤M≤150)。以下M行,每行包含两个范围为1…N的整数,为Farmer John的一头奶牛喜欢的两块草地。

输出格式(文件名:revegetate.out):

输出一个N位数,每一位均为1…4之一,表示每一块草地上所种的草的种类。第一位对应草地1的草的种类,第二位对应草地2,以此类推。如果有多种可行的解,只需输出所有解中最小的N位数。

输入样例:

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

输出样例:

12133


A lengthy drought has left Farmer John's N pastures devoid of grass. However, with the rainy season arriving soon, the time has come to "revegetate".

In Farmer John's shed, he has four buckets, each with a different type of grass seed. He wishes to sow each pasture with one of these types of seeds. Being a dairy farmer, Farmer John wants to make sure each of his cows has a varied diet. Each of his M cows has two favorite pastures, and he wants to be sure different types of grass are planted in each, so every cow can choose between two types of grass. Farmer John knows that no pasture is a favorite of more than 3 cows.

Please help Farmer John choose a grass type for each pasture so that the nutritional needs of all cows are satisfied.

INPUT FORMAT (file revegetate.in):

The first line of input contains N (2≤N≤100) and M (1≤M≤150). Each of the next M lines contains two integers in the range 1…N, describing the pair of pastures that are the two favorites for one of Farmer John's cows.

OUTPUT FORMAT (file revegetate.out):

Output an N-digit number, with each digit in the range 1…4, describing the grass type to be planted in each field. The first digit corresponds to the grass type for field 1, the second digit to field 2, and so on. If there are multiple valid solutions, print only the N-digit number that is smallest among all of them.

SAMPLE INPUT:

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

SAMPLE OUTPUT:

12133

输入样例 复制

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

输出样例 复制

12133