import std.stdio : write, writeln;
import std.array;
import std.range;
import std.algorithm : filter;

/+ やばいオーダー
bool[100+1][100+1] g;
bool[100+1][100+1] done;
int L;

bool dfs(int e, int n){
	if(n==L){
		return e==2;
	}
	
	bool f=false;
	for(int i=1; i<=100; ++i){
		if(g[e][i] && !done[e][i]){
			done[e][i] = true;
			f |= dfs(i, n+1);
			done[e][i] = false;
		}
	}
	
	return f;
}
+/

void main(){
	while(hasNext){
		// 一筆書き->オイラー路->準オイラーグラフ
		int[100+1] g;
		
		while(true){
			int s = next!int();
			int e = next!int();
			
			if((s|e)==0x00) break;
			
			++g[s];
			++g[e];
		}
		
		int cnt;
		for(int i=1; i<=100; ++i){
			if(g[i]%2==1){
				++cnt;
			}
		}
		
		writeln = cnt==2 ? "OK" : "NG";
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}