#include <iostream>
using namespace std;
int k[256] = {0};
bool ok() {
  if(k[1] % 2 == 0) return false;
  if(k[2] % 2 == 0) return false;
  for(int i=3; i<256; i++) {
    if(k[i] % 2 == 1) return false;
  }
  return true;
}
int main() {
  int a, b;
  while (cin >> a >> b) {
    k[a]++;
    k[b]++;
    if (a == 0) {
      if (ok()) cout << "OK" << endl;
      else cout << "NG" << endl;
      for (int i=0; i<256; i++) k[i] = 0;
    }
  }
}