local n=io.read("n","l")
local s={}
for i=1,2 do
    s[i]={io.read():byte(1,n)}
end

local mod=1000000007
local combination
local i
if s[1][1]==s[2][1] then
    combination=3
    i=2
else
    combination=6
    i=3
end
while i<=n do
    if s[1][i-1]~=s[2][i-1] and s[1][i]~=s[2][i] then
        combination=combination*3
        i=i+2
    elseif s[1][i-1]==s[2][i-1] and s[1][i]~=s[2][i] then
        combination=combination*2
        i=i+2
    else
        if s[1][i-1]==s[2][i-1] then
            combination=combination*2
        end
        i=i+1
    end
    combination=combination%mod
end
print(combination)