BICOLOR - Bicolor

no tags 

When you look at a political map of the world, each country is colored in color different from its neighbors' so that you can clearly see the borders. But as you know, the are between 192 and 195 countries in the world (depending on where you live) so it is common for two countries on the map to have the same color. After all, men can see only 16 colors ("Peach" is not a color according to me), so it has been a hard question for a long time if it is possible to color the map of the world with just 4 colors, following the rule that you are not allowed to color neighboring countries with the same color. This problem, however, is not easy at all, and we are going to simplify it a little bit. You are a Rock Star, and you are going on a tour in the galaxy. You are looking at the map of the sky and some of the stars are connected with other stars to form oddly shaped constellations. You are wondering if the stars can be bicolored (colored with just two colors) following the rule that you can not color two stars with the same color if they are directly connected with line on the map. You are bored as you are traveling towards the first star on your tour with speeds close to the speed of light so the clock in your space ship are ticking slower. Having nothing better to do, you decide to write a computer program to solve it.

Input

The input will consist of multiple maps. Each map starts with the number of stars on the map N (1 <= N <= 1024). On the next line is the number M (1<= M <=30000), the number of lines on the map connecting the stars. The stars are numbered with integers from 0 to N-1. On the next M lines you will find 2 integers - the ID-s of two stars that are connected. To denote the end of the input, the last map will have N = 0, and at this point you should stop reading.

Output

For each map in the input case, you need to output exactly one line in the output containing either the string "NOT BICOLORABLE" or "BICOLORABLE".

Example

Input:
3
3
0 1
1 2
2 0
5
4
0 1
0 2
0 3
0 4
0

Output:
NOT BICOLORABLE
BICOLORABLE

hide comments
shamimice03: 2017-09-16 21:50:15

how to solve it?


Added by:Nikola P Borisov
Date:2009-02-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO