#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int a,b,c=0;
    while(cin>>a>>b){

        bool flg[120] = {false};
        flg[a] = 1 - flg[a];
        flg[b] = 1 - flg[b];
        flg[a] ? c++ : c--;
        flg[b] ? c++ : c--;
        while(true){
            cin>>a>>b;
            if(a==0)break;
            flg[a] = 1 - flg[a];
            flg[b] = 1 - flg[b];
            flg[a] ? c++ : c--;
            flg[b] ? c++ : c--;
        }
        if(c==2||c==0)cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }

    return 0;
}