import Control.Monad
import Data.Maybe (fromJust)
import Data.List

data LastPattern = First | Vertical | Horizontal deriving (Show, Eq)

modNum :: Int
modNum = 1000000007

solve :: String -> String -> LastPattern -> Int -> Int
solve [] [] _ curr = curr
solve (c11:[]) (c21:[]) last curr = solveVertical [c11] [c21] last curr

solve s1 s2 last curr
    | c1 == c2 = solveVertical s1 s2 last curr
    | otherwise = solveHorizontal s1 s2 last curr
    where
        c1 = s1!!0
        c2 = s2!!0

solveVertical :: String -> String -> LastPattern -> Int -> Int
solveVertical (c11:ss1) (c21:ss2) last curr = solve ss1 ss2 Vertical next
    where
        next = case last of
            First -> 3
            Vertical -> ((curr * 2) `mod` modNum)
            Horizontal -> (curr `mod` modNum)

solveHorizontal :: String -> String -> LastPattern -> Int -> Int
solveHorizontal (c11:c12:ss1) (c21:c22:ss2) last curr = solve ss1 ss2 Horizontal next
    where
        next = case last of
            First -> 6
            Vertical -> ((curr * 2) `mod` modNum)
            Horizontal -> ((curr * 3) `mod` modNum)

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    s1 <- getLine
    s2 <- getLine
    let s = solve s1 s2 First 1
    print s
