#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;

map <pair <int, int>, int> usedEdge;
int allEdge = 0;

bool dfs(int now, int cntEdge, vector <vector <int>>& G) {
	//dfsでゴール(頂点1)に到達した時に、すべての辺を通っていたらtrueを返す
	bool flag = false;
	if (now == 1) return flag || cntEdge == allEdge;
	rep (i, G[now].size()) {
		//used処理
		if (usedEdge[make_pair(now, G[now][i])] == 0 || usedEdge[make_pair(G[now][i], now)] == 0)
			continue;
		usedEdge[make_pair(now, G[now][i])]--;
		usedEdge[make_pair(G[now][i], now)]--;
		flag = dfs(G[now][i], cntEdge + 1, G) || flag;
		usedEdge[make_pair(now, G[now][i])]++;
		usedEdge[make_pair(G[now][i], now)]++;
	}
	return flag;
}

void add(int a, int b, vector <vector <int>>& G) {
	if (a >= G.size()) G.push_back(vector <int> (0));
	if (b >= G.size()) G.push_back(vector <int> (0));
	G[a].push_back(b);
	G[b].push_back(a);
	usedEdge[make_pair(a, b)]++;
	usedEdge[make_pair(b, a)]++;
	allEdge += 1;
	return;
}

signed main () {
	int a, b;
	while(cin >> a >> b) {
		vector <vector <int>> G(2);
		add(a - 1, b - 1, G);
		while(cin >> a >> b, a) {
			add(a - 1, b - 1, G);
		}
		cout << (dfs(0, 0, G) ? "OK" : "NG") << endl;
	}
	return 0;
}
