#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    int f[101]={0},x=0;
    for(int i=0;;i++){
      if(i!=0) cin >>n>>m;
      if(n == 0 && m == 0) break;
      f[n]++;
      f[m]++;
    }
    for(int i=1; i<101; i++) x+=f[i]%2;
    if(x == 2) cout <<"OK"<<endl;
    else cout <<"NG"<<endl;
  }
  return 0;
}