#include <bits/stdc++.h>

using namespace std;

const int MAX_V = 101;
vector<int> G[MAX_V];

int main() {
    int a, b;
    while (scanf("%d %d", &a, &b) != EOF) {
        if (a == 0 && b == 0) {
            G[1].push_back(2);
            G[2].push_back(1);

            bool flag = true;
            for (int i = 1; i < MAX_V; i++) {
                if (G[i].size() % 2) flag = false;
                G[i].clear();
            }
            
            if (flag) puts("OK");
            else puts("NG");

            continue;
        }

        G[a].push_back(b);
        G[b].push_back(a);
    }

    return 0;
}
