#include <iostream>
#include <vector>


typedef std::pair<int,int> edge;

void init(int* count)
{
	for (int i=0; i<101; i++) count[i] = 0;
}

void init(bool* visited)
{
	for (int i=0; i<101; i++) visited[i] = false;
}


bool DFS(std::vector<edge> edge_list, int* count, bool* visited, int v)
{
	for (std::vector<edge>::iterator it = edge_list.begin(); it != edge_list.end(); ++it) {
		if ( (*it).first == v) {
			int u = (*it).second;
			if ( !visited[u] ) {
				visited[u] = true;
				DFS(edge_list, count, visited, u);
			}
		} else if ( (*it).second == v ) {
			int u = (*it).first;
			if ( !visited[u] ) {
				visited[u] = true;
				DFS(edge_list, count, visited, u);
			}
		}
	}
	
	for (int i=1; i<101; i++) {
		if (count[i]>0 && !visited[i]) return false;
	}
	
	return true;
}

int main()
{
	int count[101];
	std::vector<edge> edge_list;
	bool visited[101];
	
	for (int i=0; i<50; i++) {
		
		init(count);
		edge_list.clear();
		
		int a,b;
		do {
			std::cin >> a >> b;
			count[a]++; count[b]++;
			edge_list.push_back( edge(a,b) );
		} while (a>0 || b>0);
		
		if (count[1] == 0) continue;
		
		// check if Eulerian
		bool eulerian = true;
		if ((count[1] & 1) == 1 && (count[2] & 1) == 1) {
			for (int j=3; j<=100; j++) {
				if ( (count[j] & 1) == 1 ) { eulerian = false; break; }
			}
		}
		else {
			eulerian = false;
		}
		
		// check connectivity
		init(visited);
		visited[1] = true;
		bool connected = DFS(edge_list, count, visited, 1);
		if (eulerian && connected) std::cout << "OK" << std::endl;
		else std::cout << "NG" << std::endl;
		
	}
	
	return 0;
}
