#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
  int a, b;
  int degree[5000] = {0};
  while (cin >> a, cin >> b) {
    if (a == -1 && b == -1) break;
    degree[a]++;
    degree[b]++;
    if (a == 0) {
      int flg = 0;
      for (int i = 0; i < 5000; i++)
        if (degree[i]%2 && i != 1 && i != 2) flg++;
        else if	(!(degree[i]%2)	&& (i == 1 || i	== 2)) flg++;
      if (flg) cout << "NG" << endl;
      else cout << "OK" << endl;
      memset(degree, 0, sizeof(degree));
    }
  }
  return 0;
}