#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    for(int a, b; cin >> a >> b; ) {
        map<int, int> dict;
        dict[a]++;
        dict[b]++;
        for(int x, y; cin >> x >> y, x + y; ) {
            dict[x]++;
            dict[y]++;
        }
        bool ok = true;
        if(dict[1] % 2 == 0 || dict[2] % 2 == 0) ok = false;
        for(auto p : dict) {
            if(p.first == 1 || p.first == 2) continue;
            if(p.second % 2 != 0) ok = false;
        }
        cout << (ok ? "OK" : "NG") << endl;
    }
}