#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int k[101],a,b,c,i;
	for (i=0;i<101;i++) k[i]=0;
	while(cin >> a >> b) {
		if (a+b>0) { k[a]++; k[b]++; continue;}
		for (i=1,c=0;i<101;i++) { c+=k[i] % 2; k[i]=0;}
		if (c<3) cout << "OK"; else cout << "NG";
		cout << endl;
	}
 return 0;
}