#include <cstdio>
#include <vector>
using namespace std;

int cnt[100000];

int main () {
  while (1) {
    for (int i=0; i<100000; i++) {
      cnt[i] = 0;
    }

    while (1) {
      int a, b;
      if (scanf("%d%d", &a, &b) != 2) return 0;
      if (a == 0 && b == 0) break;
      --a;
      --b;
      cnt[a]++;
      cnt[b]++;
    }
  
    if (cnt[0]%2 != 1) puts("NG");
    else if (cnt[1]%2 != 1) puts("NG");
    else {
      bool found = false;

      for (int i=2; i<100000; i++) {
        if (cnt[i]%2 != 0) {
          puts("NG");
          found = true;
          break;
        }
      }
  
      if (!found) puts("OK");
    }
  }
}