fun main(arg: Array<String>) {
    val N = nextInt()
    val S1 = next()
    val S2 = next()
    val MOD = 1000000007L
    var ans = 1L
    var tate = false
    var n = 0
    var c = 0
    fun isTate(n: Int) = S1[n] == S2[n]
    while (n < N) {
        if (c == 0) {
            if (isTate(n)) {
                ans = 3
                tate = true
            } else {
                ans = 6
                tate = false
            }
        } else if (isTate(n)) {
            ans *= if (tate) 2 else 1
            tate = true
        } else {
            ans *= if (tate) 2 else 3
            tate = false
        }
        ans %= MOD
        c += 1
        n += if (tate) 1 else 2
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
