#include <algorithm> // sort ?????????
#include <string> // string (?????????) ?????????
#include<iostream>
using namespace std;
int N[128] = { 0 },a,b;
bool ok() {
	if (N[1] % 2 == 0)return false;
	if (N[2] % 2 == 0)return false;
	for (int i = 3; i < 128; i++) {
		if (N[i] % 2 == 1)return false;
	}
	return true;
}
int main() {
	while (cin >> a >> b) {
		N[a] += 1;
		N[b] += 1;
		if (a == 0 && b == 0) {
			if (ok)cout << "OK" << endl;
			else cout << "NG" << endl;
			for (int i = 0; i < 128; i++)N[i] = 0;
		}
	}
	return 0;
}