#include <iostream>
#define CROSS_MAX 100
using namespace std;

int main() {
  int a, b;
  int data[CROSS_MAX][CROSS_MAX];
  for(int i = 0; i < CROSS_MAX; i++) {
    for(int j = 0; j < CROSS_MAX; j++) {
      data[i][j] = 0;
    }
  }
  while(cin >> a >> b) {
    if(a == 0 && b == 0) {
      bool flag = true;
      for(int i = 0; i < CROSS_MAX; i++) {
	int count = 0;
	for(int j = 0; j < CROSS_MAX; j++) {
	  count += data[i][j];
	}
	if(i == 0 && count % 2 == 0 || i == 1 && count % 2 == 0) flag = false;
	if(i != 0 && i != 1 && count % 2 != 0) flag = false;
      }
      if(flag) cout << "OK" << endl;
      else     cout << "NG" << endl;

      for(int i = 0; i < CROSS_MAX; i++) {
	for(int j = 0; j < CROSS_MAX; j++) {
	  data[i][j] = 0;
	}
      }
    } else {
      data[a-1][b-1]++;
      data[b-1][a-1]++;
    }
  }
  return 0;
}