#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

#define MAX_N 101

int route[MAX_N];

int main()
{
    int a,b=1;
    int n=0;
    
    while (cin >> a && cin >> b)
    {
        route[a]++;
        route[b]++;
        n++;
        if (a == 0)
        {
            if(route[1] % 2 == 1 && route[2] % 2 == 1)
            {
                for(int i=3; i<n; i++)
                {
                    if(route[i]%2==1){cout << "NG" << endl; break;}
                    if(i==n-1){cout << "OK" << endl;}
                }
            }
            for(int i=0; i < MAX_N; i++){route[i]=0;}
            n=0;
        }
    }
}