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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    while(1){
        string s;
        int degree[110] = {0};
        bool flag = false;
        while(1){
            getline(cin, s);
            if(s == "0 0"){
                break;
            }
            if(s == ""){
                flag = true;
                break;
            }
            int a = 0, b = 0, j = 0;
            while('0' <= s[j] && s[j] <= '9'){
                a *= 10;
                a += s[j] - '0';
                ++j;
            }
            ++j;
            while(j < s.size()){
                b *= 10;
                b += s[j] - '0';
                ++j;
            }
            ++degree[a];
            ++degree[b];
        }
        if(flag){
            break;
        }
        bool ans = true;
        int cnt = 0;
        rep(i, 110){
            cnt += degree[i] % 2;
            if(i > 2 && degree[i] == 1){
                ans = false;
                break;
            }
        }
        ans &= cnt <= 2;
        ans &= degree[1] % 2 == 1 && degree[2] % 2 == 1;
        if(ans){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
    return 0;
}
