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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    map<int, int> d;

    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            bool OK = true;
            for (auto it=d.begin(); it!=d.end(); ++it) {
                if ((it->first == 1 && it->second % 2 == 0) ||
                    (it->first == 2 && it->second % 2 == 0) ||
                    (it->first >= 3 && it->second % 2 == 1)) {
                    OK = false;
                    break;
                }
            }
            cout << (OK ? "OK" : "NG") << endl;

            d.clear();
            continue;
        }
        d[a] ++;
        d[b] ++;
    }

    return 0;
}
