let m = 1000000007

let () =
  let n = read_int () in
  let s1 = read_line () in
  read_line () |> ignore;
  let rec doit i ps =
    if i = n then ps
    else if i = n - 1 || s1.[i] <> s1.[i+1] then doit (i + 1) (true :: ps)
    else doit (i + 2) (false :: ps) in
  match doit 0 [] with
  | [] -> assert false
  | p :: ps ->
    let _, s = List.fold_left (fun (q, s) p ->
      match q, p with
      | true, true -> true, s * 2 mod m
      | true, false -> false, s * 2 mod m
      | false, true -> true, s
      | false, false -> false, s * 3 mod m)
      (if p then true, 3 else false, 6) ps in
    Printf.printf "%d\n" s