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