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

int main() {
  int a, b;
  int n;
  int deg[200] = {};

  while (cin >> a >> b) {
    if (a == 0 && b == 0) {
      bool f = true;
      for (int i = 0; i < n; ++i) {
        if (deg[i] & 1 && i < 2 || deg[i] >= 3) continue;
        f = false;
        deg[i] = 0;
      }
      cout << (f ? "OK" : "NG") << endl;
    }

    n = max({n, a, b});
    a--;
    b--;
    deg[a]++;
    deg[b]++;
  }
}