#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int c[110]={0};
  int a,b;
  while(cin>>a>>b){
    if(a==0){
      bool f = true;
      if(c[1]%2==0||c[2]%2==0) f = false;
      FOR(i,3,110){
        if(c[i]!=0&&c[i]%2==1){
          f = false;
          break;
        }
      }
      if(f) cout<<"OK"<<endl;
      else cout<<"NG"<<endl;
      REP(i,110)c[i]=0;
    }else{
      c[a]++;
      c[b]++;
    }
  }
  return 0;
}