#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int cross[110][110];
int a, b;

int main(){
	while (cin >> a >> b){
		if (a + b != 0){
			cross[a][b]++;
			cross[b][a]++;
		}
		else{
			int now = 1;
			bool f = 1;
			while (f){
				for (int i = 3; i < 103; i++){
					if (cross[now][i] > 0){
						cross[now][i]--;
						cross[i][now]--;
						now = i; break;
					}
					if (i == 102)f = 0;
				}
			}
			int co = 0;
			for (int i = 0; i < 103; i++){
				for (int j = i + 1; j < 103; j++){
					if (cross[i][j] == 1)co++;
				}
			}
			if (co==1&&cross[now][2])cout << "OK\n";
			else cout << "NG\n";
			REP(i, 110){
				REP(j, 110){
					cross[i][j] = 0;
				}
			}
		}
	}
}