main = interact $ unlines . map (show' . nnw) . init . lines
 where show' (n,d) = if d==1 then show n else show n ++ "/" ++ show d

nnw "north" = (0,1)
nnw "west" = (90,1)
nnw "northwest" = (45,1)
nnw "westnorth" = (45,1)
nnw xs = (irreducible, 2 ^ ((length sign + 2) - div numerator irreducible))
 where
  irreducible = until odd (`div` 2) numerator
  numerator = (sum $ zipWith ($) sign (iterate (*2) 90)) + 90*(2^(length sign))
  sign = map (\c -> if c=='n' then negate else id) $ tail $ tail $ reverse $ filter (flip elem "nw") xs