#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b;
  map<int, int> deg;

  while (cin >> a >> b) {
    if (a == 0 && b == 0) {
      bool f = true;
      for (auto p : deg) {
        if (p.first < 2 && ~p.second & 1) f = false;
        if (p.first >= 2 && p.second & 1) f = false;
      }
      cout << (f ? "OK" : "NG") << endl;
      deg.clear();
      continue;
    }

    a--;
    b--;
    deg[a]++;
    deg[b]++;
  }
}