program arc081_d
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,j,ans
    integer(int64),parameter:: md=1000000007
    character(:),allocatable:: s(:)

    read*, n
    allocate(character(n):: s(2))
    read*, s(1)
    read*, s(2)

    i=1
    if (s(1)(1:1) == s(2)(1:1)) then
        ans = 3
    else
        ans = 6
    end if

    do while (i <= n)
        if (s(1)(i:i) == s(2)(i:i)) then
            if (i+1 <= n) ans=mod(ans*2,md)
            i=i+1
        else
            if (i+2 <= n) then 
                j = i+2
                if (s(1)(j:j) /= s(2)(j:j)) ans=mod(ans*3,md)
            end if
            i=i+2
        end if
    end do

    print'(i0)', ans
end program arc081_d