module AOJ_Volume0086;

import std.stdio,std.string,std.conv;

int main()
{
	while(true)
	{
		bool flag = false;
		int x[102];
		foreach(i;0..102)
		{
			x[i] = 0;
		}
		string s;
		while((s = readln.chomp).length != 0)
		{
			flag = true;
			string[] _s = s.split(" ");
			int a = _s[0].to!int;
			int b = _s[1].to!int;
			if(a == 0 && b == 0)
			{
				break;
			}
			else
			{
				x[a]++;
				x[b]++;
			}
		}

		if(flag)
		{
			int count = 0;
			foreach(i;0..102)
			{
				if(x[i]%2 == 1) count++;
			}
			
			if(count == 2)
			{
				if(x[1]%2 == 1 && x[2]%2 == 1)
				{
					writeln("OK");
				}
				else
				{
					writeln("NG");
				}
			}
			else
			{
				writeln("NG");
			}
		}
		else
		{
			break;
		}
	}
	return 0;
}