#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	for(;;){
		map<int, int> deg;
		for(;;){
			int a, b;
			if(scanf("%d%d", &a, &b) == EOF)
				return 0;
			if(a == 0)
				break;
			deg[a]++;
			deg[b]++;
		}

		bool ok = true;
		for(map<int, int>::iterator itr=deg.begin(); itr!=deg.end(); ++itr){
			if(itr->first == 1 || itr->first == 2)
				ok &= itr->second % 2 == 1;
			else
				ok &= itr->second % 2 == 0;
		}
		puts(ok ? "OK" : "NG");
	}
}