#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define DEB 0

int edge[128][128];
int vertex[128];
int used[128];
set<int> st;

void dfs(int node){
  used[node] = 1;
  for(int i=1; i<128; i++){
    if( edge[node][i] && !used[i] ){
      dfs(i);
    }
  }
}

int main(){
  int a,b;
  while(~scanf("%d%d",&a,&b)){
    if( a==0 && b==0 ){
      bool f = true;
      int cnt = 0;
      dfs(1);
      set<int>::iterator it;
      for(it=st.begin(); it!=st.end(); it++){
	if( used[*it]==0 ){
	  f = false; break;
	}else{
	  if( vertex[*it]%2 ){
	    cnt++;
	  }
	}
      }
      if( f ){
	if( !(cnt==2 && vertex[1]%2 && vertex[2]%2) ){
	  f = false;
	}
      }
      puts(f ? "OK" : "NG");
      
      
      memset(used,0,sizeof(used));
      memset(vertex,0,sizeof(vertex));
      memset(edge,0,sizeof(edge));
      st.clear();
    }else{
      edge[a][b] = edge[b][a] = 1;
      vertex[a]++; vertex[b]++;
      st.insert(a);
      st.insert(b);
    }
  }
  return 0;
}