import qualified Data.Array as A
import Data.Array ((//), (!), listArray)
import Data.Functor
import Data.List
import Control.Monad
import System.IO

main :: IO ()
main = do
  eof <- isEOF
  if eof then return () else solve >> main

solve :: IO ()
solve = do
  xs <- getDegrees
  putStrLn $ if ok xs then "OK" else "NG"

getDegrees :: IO [Int]
getDegrees = rec $ listArray (0, 100) $ replicate 101 0
  where rec arr = do
          [x, y] <- map readInt . words <$> getLine
          if x == 0 && y == 0 then return $ A.elems arr
          else rec $ arr // [(x, (arr ! x) + 1), (y, (arr ! y) + 1)]

ok :: [Int] -> Bool
ok (_:x0:x1:xs) = odd x1 && odd x1 && all even xs

readInt :: String -> Int
readInt = read