import Control.Applicative
import Control.Monad
import Control.Monad.State

data Dice = D { one :: DiceVector
              , two :: DiceVector
              , three :: DiceVector
              } deriving Show


type DiceVector = [Double]
type Matrix = [[Double]]

initDice = D [0,0,1] [0,-1,0] [1,0,0]

main = do
    sets <- getDataSet []
    results <- forM sets $ \set -> do
        let moveActions = sequence (map oneAction set)
        return $ execState moveActions (initDice, 1)
    mapM_ (print.snd) results

getDataSet :: [[String]] -> IO [[String]]
getDataSet list = do
    n <- read<$>getLine
    if n == 0 then return list
              else do
                  moves <- replicateM n getLine
                  getDataSet (list ++ [moves])

oneAction str = do
    moveDice str
    addVal

moveDice :: String -> State (Dice,Int) ()
moveDice direction = do
    (dice,val) <- get
    put (move direction dice,val)

addVal :: State (Dice,Int) ()
addVal = do
    (dice,val) <- get
    let newVal = val + diceTop dice
    put (dice,newVal)

diceTop :: Dice -> Int
diceTop d
  | one d !!2 == 1.0 = 1
  | one d !!2 == -1.0 = 6
  | two d !!2 == 1.0  = 2
  | two d !!2 == -1.0 = 5
  | three d !!2 == 1.0  = 3
  | three d !!2 == -1.0 = 4

move direction = case direction of
                        "North" -> moveNorth
                        "South" -> moveSouth
                        "East"  -> moveEast
                        "West"  -> moveWest
                        "Right" -> moveRight
                        "Left"  -> moveLeft
moveNorth = rotateX (-1)
moveSouth = rotateX 1
moveEast  = rotateY 1
moveWest  = rotateY (-1)
moveRight = rotateZ (-1)
moveLeft  = rotateZ 1

rotateX :: Double -> Dice -> Dice
rotateX t dice = D one' two' three'
    where
        one' = rotate_x t `mul` one dice
        two' = rotate_x t `mul` two dice
        three' = rotate_x t `mul` three dice

rotateY :: Double -> Dice -> Dice
rotateY t dice = D one' two' three'
    where
        one' = rotate_y t `mul` one dice
        two' = rotate_y t `mul` two dice
        three' = rotate_y t `mul` three dice

rotateZ :: Double -> Dice -> Dice
rotateZ t dice = D one' two' three'
    where
        one' = rotate_z t `mul` one dice
        two' = rotate_z t `mul` two dice
        three' = rotate_z t `mul` three dice

mul x y = map (dot y) x
dot x y = sum $ zipWith (*) x y

rotate_x :: Double -> Matrix
rotate_x t = [ [1,0    , 0    ]
             , [0,0    , - t*1]
             , [0,t*1  , 0    ]]

rotate_y t = [ [0    , 0, t*1  ]
             , [0    , 1, 0    ]
             , [- t*1, 0, 0    ]]

rotate_z t = [ [0  , - t*1, 0]
             , [t*1, 0    , 0]
             , [0  , 0    , 1]]