// AtCoder My Practice
// author: Leonardone @ NEETSDKASU
import std.stdio      : readln, writeln;
import std.string     : chomp;
import std.conv       : to;

void main() {
    auto n = readln.chomp.to!uint;
    auto s1 = readln.chomp;
    auto s2 = readln.chomp;
    long ans, md = 1_000_000_007;
    uint i, pat;
    if (s1[0] == s2[0]) {
        ans = 3;
        i = 1;
        pat = 0;
    } else {
        ans = 6;
        i = 2;
        pat = 1;
    }
    while (i < n) {
        if (s1[i] == s2[i]) {
            if (pat == 0) {
                ans = (ans * 2) % md;
            }
            pat = 0;
            i += 1;
        } else {
            if (pat == 1) {
                ans = (ans * 3) % md;
            } else {
                ans = (ans * 2) % md;
            }
            pat = 1;
            i += 2;
        }
    }
    writeln(ans);
}