#include<iostream>
#include<set>
using namespace std;
int main(){
  set<int>way;
  int a,b;
  while(cin>>a>>b){
    if(!a){
      if(way.empty())cout<<"OK"<<endl;else cout<<"NG"<<endl;
      set<int>way;
      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;
}