
import std.stdio, std.array;

void main() {
  while(true) {
    int[int] field;
    bool ans = true;
    for(int n, m; readf("%d %d\n", &n, &m), n + m != 0;) {
      field[n]++;
      field[m]++;
    }
    if(stdin.eof) break;

    int odd = 0;
    foreach(int x, int count; field) {
      if ((count & 1) == 1) odd++;
      if ((count & 1) == 1 && odd > 2) {ans = false; break;}
    }
    if (odd == 1) ans = false;

    writeln(ans ? "OK" : "NG");
  }
}