#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 100;
int N;
int ioNum[MAXN];

bool isOK() {
  int odd = 0;
  int pos[2] = {0, 0};
  for(int i = 0; i < N; ++i) {
    if(ioNum[i] % 2) {
      if(odd == 2) return false;
      pos[odd++] = i;
    }
  }
  return pos[0] + pos[1] == 1;
}

int main() {
  while(1) {
    fill(ioNum, ioNum+MAXN, 0);
    N = 0;
    while(1) {
      int a, b;
      if(cin >> a >> b) ; else return 0;
      if(a == 0 && b == 0) break;
      N = max(N, max(a, b));
      --a; --b;
      ++ioNum[a];
      ++ioNum[b];
    }
    if(isOK()) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
  return 0;
}