#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int node,edge;
bool bfs()
{
vector<int>adjlist[1000];
int i;
for(i=0;i<edge;i++)
{
int x,y;
scanf("%d%d",&x,&y);
adjlist[x].push_back(y);
adjlist[y].push_back(x);
}
queue<int>BFS;
int colour[1000],cur=1; //1=white,-1=black
bool visited[1000];
memset(visited,false,sizeof(visited));
BFS.push(0);
visited[0]=true;
colour[0]=1;
while(!BFS.empty())
{ int f=BFS.front();
//cout<<f<<"curnode"<<endl;
cur*=-1;
for(i=0;i<adjlist[f].size();i++)
{ int C=adjlist[f][i];
//cout<<C<<"child"<<endl;
if(visited[C]==true){
if(colour[C]==colour[f])return false;
}
else { visited[C]=true;
BFS.push(C);
colour[C]=colour[f]*-1;
}
}
BFS.pop();
}
return true;
}
int main()
{
while(cin>>node)
{
if(node==0)break;
cin>>edge;
bool bicolour=bfs();
if(bicolour)cout<<"BICOLORABLE."<<endl;
else cout<<"NOT BICOLORABLE."<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন