program main
implicit none
integer N,i
character(52) S1,S2
integer(16)::mo=10**9+7,ans
character Pat
read*,N
read*,S1
read*,S2
ans=1
do i=1,N

  if(i==1)then
    if(S1(i:i)==S2(i:i))then
      ans=mod(ans*3,mo)
      Pat="X"
    else
      ans=mod(ans*6,mo)
      Pat="Y"
    endif
    cycle
  endif
  
  if(S1(i-1:i-1)==S1(i:i))cycle
  
  select case(Pat)
    case("X")
      if(S1(i:i)==S2(i:i))then
        ans=mod(ans*2,mo)
        Pat="X"
      else
        ans=mod(ans*2,mo)
        Pat="Y"
      endif
    case("Y")
      if(S1(i:i)==S2(i:i))then
        Pat="X"
      else
        ans=mod(ans*3,mo)
        Pat="Y"
      endif
  end select
end do
print"(i0)",ans
end program main