//39
#include<iostream>
#include<map>

using namespace std;

int main(){
  for(;;){
    map<int,int> c;
    for(int a,b;cin>>a>>b,cin&&(a|b);){
      c[a]++;
      c[b]++;
    }
    if(!cin)return 0;
    map<int,int>::iterator it;
    for(it=c.begin();it!=c.end();it++){
      if(it->first==1 || it->first==2){
	if(it->second%2==0)break;
      }else{
	if(it->second%2!=0)break;
      }
    }
    cout<<((it==c.end())?"OK":"NG")<<endl;
  }
  return 0;
}