#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{	
	int a, b, m = 0;
	bool f[100];

	memset(f, 0, sizeof(f));

	while (cin >> a >> b) {
		if (a > 0 || b > 0) {
			m = max({ m, a, b });
			f[a - 1] = !f[a - 1];
			f[b - 1] = !f[b - 1];
		}
		else {
			bool g = 1;

			if (f[0] && f[1]) {
				for (int i = 2; i < m; i++) {
					if (f[i]) {
						g = 0;
						break;
					}
				}
			}
			else
				g = 0;

			if (g)
				cout << "OK" << endl;
			else
				cout << "NG" << endl;

			memset(f, 0, sizeof(f));
			m = 0;
		}
	}

	return 0;
}

