#include <stdio.h>

#define N 100

int main(void){
	int br[N+1];
	int oddXnum;
	int s,d;
	
	for (int i=1; i<=N; i++) br[i] = 0;
	br[1] = br[2] = 1;
	while (scanf("%d%d",&s,&d)!=EOF){
		if (s==0 && d==0){
			oddXnum = 0;
			for (int i=1; i<=N; i++) oddXnum += br[i]%2;
			puts(oddXnum==0 ? "OK" : "NG");
			for (int i=1; i<=N; i++) br[N] = 0;
			br[1] = br[2] = 1;
		} else {
			br[s]++;
			br[d]++;
		}
	}
	
	return 0;
}	