#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int judge(vector<int> &a, int k)
{
	for (int i = 2; i < k; ++i) {
		if (a[i] % 2 == 1) {
			return 1;
			break;
		}
	}
	return 0;
}
int main()
{
	vector<int> a;
	int aa, bb;
	while (1) {
		int size = 0;
		a.reserve(100);
		while (cin >> aa && cin >> bb && aa != 0 && bb != 0) {
			if (aa > size || bb > size) {
				for (int i = 0; i < max(aa, bb) - size; ++i) a.push_back(0);
				size = a.size();
			}
			a[aa - 1] += 1;
			a[bb - 1] += 1;
		}
		if (a[0] % 2 == 1 && a[1] % 2 == 1 && judge(a, a.size()) == 0) printf("%s", "OK");
		else printf("%s", "NG");
		for (int i = 0; i < size; ++i) a.pop_back();
	}
}