#include<iostream>
using namespace std;

int main() {
	int a, b;
	while (cin >> a >> b) {
		int c, d;
		int ve[1000] = {};

		ve[a - 1]++;
		ve[b - 1]++;

		while (cin >> c >> d, c, d) {
		ve[c - 1]++;
		ve[d - 1]++;
		}

		int ca = 0;

		for (int i = 0;i < 1000;i++) {
			if (ve[i] % 2 != 0)ca++;
		}

		if (ca >= 4)cout << "NG" << endl;
		else if (ca == 2 && (ve[0] % 2 != 1 || ve[1] % 2 != 1))cout << "NG" << endl;
		else if (ca == 0)cout << "NG" << endl;
		else cout << "OK" << endl;
	}
	return 0;
}