#include <iostream>
#include <map>
#include <cstring>
using namespace std;

const int size = 208;
int G[size][size];
int C[size];
map <int, int> M;
int M_index;
bool flag;

void set_index( int a ) 
{
  if ( M.find( a ) != M.end() ) return;
  M[a] = M_index; 
  M_index++;
}

void init()
{
  memset( G, 0, sizeof(G) );
  memset( C, 0, sizeof(C) );
  M.clear();
  flag = false;
}

int main( void ) 
{
  int a, b;
  flag = true;
  while ( cin >> a >> b ) {
    if ( a == 0 && b == 0 ) {
      for ( int i = 0; i < size; i++ ) {
        for ( int j = 0; j < size; j++ ) {
          if ( G[i][j] > 0 ) C[i] += G[i][j];
        }
      }
      bool ok = true;
      int start = M[1], goal = M[2];
      for ( int i = 0; i < size; i++ ) {
        if ( !C[i] ) continue;
        if ( i == start || i == goal ) {
          if ( C[i] % 2 == 0 ) ok = false;
        } else {
          if ( C[i] % 2 != 0 ) ok = false;
        }
      }
      // output
      cout << ( ok ? "OK" : "NG" ) << endl;
      flag = true;
    } else {
      if ( flag ) {
        init();
      }
      set_index( a );
      set_index( b );
      int index_a = M[a], index_b = M[b];
      G[index_a][index_b]++;
      G[index_b][index_a]++;
    }
  }
  return 0;
}