local n = io.read("*n", "*l")
local str = io.read()
local mod = 1000000007
local _unused = io.read()
local t = {str:byte(1, n)}
local ret = 1
local prevstate = 0
local i = 1
while(i <= n) do
  if(i ~= n and t[i] == t[i + 1]) then
    if(prevstate == 0) then
      ret = (ret * 6) % mod
    elseif(prevstate == 1) then
      ret = (ret * 3) % mod
    else
      ret = (ret * 2) % mod
    end
    i = i + 2
    prevstate = 1
  else
    if(prevstate == 0) then
      ret = (ret * 3) % mod
    elseif(prevstate == 1) then
      --  * 1
    else
      ret = (ret * 2) % mod
    end
    i = i + 1
    prevstate = 2
  end
end
print(ret)
