#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

void solve()
{
	int a, b;
	while (cin >> a >> b)
	{
		map<int, int> Map;
		Map[a]++;
		Map[b]++;
		int c, d;
		while (cin >> c >> d)
		{
			if (c == 0 && d == 0)
			{
				map<int, int>::iterator it = Map.begin();
				while (it != Map.end())
				{
					if (it->first != 1 && it->first != 2 && it->second % 2 == 1)
					{
						cout << "NG" << endl;
						goto END;
					}
					++it;
				}
				break;
			}
			Map[c]++;
			Map[d]++;
		}
		cout << "OK" << endl;
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}