#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

vector<int>E[100];
bool used[100];
int Max;
map<pair<int, int>, bool>mp;

bool dfs(int x) {
	if (x == 1) {
		bool f = true;
		rep(i, Max) {
			f &= used[i]; if (!f)break;
		}
		if (f)return true;
	}
	for (int i : E[x]) {
		if (!mp[make_pair(min(i,x),max(i,x))]) {
			mp[make_pair(min(i, x), max(i, x))] = true;
			bool f = used[i];
			used[i] = true;
			if (dfs(i))return true;
			mp[make_pair(min(i, x), max(i, x))] = false;
			used[i] = f;
		}
	}
}
int main() {
	while (1) {
		rep(i, 100)E[i].clear();
		Max = 0;
		memset(used, 0, sizeof(used));
		int a, b;
		while (1) {
			if (!~scanf("%d%d", &a, &b))return 0;
			if (!a)break;
			Max = max(Max, a); Max = max(Max, b);
			a--; b--;
			E[a].push_back(b);
			E[b].push_back(a);
		}
		used[0] = true;
		puts(dfs(0) ? "OK" : "NG");
	}
}