#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int N = 1000;

bool solve(int cnt[N]){
  if(cnt[1] % 2 == 0) return false;
  if(cnt[2] % 2 == 0) return false;
  FOR(i, 3, N) if(cnt[i] % 2) return false;
  return true;
}
int main() {
  int a, b;
  int cnt[N];
  memset(cnt, 0, sizeof(cnt));
  while(scanf("%d %d", &a, &b) != EOF){
    cnt[a]++;
    cnt[b]++;
    if(a == 0 && b == 0){
      cout <<(solve(cnt) ? "OK" : "NG") <<endl;
      memset(cnt, 0, sizeof(cnt));
    }
  }

  return 0;
}