https://vjudge.net/contest/278989#problem/C
#include <cstdio>
#include <string.h>
#include <queue>
using namespace std;
int p[205][205];
int v[205], m, n;
bool c[205];
bool bfs()
{
queue <int> q;
q.push(0);
v[0] = 1;
c[0] = true;
while (!q.empty())
{
int t = q.front();
q.pop();
for (int i = 0; i < n; i++)
{
if (p[t][i])
{
if (!v[i])
{
q.push(i);
v[i] = 1;
c[i] = !c[t];
}
else
{
if (c[i] == c[t])
return false;
}
p[t][i] = 0;
}
}
}
return true;
}
int main()
{
while (scanf("%d", &n) && n != 0)
{
memset(p, 0, sizeof(p));
memset(v, 0, sizeof(v));
memset(c, 0, sizeof(c));
int t1, t2;
scanf("%d", &m);
for (int i = 0; i < m; i++)
{
scanf("%d%d", &t1, &t2);
p[t1][t2] =1;
}
if (bfs())
printf("BICOLORABLE.\n");
else
printf("NOT BICOLORABLE.\n");
}
return 0;
}