#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int a, b;
map<int, int> m;

void calc()
{
	if (!(m[1] % 2 == 1 && m[2] % 2 == 1))
	{
		cout << "NG" << endl;
		m.clear();
		return;
	}
	
	m[1] = m[2] = 2;	//2の倍数にする

	bool flag = true;	//最終的にtrueなら条件を満たす
	for (map<int, int>::iterator it=m.begin(); it!=m.end(); it++)
	{
		if (it->second % 2 != 0) flag = false;
	}

	m.clear();

	if (flag)
	{
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}

	return;
}

int main()
{
	while (cin >> a >> b)
	{
		if (a == 0 && b == 0)
		{
			calc();
			continue;
		}
		m[a]++;
		m[b]++;
	}
	
	return 0;
}