fun main() {
    val n = readLine()?.toInt() ?: return
    val s1 = readLine() ?: return
    val s2 = readLine() ?: return
    val m = 1000000007L
    var i = 0
    val p = mutableListOf<String>()
    while (i < s1.length) {
        if (s1[i] == s2[i]) {
            p.add("v")
        } else {
            p.add("h")
            i++
        }
        i++
    }
    val t = p.foldIndexed(0L) { index, a, b ->
        if (a == 0L) {
            if (b == "v") {
                3L
            } else {
                6L
            }
        } else {
            a * if (b == "v") {
                if (p[index - 1] == "v") {
                    2L
                } else {
                    1L
                }
            } else {
                if (p[index - 1] == "v") {
                    2L
                } else {
                    3L
                }
            } % m
        }
    }
    println(t.toString())
}
