import Control.Applicative( (<$>))

main = do
    n_ <- readLn::IO Int
    line1 <- getLine
    line2 <- getLine
    let
	d:ouble = zip line1 line2
	proc1st::(Char,Char) -> Integer
	proc1st (a,b)
	  |  a==b	= 3 * case ouble of
				[]	-> 1
				ouble	-> proc (a,a) ouble
	  | otherwise	= 6 * case ouble of
				[]	-> 1
				o:uble	-> proc (a,b) uble
	proc _ [] = 1
	proc (prev1,prev2) [_]
	  | prev1==prev2    = 2
	  | otherwise	    = 1
	proc (prev1,prev2) ((a,b):tl@((a2,b2):remain))
	  | prev1==prev2    = if a==b
				then 2 * proc (a,a) tl
				else 2 * proc (a2,b2) remain
	  | otherwise	    = if a==b
				then proc (a,a) tl
				else 3 * proc (a2,b2) remain
    print $ proc1st d `rem` 1000000007