#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()
namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;

unordered_map <pair <int, int>, int> usedEdge;
unordered_map <int, int> pear;
//数字から何番目の頂点
unordered_map <int, int> berry;
//頂点数から元の番号
int allEdge = 0;
int allVertex = 1;

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

void add(int a, int b, vector <vector <int>>& G) {
	if (a == 0 || a == 1) {
		//0 = start, 1 = goalなので、新たに番号に頂点を割り振る必要はない
	} else if (pear[a] == 0) {
		//その番号にまだ頂点が割り振られていない場合
		pear[a] = allVertex;
		berry[allVertex] = a;
		allVertex++;
		G.push_back(vector <int> ());
	}
	if (b == 0 || b == 1) {
		//0 = start, 1 = goalなので、新たに番号に頂点を割り振る必要はない
	} else if (pear[b] == 0) {
		//その番号にまだ頂点が割り振られていない場合
		pear[b] = allVertex;
		berry[allVertex - 1] = b;
		allVertex++;
		G.push_back(vector <int> ());
	}
	G[pear[a] - 1].push_back(pear[b] - 1);
	G[pear[b] - 1].push_back(pear[a] - 1);
	usedEdge[make_pair(a, b)]++;
	usedEdge[make_pair(b, a)]++;
	allEdge += 1;
	return;
}

signed main () {
	int a, b;
	while(cin >> a >> b) {
		usedEdge = unordered_map <pair <int, int>, int> ();
		pear = unordered_map <int, int> ();
		berry = unordered_map <int, int> ();
		vector <vector <int>> G(2);
		allEdge = 0;
		allVertex = 3;
		//pear[in] = i + 1個目の頂点
		pear[0] = 1, pear[1] = 2;
		//berry[i個目の頂点] = berry[in]
		berry[0] = 0, berry[1] = 1;
		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;
}
