let n = read_int()
let s = read_line()
let t = read_line()
let b = [|[|2; 2|]; [|1; 3|]; [|3; 6|]|]
let m = 1_000_000_007

let rec f i j a =
  if i >= n then a
  else
    let k = if s.[i] = t.[i] then 0 else 1 in
    f (i + 1 + k) k (a * b.(j).(k) mod m)

let () = Printf.printf "%d\n" (f 0 2 1)
