#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Edge{
public:
	int to;
	bool is_passed;

	Edge() : to(-1), is_passed(false){
		return;
	}
	~Edge(){
		return;
	}
};



int main(int argc, char **argv){
	std::vector<std::vector<Edge> > edges(101);
	int a, b;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> a >> b){
#else
	while(std::cin >> a >> b){
#endif
		if(a == 0 && b == 0){ 
			bool can_patrol = true;

			if(edges[1].size() % 2 == 0){
				can_patrol = false;
			}
			else if(edges[2].size() % 2 == 0){
				can_patrol = false;
			}
			else{
				for(int i = 3; i < edges.size(); i++){
					if(edges[i].size() % 2 == 1){
						can_patrol = false;
						break;
					}
				}
			}

			if(can_patrol){
				std::cout << "OK" << std::endl;
			}
			else{
				std::cout << "NG" << std::endl;
			}
			edges.clear();
			edges.resize(101);
			continue;
		}
		Edge e;
		e.to = b;
		edges[a].push_back(e);
		e.to = a;
		edges[b].push_back(e);
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}
