#include <iostream>
using namespace std;

#define P 100

int main(void){
  int deg[P+1];
  int a,b;
  
  for (int i=0; i<=P; i++) deg[i]=0;
  while (cin >> a >> b){
    if (a==0 && b==0){
      int ans=1;
      if (deg[1]%2==0 || deg[2]%2==0) ans = 0;
      for (int i=3; i<=100; i++){
        if (deg[i]%2==1) ans = 0;
      }
      cout << (ans?"OK":"NG") << endl;
      // reset
      for (int i=0; i<=P; i++) deg[i]=0;
    } else {
      deg[a]++;
      deg[b]++;
    }
  }
  return 0;
}
