#include<stdio.h>
int main(){
	int u,v,i,f;
	int a[102] = {0};
	for(;scanf("%d%d",&u,&v);)
		if(!u|v){
			f=1;
			if((a[1]*a[2])%2)f=0;
			
			for(i=3;i<102;)a[i++]%2?f=0:0;
			
			puts(f?"OK":"NG");
			for(i=0;i<102;)a[i++]=0;
		}else a[u]++,a[v]++;
}