#include <iostream>
#include <vector>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    int a, b;
    vector<int> v(101);
    while (cin >> a >> b) {
        if (a != 0 || b != 0) {
            v[a] ++;
            v[b] ++;
        } else {
            bool ok = true;
            if (v[1] % 2 == 0 || v[2] % 2 == 0) {
                ok = false;
            }
            for (int i=3; i<101; ++i) {
                if (v[i] % 2 != 0) {
                    ok = false;
                }
            }
            cout << (ok ? "OK" : "NG") << endl;
            fill(v.begin(), v.end(), 0);
        }
    }
    return 0;
}