#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int main() {
    int a,b;
    vector<int> v = vector<int>(51,0);
    while(cin >> a >> b)
    {
        if(a==0)
        {

            if(v[1] % 2 != 0 && v[2] % 2 != 0)
            {
                bool ok = true;
                for(int i = 3 ; i< v.size();i++)
                {
                    if(v[i] %2 != 0)
                    {
                        cout << "NG" << endl;
                        ok = false;
                        break;
                    }
                }
                if(ok) cout << "OK" << endl;
            }
            else
                cout << "NG" << endl;
            v = vector<int>(51,0);
            continue;
        }
        v[a]++;
        v[b]++;
    }
    
    return 0;
}