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

const int MAX_NODE = 100;

int main() {
	int nodes[MAX_NODE + 1];
	int last = 0, from, to;
	memset(nodes, 0, sizeof(nodes));
	
	while (cin >> from >> to) {
	  if (from == 0 && to == 0) {
	    bool check=true;
	    if(nodes[1]%2!=1 || nodes[2]%2!=1)
	      check=false;
	    for(int i=3;i<last;i++)
	      {
		if(nodes[i]%2!=0)
		  check=false;
	      }
	    /* output the answerer */
	    if(check)
	      cout<<"OK"<<endl;
	    else
	      cout<<"NG"<<endl;
	  }
	  else {
	    /* update the `nodes` */
	    nodes[from]++;
	    nodes[to]++;
	    last = max(max(from,to),last);
	  }
	}
	return 0;
}