#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 1005


int cnt[ARRAY_MAX];

int main(){

    int a,b;
    while(cin >> a >> b,a){
        
        REP(i,ARRAY_MAX){
            cnt[i] = 0;
        }
        int maxi = -1;
        int odd = 0;
        maxi = max(maxi,max(a,b));
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
        while(cin >> a >> b,a){
            maxi = max(maxi,max(a,b));
            a--;
            b--;
            cnt[a]++;
            cnt[b]++;
        }
        REP(i,maxi){
            if(cnt[i] % 2 == 1){
                odd++;
            }
        }
        if(odd <= 2 && cnt[0]%2 == 1 && cnt[1]%2 == 1){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }

    


    return 0;
}
