#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;


void cp(int temp[105][105], int graph[105][105]){
    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            temp[i][j]=graph[i][j];
        }
    }
}

bool ch(int graph[105][105]){
    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            if(graph[i][j]>0)return false;
        }
    }
    return true;
}

bool ch2(int graph[105][105]){
    for(int i=0; i<105; i++){
        if(graph[2][i]>0)return false;
    }
    return true;
}




bool Patrol(int now, int graph[105][105]){
    if(now==2)return ch(graph);
    if(ch2(graph))return false;
    
    for(int i=0; i<105; i++){
        if(graph[now][i]>0){
            int temp[105][105];
            cp(temp,graph);
            temp[now][i]--;
            temp[i][now]--;
            int temp_now=i;
            if(Patrol(temp_now, temp)==true){
                return true;
            }
        }
    }
    return false;
}



int main(void)
{
    
    int n,m;
    while(cin>>n>>m){
        int graph[105][105]={0};
        while(1){
            graph[n][m]++;
            graph[m][n]++;
            cin>>n>>m;
            if(n==0&&m==0)break;
        }
        
        if(Patrol(1, graph))cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
        
    }
    
    
}