#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool calc (int *x) {
	if(x[1] % 2 == 0 || x[2] % 2 == 0) return false;
	int i = 3;
	while(x[i]) {
		if(x[i] % 2 != 0) return false;
		i++;
	}
	return true;
}
int main() {
	int a, b;
	int x[110] = {};
	while(cin >> a >> b) {
		if(!(a || b)) {
			if(calc(x)) cout << "OK" << endl;
			else cout << "NG" << endl;
			rep(i,110) x[i] = 0;
		} else {
			x[a]++, x[b]++;
		}
	}
	return 0;
}