#include <iostream>
using namespace std;

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : route( 0 ), prev( NULL ), next( NULL ){}

	int route;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = mSize; i > 0; --i ){
			tCell* it = tail->prev;
			it->prev->next = it->next;
			it->next->prev = it->prev;
			SAFE_DELETE( it );
		}
		mSize = 0;
	}

	void alloc( int n ){
		if ( n <= mSize ) return;
		while ( n != mSize ) pushBack();
	}
	void pushBack(){
		tCell* it = new tCell;
		it->prev = tail->prev;
		it->next = tail;
		it->prev->next = it;
		it->next->prev = it;
		++mSize;
	}
	int size(){ return mSize; }

	int& operator[]( int index ){
		tCell* it = head->next;
		for ( int i = 0; i < index; ++i ){
			it = it->next;
		}
		return it->route;
	}

private:
	int mSize;
	tCell *head, *tail;
};

int main(){
	int a, b;
	MyArray list;

	while ( cin >> a >> b ){
		if ( !a && !b ){
			bool enable = true;
			if ( !( list[ 1 ] % 2 && list[ 2 ] % 2 ) ){
				enable = false;
			}else{
				for ( int i = 3; i <= list.size(); ++i ){
					if ( list[ i ] % 2 ){
						enable = false;
						break;
					}
				}
			}
			cout << ( enable ? "OK" : "NG" ) << endl;

			list.init();
		}else{
			list.alloc( a + 1 );
			list.alloc( b + 1 );
			++list[ a ];
			++list[ b ];
		}
	}
}