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

int map[101][101];

bool solve(int map[][101]){
	int a, b, c;
	a=b=c=0;
	for(int i=1; i<=100; i++){
		a+=map[1][i];//?§????????????????
		b+=map[2][i];//??????????????????
	}
	if(!(a%2)||!(b%2))return false;//??¶??°?????£???????????????

	for(int i=3; i<=100; i++){
		for(int j=1; j<=100; j++){
			c+=map[i][j];//?§???????????????\???????????????
		}
		if(c%2)return false;//?\???°???????????????
		c=0;
	}
	return true;
}

int main(){
	int a, b;

	while(1){
		fill(&map[0][0], &map[101][101], 0);
		while(cin>>a>>b, a||b){
			map[a][b]++;
			map[b][a]++;
		}
		if(cin.eof())break;
		solve(map) ? cout<<"OK\n" : cout<<"NG\n";
	}
	return 0;
}