#include <iostream>

int main() {
	int map[100][100];
	int a, b;
	int max = 0;
	int sum;
	bool flg;
	
	// Create a map. If Input( 0, 0), check the map.
	while(std::cin >> a >> b) {
		if(!a && !b) {
			// see if We can do one-stroke sketch in the map.
			flg = false;
			for( int i=0; i<max; i++) {
				sum = 0;
				for( int j=0; j<max; j++) sum += map[i][j];
				// If a point is 'Odd Point', we can't do one-stroke sketch in this map.
				if( (sum%2==1 && i>=2) || ( i<2 && sum>1) ) {flg=true; break;}
			}
			std::cout << ( flg ? "NG" : "OK" ) << std::endl;
			// Clear the map.
			for( int i=0; i<10000; i++) map[i/100][i%100] = 0;
			max = 0;
		}else {
			// Connect between two points.
			map[a-1][b-1] ++; map[b-1][a-1] ++;
			if(max<a) max = a; if(max<b) max = b;
		}
	}
}