#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Info{
	Info(){
		current = 0;
	}

	Info(int arg_current,short map[101][101]){
		current = arg_current;
		for(int i = 0; i < 101; i++){
			for(int k = 0; k < 101; k++)table[i][k] = map[i][k];
		}
	}
	int current;
	short table[101][101];
};

short map[101][101];	//?????????????????????????????¨???????????°<????????°?????¨????????´?????????!!!???>
bool Found;
int start = 1,goal = 2,from,to;
Info tmp;

void bfs(int a, int b){
	for(int i = 1; i <= 100; i++){
		for(int k =1; k <= 100; k++){
			map[i][k] = 0; //i??¨k????????¶????????¬??°????¨??????????????????????
		}
	}

	map[a][b]++;
	map[b][a]++;

	while(true){
		scanf("%d %d",&from,&to);
		if(from == 0 && to == 0)break;

		map[from][to]++;
		map[to][from]++;
	}

	queue<Info> Q;

	Q.push(Info(1,map));	//start??°??????????´?
	Found = false;

	while(!Q.empty()){
		tmp = Q.front();
		Q.pop();

		//??´???????????????????????????
		if(tmp.current == 2){
			//??¨?????????????????£?????????OK
			Found = true;
			for(int i = 1; i <= 100; i++){
				for(int k = 1; k <= 100; k++){
					if(tmp.table[i][k] > 0){ //?°?????????¨???1??¬?????£????????????????????£????????????
						Found = false;
						break;
					}
				}
			}
			if(Found)break;
			else{
				continue;
			}
		}

		for(int k = 1; k <= 100; k++){
			if(tmp.table[tmp.current][k] > 0){ //??????????????´???
				Info newInfo(k,tmp.table);

				newInfo.table[tmp.current][k]--;
				newInfo.table[k][tmp.current]--;
				Q.push(newInfo);
			}
		}
	}

	if(!Found)printf("NG\n");
	else{
		printf("OK\n");
	}
}


int main(){

	int a,b;

	while(scanf("%d %d",&a,&b) != EOF){
		bfs(a,b);
	}

    return 0;
}