#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

bool check(vector<int> deg) {
	// degree of start and end should be odd
	if (deg[1] % 2 == 0) return false;
	if (deg[2] % 2 == 0) return false;

	// degree of other vertice should be even
	rep2(i, 3, deg.size()) {
		if (deg[i] % 2 != 0) return false;
	}

	return true;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

	int a, b;
	vector<int> deg(1000, 0);

	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			if (check(deg)) {
				cout << "OK" << endl;
			} else {
				cout << "NG" << endl;
			}

			deg.clear();
			deg.resize(1000, 0);

		} else {
			deg[a]++;
			deg[b]++;
		}
	}
}