#include <stdio.h>

int main() {
	int cross[101];
	
	while(!feof(stdin)) {
		for(int i=0; i<101; i++){
			cross[i] = 0;
		}
		
		while(true) {
			int a,b;
			//if(scanf("%d %d", &a, &b)<=0){return 0;}
			scanf("%d %d", &a, &b);
			if ( a==0 ) {
				if(feof(stdin)){return 0;}
				bool ng = false;
				if ( cross[1]%2 == 1 && cross[2]%2 == 1 ) {
					for(int i=3; i<101; i++) {
						if ( cross[i]%2 == 1 ) {
							ng = true;
							break;
						}
					}
				} else {
					ng = true;
				}
				puts(ng?"NG":"OK");
				break;
			}
			cross[a]++;
			cross[b]++;
		}
	}
}