#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
vector<int> node[105];

void init (void )
{
	rep (i, 105 ) node[i].clear();
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.patrol", "r", stdin );
	init ();
	int from, to;
	int max_node = 0;
	while (	scanf ("%d %d", &from, &to )!= EOF ){
		if (from == 0 && to == 0 ){
			bool ok = true;
			if ((node[1].size() % 2 == 0 ) || (node[2].size() % 2 == 0 ) ){
 				ok = false;
			}else{
				for (int i = 3; i <= max_node; i++ ){
					if (node[i].size() % 2 != 0 ){
						ok = false;
						break;
					} // end if
				} // end for
			} // end if

			if (ok ){
				cout << "OK" << endl;
			}else{
				cout << "NG" << endl;
			} // end if
			
			init ();
			max_node = 0;
		}else{
			node[from].push_back (to );
			node[to].push_back (from );	
			max_node = max (max_node, from );
			max_node = max (max_node, to );
		} // end if
	} // end loop
		
	return 0;
}