import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    for(;;)
    {
        string[] ss;
        for(string t; (t=readln().chomp())!="" && t!="0 0"; ss~=t){}
        if(ss.length==0) break;
        int[] c = new int[3];
        foreach(s;ss)
        {
            auto m = s.split().map!(to!int);
            immutable a=m[0], b=m[1];
            c.length = max(c.length,max(a,b)+1);
            ++c[a];
            ++c[b];
        }
        writeln(c[1..3].all!"a&1"() && !c[3..$].any!"a&1"()?"OK":"NG");
    }
}