#include<iostream>
using namespace std;

int cross[101] = {};

bool ok() {
	for (int i = 1; i <= 100; i++) {
		if (cross[i] / 2 == 1) return false;
	}
	return true;
}

int main() {
	int a, b;
	while (cin >> a >> b) {
		cross[a]++;
		cross[b]++;
		if (a == 0) {
			if (ok()) cout << "OK" << endl;
			else cout << "NG" << endl;
			for (int i = 0; i<256; i++) cross[i] = 0;
		}
	}
	return 0;

}