#include <iostream>
using namespace std;

int edge[100][100];
int a, b;
int now;

void initialize(){
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			edge[i][j] = 0;
		}
	}
	now = 1;
}

bool isEmpty(){
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if(edge[i][j] > 0) return false;
		}
	}
	return true;
}

bool answer(int now){
	if(now == 2 && isEmpty()) return true;
	for (int i = 0; i < 100; i++) {
		if(edge[now][i] > 0){
			edge[now][i]--;
			edge[i][now]--;
			if(answer(i)) return true;
			edge[now][i]++;
			edge[i][now]++;
		}
	}

	return false;
}

int main(){
	initialize();
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			if(answer(now)){
				cout << "OK" << endl;
			}else {
				cout << "NG" << endl;
			}
			initialize();
		}else{
			edge[a][b]++;
			edge[b][a]++;
		}
	}

	return 0;
}