#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;


int main(){
  int a,b,index;
  int INDEX[200];
  vector< vector<int> > vec;
  map<int,bool> exist;
  vec.clear();
  vec.reserve(200);
  exist.clear();
  index = 0;

  while(cin >> a >> b){
    if(!(a|b)){
      //cout << "-----------" << endl;
      bool OK=true;
      for(int i=0;i<index;i++){
	//cout << "INDEX[i] = " << INDEX[i] << ", size = " << vec[INDEX[i]].size() << endl;
	if(INDEX[i] == 1 || INDEX[i] == 2){
	  if(vec[INDEX[i]].size() == 1 || vec[INDEX[i]].size()%2 == 0)continue;
	  else {
	    OK = false;
	    break;
	  }
	}
	else{
	  if(vec[INDEX[i]].size()%2 == 0)continue;
	  else {
	    OK = false;
	    break;
	  }
	}
      }
      if(OK)cout << "OK" << endl;
      else cout << "NG" << endl;
  

      vec.clear();
      exist.clear();
      index = 0;

    }
    vec[a].push_back(b);
    vec[b].push_back(a);
    if(!exist[a]){
      INDEX[index] = a;
      index++;
      exist.insert(map<int,bool>::value_type(a,true));
    }    
    if(!exist[b]){
      INDEX[index] = b;
      index++;
      exist[b] = true;
    }
  }
  return 0;
}