#include <iostream>
#define CROSS 101
using namespace std;


int main() {
  int a, b;
  int data[CROSS][CROSS];
  int initFlag = true;
  while(cin >> a >> b) {
    if(initFlag) {
      for(int i = 0; i < CROSS; i++) {
	for(int j = 0; j < CROSS; j++) {
	  data[i][j] = 0;
	}
      }
      initFlag = false;
    }

    if(a == 0 && b == 0) {
      bool ok = true;
      for(int i = 0; i < CROSS; i++) {
	int num = 0;
	for(int j = 0; j < CROSS; j++) {
	  num += data[i][j];
	}
	if(i == 1 || i == 2) {
	  if(num % 2 == 0) {
	    ok = false;
	    break;
	  }
	} else {
	  if(num % 2 != 0) {
	    ok = false;
	    break;
	  }
	}
      }
      if(ok) {
	cout << "OK" << endl;
      } else {
	cout << "NG" << endl;
      }
      initFlag = true;
    } else {
      data[a][b]++;
      data[b][a]++;
    }
  }
}