open Num
       
let () =
  let m = num_of_int 1000000007 in
  let n = read_int () in
  let s1 = read_line () in
  let s2 = read_line () in
  let rec iter r p x =
    if x >= n then r
    else
      if x = 0 then
        if s1.[x] = s2.[x] then iter (num_of_int 3) 1 (x+1) else iter (num_of_int 6) 2 (x+2)
      else
        if s1.[x] = s2.[x] then
          if p = 1 then iter (mod_num ((num_of_int 2) */ r) m) 1 (x+1) else iter r 1 (x+1)
        else
          if p = 1 then iter (mod_num ((num_of_int 2) */ r) m) 2 (x+2) else iter (mod_num ((num_of_int 3) */ r) m) 2 (x+2)
  in
  iter (num_of_int 0) 0 0 |> string_of_num |> print_endline
