#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> G[101];

void clear(){
	for(int i = 0; i < 101; i++){
		if(G[i].size() != 0)	G[i].clear();
	}
}

int main(void){
	int a, b;
	bool flag = false;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a || b){
			G[a].push_back(b);
			G[b].push_back(a);
		}else{
			for(int i = 1; i < 101; i++){
				if(i != 1 && i != 2 && (G[i].size() != 0) && (G[i].size() % 2 != 0)){
					flag = true;
					break;
				}
			}
			if(flag){
				printf("NG\n");
				clear();
				flag = false;
			}else{
				printf("OK\n");
				clear();
				flag = false;
			}
		}
	}
  return 0;
}