#include<iostream>
#include<set>
using namespace std;
int main(){
  set<int>way;
  int a,b;
  while(true){
    if(!(cin>>a>>b))break;
    if(!a){
      if(way.empty())cout<<"OK"<<endl;else cout<<"NG"<<endl;
      way.clear();
      continue;
    }
    if(a>2)if(way.find(a)==way.end())way.insert(a);else way.erase(a);
    if(b>2)if(way.find(b)==way.end())way.insert(b);else way.erase(b);
  }
  return 0;
}