#include <iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main() {
	int tmp[1000] = {0};
	int a, b;
	while (1) {
		if (cin >> a >> b == NULL)
			break;
		if (!a && !b) {
			bool flag = true;
			if (!(tmp[0] == 1 && tmp[1] == 1))
				flag = false;
			FOR(i,2,1000) {
				if (tmp[i] % 2 != 0)
					flag = false;
			}
			if (flag)
				cout << "OK" << endl;
			else
				cout << "NG" << endl;
			REP(i,1000)
				tmp[i] = 0;
			continue;
		}
		++tmp[a-1]; ++tmp[b-1];
	}
	return 0;
}