#include <iostream>
using namespace std;

const int nmax = 101;

int move(int area[nmax][nmax], int i, int count){
	int num = 0;
	if(i == 2 && count == 0){
		return 1;
	}else if(count == 0){
		return 0;
	}
	for(int j = 1; j < nmax; j++){
		if(area[i][j]){
			area[i][j]--;
			area[j][i]--;
			count--;
			num += move(area, j, count);
			count++;
			area[i][j]++;
			area[j][i]++;
		}
	}
	return num;
}

int main(){
	int area[nmax][nmax];
	int a, b;
	while(cin >> a >> b){
		for(int i = 1; i < nmax; i++){
			for(int j = 1; j < nmax; j++){
				area[i][j] = 0;
			}
		}
		int count = 0;
		do{
			if(a == 0 && b == 0) break;
			area[a][b]++;
			area[b][a]++;
			count++;
		}while(cin >> a >> b);
		if(move(area, 1, count)) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}