
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])

type domino = H | V

let m = 1000000007

let mm x y = (x * y) mod m

let parse s =
  let rec f str = match str with
  | [] -> []
  | [_] -> [V]
  | (x::y::ys) -> if x = y then H :: f ys else V :: f (y::ys) in
  f (list_of_string s)

let calc xs =
  let f (p, a) x =
    match p, x with
    | H, H -> (H, mm 3 a)
    | H, V -> (V, a)
    | V, _ -> (x, mm 2 a) in
  match xs with
  | [] -> 1
  | (x::xs') ->
      let mult = match x with H -> 6 | V -> 3 in
      List.fold_left f (x, mult) xs' |> snd

let () =
  let _ = read_line () in
  let _ = read_line () in
  read_line () |> parse |> calc |> printf "%d\n"
