#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int x,y,c[110];

int main(){
  while(~scanf("%d %d",&x,&y)){
    if(x==0&&y==0){
      int check;
      check=0;
      for (int i = 1;i<110;i++){
	if(c[i]==0){
	  i=110;
	}
	if(c[i]%2==1){
	  check++; 
	}
	if(check==3){
	  printf("NG\n");
	  i=110;
	}	
      }
      if(check==1){
	printf("NG\n");
      }
      if(check%2==0){
	printf("OK\n");
      }
      
      for(int j=0;j<110;j++){
	c[j]=0;
      }
    }
    c[x]++;
    c[y]++;
  }  
}