#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())

////////////////////////////////////////////////////////////

int cnt = 0;
bool ans = 0;

void solve( int now , vector< vector<int> > m , int n ){
	//cout << "now:" << now << " n:" << n << endl;
	
	if( n == 0 && now == 1){
		ans = 1;
		ret;
	}

	if(ans)
		ret;

	rep(i,0,cnt){

		if(m[now][i]){
			m[now][i]--;
			m[i][now]--;
			solve( i , m , n-1 );
			m[now][i]++;
			m[i][now]++;
		} 
	}
}

int main(){
	int tmp;
	while( cin >> tmp ){
		vector< vector<int> > m(110, vector<int> (110,0));
		int tmp2;
		cin >> tmp2;
		tmp--; tmp2--;
		m[tmp][tmp2] += 1;
		m[tmp2][tmp] += 1;
		cnt = 0;
		int a,b;

		while( cin >> a ){
			cin >> b;
			if( a == 0 && b == 0 )
				break;
			a--; b--;
			m[a][b] += 1;
			m[b][a] += 1;
			cnt++;
		}
		cnt++;
		ans = 0;
		solve( 0 , m , cnt ); 

		if(ans)
			P("OK");
		else
			P("NG");
	}


	ret 0;
}

