#include <iostream>
using namespace std;

int main(){
  int a,b,c[101];
  for(int i=0;i<101;i++) c[i] = 0;
  while(cin >> a >> b){
    if(a != 0 || b != 0){
      c[a]++;
      c[b]++;
    }
    else{
      string ans = "OK";
      if(c[1] != 1 || c[2] != 1) ans = "NG";
      else{
	for(int i=3;i<101;i++){
	  if(c[i] % 2 == 1){
	    ans = "NG";
	    break;
	  }
	}
      }
      cout << ans << endl;
      for(int i=0;i<101;i++) c[i] = 0;
    }
  }
  return 0;
}