fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val d = Array(2) { "" }
    d[0] = readLine()!!
    d[1] = readLine()!!

    var counts = 0L
    var preVertical = false
    var i = 0
    if (d[0][0] == d[1][0]) {
        preVertical = true
        counts = 3
        i++
    } else {
        counts = 6
        preVertical = false
        i += 2
    }

    val MOD = 1000000007
    while (i < N) {
        val isVertical = d[0][i] == d[1][i]

        if (isVertical) {
            if (preVertical) {
                counts = counts * 2 % MOD
            } else {
                counts = counts
            }
            i++
            preVertical = true
        } else {
            if (preVertical) {
                counts = counts * 2 % MOD
            } else {
                counts = counts * 3 % MOD
            }
            preVertical = false
            i+=2
        }
    }
    println(counts)
}