#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, cnt[105]{};
    while(cin >> a >> b){
        if(a==0){
            bool ok = true;
            for(int i=3;i<105;i++){
                ok &= cnt[i]%2==0;
            }
            ok &= cnt[1]%2==1 && cnt[2]%2==1;
            cout << (ok?"OK":"NG") << endl;
            fill(cnt,cnt+105,0);
        }
        else{
            cnt[a]++;
            cnt[b]++;
        }
    }
    return 0;
}
