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

vector<vector<int> > vec(101);
int n;

int main(){
	int a,b;
	while(cin>>a>>b){
		rep(i,101)vec[i].clear();
		vec[a-1].push_back(b-1);
		vec[b-1].push_back(a-1);
		while(cin>>a>>b,a||b){
			vec[a-1].push_back(b-1);
			vec[b-1].push_back(a-1);
		}
		int sum=0;
		bool check,tmp=false;
		if(vec[0].size()%2!=0 && vec[1].size()%2!=0)check=true;
		else if(vec[0].size()%2==0 && vec[1].size()%2==0)check=false;
		else tmp=true;
		rep(i,101)if(vec[i].size()%2==1)sum++;
		if(tmp)cout<<"NG"<<endl;
		else if(check){
			if(sum==2)cout<<"OK"<<endl;
			else cout<<"NG"<<endl;
		}else{
			if(sum==0)cout<<"OK"<<endl;
			else cout<<"NG"<<endl;
		}
	}
	return 0;
}