#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int way[101][101];
int n;

bool dfs(int now){
	if(now==1){
		bool check=true;
		rep(i,n)rep(j,n)if(way[i][j]!=0)check=false;
		if(check)return true;
		else return false;
	}
	bool hoge;
	rep(i,50){
		if(way[now][i]>0){
			way[now][i]--;
			way[i][now]--;
			hoge=dfs(i);
			way[now][i]++;
			way[i][now]++;
			if(hoge)return true;
		}
	}
	return false;
}

int main(){
	int a,b;
	while(cin>>a>>b){
		rep(i,101){
			n=max(a,b);
			rep(j,101)way[i][j]=0;
		}
		way[a-1][b-1]++;
		way[b-1][a-1]++;
		while(cin>>a>>b,a||b){way[a-1][b-1]++;way[b-1][a-1]++;n=max(n,max(a,b));}
		if(dfs(0))cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
	return 0;
}