#include <vector>
#include <iostream>
#include <stdlib.h>
using namespace std;
class Graph
{
public:
Graph(int vertexCnt)
{
m_vertexCnt = vertexCnt;
int edges;
cin >> edges;
m_relations = new bool*[m_vertexCnt];
for (int i = 0; i < m_vertexCnt; ++i)
m_relations[i] = (bool*)calloc(m_vertexCnt, sizeof(bool));
int a, b;
for (int i = 0; i < edges; ++i)
{
cin >> a >> b;
m_relations[a][b] = m_relations[b][a] = true;
}
}
~Graph()
{
for (int i = 0; i < m_vertexCnt; ++i)
free(m_relations[i]);
delete[] m_relations;
}
enum Color_t
{
NO_COLOR = 0,
RED,
BLACK
};
bool IsBicolorable()
{
Color_t* vertexes = (Color_t*)calloc(m_vertexCnt, sizeof(Color_t));
bool result = CheckIsBicolorable(vertexes);
free(vertexes);
return result;
}
private:
bool CheckIsBicolorable(Color_t* vertexes)
{
size_t processedCnt = 0;
vector<int> vertexCol;
vertexCol.push_back(0);
vertexes[0] = RED;
while(processedCnt < vertexCol.size())
{
int currentVertex = vertexCol[processedCnt];
for (int i = 0; i < m_vertexCnt; ++i)
{
if (m_relations[currentVertex][i])
{
if (vertexes[i] == NO_COLOR)
{
vertexes[i] = GetOppositeColor(vertexes[currentVertex]);
vertexCol.push_back(i);
}
else if (vertexes[i] == vertexes[currentVertex])
return false;
}
}
++processedCnt;
}
return true;
}
static Color_t GetOppositeColor(Color_t color)
{
if (color == RED)
return BLACK;
return RED;
}
private:
int m_vertexCnt;
bool** m_relations;
};
static void Test()
{
int vertexCnt;
while(true)
{
cin >> vertexCnt;
if (vertexCnt <= 0)
return;
Graph graph(vertexCnt);
if (graph.IsBicolorable())
cout << "BICOLORABLE." << endl;
else
cout << "NOT BICOLORABLE." << endl;
}
}
int main(int argc, char* argv[])
{
Test();
return 0;
}