#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <cstring>
using namespace std;

int cross[100];
int a, b;
bool ans;

int main(void){

	for(int i = 0; i < 100; i++){
		cross[i] = 0;
	}

	while (cin >> a >> b) {
		
		if (a == 0) {

			ans = true;

		if(cross[0] % 2 == 1 && cross[1] % 2 == 1){
			for(int i = 2; i < 100; i++){
				if(cross[i] % 2 == 1){
					ans = false;
				}
			}
		}else{
			ans = false;
		}

		if(ans){
			cout << "OK" << endl;
		}else{
			cout << "NG" << endl;
		}


		for(int i = 0; i < 100; i++){
			cross[i] = 0;
		}

		}else{
			
			cross[a - 1]++;
			cross[b - 1]++;
		}
	}
	
    return 0;
}