#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<vector<int> >V;
int cnt[100][100],edge;
void add(int a,int b){
    --a;--b;
    if(find(V[a].begin(),V[a].end(),b)==V[a].end())
        V[a].push_back(b);

    ++cnt[a][b];

    if(find(V[b].begin(),V[b].end(),a)==V[b].end())
        V[b].push_back(a);

    ++cnt[b][a];
}
bool dfs(int atnum,int n){
    if(atnum==1&&n==edge)return true;
    bool Flag=false;
    for(int i=0;i<V[atnum].size();++i){
        int to=V[atnum][i],from=atnum;
        if(cnt[to][from]<=0)continue;
        --cnt[to][from],--cnt[from][to];
        Flag|=dfs(to,n+1);
        ++cnt[to][from],++cnt[from][to];
    }
    return Flag;
}
int main(){
    int a,b;
    while(cin>>a>>b){
        edge=1;
        V.clear();V.resize(100);
        fill(cnt[0],cnt[0]+10000,0);
        add(a,b);
        while(cin>>a>>b,a||b)
            add(a,b),++edge;

        if(dfs(0,0))cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }
}