import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int[] group(string s, string t) {
    int[] gs;

    auto n = s.length;
    int p = 0;
    while (p < s.length) {
        if (s[p] == t[p]) {
            gs ~= 1;
            p += 1;
        }
        else {
            gs ~= 0;
            p += 2;
        }
    }
    return gs;
}

void main() {
    readln;
    auto s = readln.chomp;
    auto t = readln.chomp;

    const MOD = 1000000007L;
    auto gs = group(s, t);
    long ans = 1;
    //    writeln(gs);
    if (gs[0] == 0)
        ans = 6;
    else
        ans = 3;
    for (int i = 1; i < gs.length; i++) {
        int prev = gs[i - 1];
        int next = gs[i];

        if (prev == 0) { // 横
            if (next == 0) {
                ans = (ans * 3) % MOD;
            }
        }
        else {
            if (next == 0) {
                ans = (ans * 2) % MOD; // 上下で色かえ
            }
            else if (next == 1) {
                ans = (ans * 2) % MOD;
            }
        }
    }
    writeln(ans);
}
