import Prelude hiding (abs)
import Control.Monad
import Data.List (nub)
import Data.Maybe (fromJust)
import qualified Data.IntMap as IM
import qualified Data.Tree as T

data Color = Black | White | Null deriving (Eq, Read, Show)
type State = (Turn, Colors, Int)
type Colors = IM.IntMap Color
type Arrows = IM.IntMap [Int]
data Turn = Fennec | Snuke deriving (Ord, Eq, Read, Show)
type Move = (Turn, Int)
type GameTree = T.Tree Move

main :: IO ()
main = do
    n <- readLn
    abs <- map (tup2 . map read . words) <$> replicateM n readLn
    print $ solve n abs

-- |
--
-- >>> solve 7 [(3,6), (1,2), (3,1), (7,4), (5,7), (1,4)]
-- Fennec
--
-- >>> solve 4 [(1,4), (4,2), (2,3)]
-- Snuke
solve :: Int -> [(Int, Int)] -> Turn
solve n abs = minmax gt
  where
    gt = explore arrows state0
    arrows = initArrows abs
    state0 = (Snuke, initColors n, 0)

minmax :: GameTree -> Turn
minmax gt
  | null sf   = fst rl
  | otherwise = case fst rl of
                  Fennec -> minimum $ map minmax sf
                  Snuke  -> maximum $ map minmax sf
  where
    rl = T.rootLabel gt
    sf = T.subForest gt

explore :: Arrows -> State -> GameTree
explore arrows = T.unfoldTree (expand arrows)

expand :: Arrows -> State -> (Move, [State])
expand arrows state@(turn, _, coord)
  | null xs   = ((turn, coord), [])
  | otherwise = ((turn, coord), [step state x | x <- xs])
  where xs = listCoords arrows state

listCoords :: Arrows -> State -> [Int]
listCoords arrows (turn, colors, _) = nullTargets
  where
    turn' = next turn
    nullTargets = [x | x <- targets, IM.lookup x colors == Just Null]
    targets = nub $ concat [fromJust $ IM.lookup x arrows | x <- myArea]
    myArea = IM.keys $ IM.filter (== color turn') colors

step :: State -> Int -> State
step (turn, colors, _) x = (turn', colors', x)
  where
    turn' = next turn
    colors' = IM.update (const $ Just $ color turn') x colors

next :: Turn -> Turn
next Fennec = Snuke
next Snuke = Fennec

color :: Turn -> Color
color Fennec = Black
color Snuke = White

initArrows :: [(Int, Int)] -> Arrows
initArrows = foldl f IM.empty
  where
    f :: Arrows -> (Int, Int) -> Arrows
    f x (a, b) = IM.unionWith (++) x (IM.fromList [(a, [b]), (b, [a])])

initColors :: Int -> Colors
initColors n = IM.fromList $ b0 : w0 : ns
  where
    b0 = (1, Black)
    w0 = (n, White)
    ns = zip [2 .. n-1] (repeat Null)


-- Util
tup2 :: [Int] -> (Int, Int)
tup2 [] = undefined
tup2 [x,y] = (x,y)
tup2 _ = undefined
