object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val s1, s2 = sc.next + ("*" * 5)
  val MOD = 1000000007

  var i = 0
  var sum: Long = if (s1(0) == s2(0)) 3 else 6
  while(i < n) {
    if (s1(i+1) != '*' && s1(i+2) != '*') {
      if (s1(i) == s2(i)) {
        sum = (sum * 2) % MOD
        i += 1
      } else {
        if (s1(i + 2) != s2(i + 2)) {
          sum = (sum * 3) % MOD
        }
        i += 2
      }
    } else i = n
  }
  println(sum)
}
