local mod = 1000000007
local function bmul(x, y) return (x * y) % mod end
local n = io.read("*n", "*l")
local s1 = io.read()
local s2 = io.read()
local cur = 1
local ret = 1
local prv = true
while cur <= n do
  if s1:sub(cur, cur) == s2:sub(cur, cur) then
    if cur == 1 then
      ret = 3
    elseif prv then
      ret = bmul(ret, 2)
    end
    cur = cur + 1
    prv = true
  else
    if cur == 1 then
      ret = 6
    elseif prv then
      ret = bmul(ret, 2)
    else
      ret = bmul(ret, 3)
    end
    cur = cur + 2
    prv = false
  end
end
print(ret)
