import Data.List

main = do
  getLine
  getLine
  s <- getLine
  print $ solve4 s
 
solve4 xs = case group xs of
  ((_ : []) : ys) -> solve4' 'v' 3 ys
  ((_ : _ : []) : ys) -> solve4' 'h' 6 ys
  where
    solve4' d p = snd . foldl (\a b -> let t = solve4'' a b in (fst t, (`mod` 1000000007) $ snd t)) (d, p)
    solve4'' acc x = case acc of
        ('v', z)
          | length x == 1 -> ('v', 2 * z)
          | length x == 2 -> ('h', 2 * z)
        ('h', z)
          | length x == 1 -> ('v', z)
          | length x == 2 -> ('h', 3 * z)
