l=[]
while gets
  n,m=$_.split.map(&:to_i)
  if n==0 and m==0
    tf=true
    (1..(l.max)).each do |x|
      if x.between?(1,2) then tf=l.count(x).odd?
      else tf=l.count(x).even? end
      break unless tf
    end
    puts tf ? "OK" : "NG"
    l=[]
  else
    l<<n<<m
  end
end