#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];
int a, b;

int main(){
	while (cin >> a >> b){
		int s, g;
		if (a + b != 0){
			if (a == 1 || b == 1 || b == 2 || a == 2){
				if (a == 1)s = b;
				if (b == 1)s = a;
				if (a == 2)g = b;
				if (b == 2)g = a;
				continue;
			}
			cross[a]++;
			cross[b]++;
		}
		else{
			bool f = 1;
			if (cross[s] % 2 != 1 || cross[g] % 2 != 1)f = 0;
			for (int i = 3; i < 110; i++){
				//cout << cross[i] << endl;
				if (i == s || i == g){
					cross[i] = 0;
					continue;
				}
				if (cross[i] % 2 == 1)f = 0;
				cross[i] = 0;
			}
			f ? cout << "OK\n" : cout << "NG\n";
		}
	}
}