#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;

#define ALL(s) (s).begin(),(s).end()
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 110;
int deg[MAX];
int a, b;

int main() {
    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            bool ok = true;
            if (!(deg[1] & 1) || !(deg[2] & 1)) ok = false;
            for (int i = 3; i < MAX; ++i) if (deg[i] & 1) ok = false;
            
            if (ok) puts("OK");
            else puts("NG");
            
            memset(deg, 0, sizeof(deg));
        }
        deg[a]++;
        deg[b]++;
        
        //for (int i = 0; i < MAX; ++i) if (deg[i] > 0) cout << i << " : " << deg[i] << endl;
    }
    
    return 0;
}
