#include <iostream>
using namespace std;

int main(){
	int u,v;
	int a[102] = {0};
	
	while( cin >> u >> v ){
		if( u == 0 && v == 0 ){
			int k=0;
			for(int i=1 ; i <= 101 ; i++ ){
				if( a[i]%2 == 1 ) k++;
			}
			cout << (( k == 0 || k == 2 )? "OK" : "NG" ) << endl;
			for(int i=0 ; i <= 101 ; i++ )
				a[i] = 0;
		}else{
			a[u]++;
			a[v]++;
		}
	}
}