fun main(arg: Array<String>) {
    val N = nextInt()
    val S1 = next()
    val S2 = next()
    val Tate = BooleanArray(N) { S1[it] == S2[it] }
    val C = LongArray(N) { n -> 
        if (n == 0) if (Tate[n]) 3 else 6
        else if (!Tate[n - 1] && !Tate[n] && S1[n - 1] == S1[n]) 1
        else if (Tate[n]) if (Tate[n - 1]) 2L else 1L
                     else if (Tate[n - 1]) 2L else 3L
    }
    val MOD = 1000000007L
    val ans = C.reduce { acc, c -> (acc * c) % MOD }
    println(ans)
}

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

