#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> edge[111];
int used[111][111];
int main(void){
  int a,b;
  while(cin >> a >> b){
    for(int i = 1; i <= 100; i++) edge[i].clear();
    memset(used,0,sizeof(used));
    int n = 1;
    used[a][b]++; 
    used[b][a]++; 
    edge[a].push_back(b);
    edge[b].push_back(a);
    while(cin >> a >> b && a){
      n++;
      used[a][b]++; 
      used[b][a]++; 
      edge[a].push_back(b);
      edge[b].push_back(a);
    }
    int p = 1;
    bool f;
    for(int i = 0; i < n; i++){
      f = true;
      for(int j = 0; j < (int)edge[p].size(); j++){
	if(used[p][edge[p][j]]){
	  f = false;
	  used[p][edge[p][j]]--;
	  used[edge[p][j]][p]--;
	  p = edge[p][j];
	  break;
	}
      }
      if(f) break;
    }
    cout << ((f&&p!=2)?"NG":"OK") << endl;
  }
}