// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;

void main() {
    int n;
    auto s = new string[](2);

    scan(n);
    iota(2).each!(i => s[i] = readln.chomp);

    if (n == 1) {
        writeln(3);
        return;
    }

    int pos = 0;
    int joutai;
    long ans;

    if (s[0][0] == s[1][0]) {
        joutai = 0;
        ans = 3;
        pos = 1;
    }
    else {
        joutai = 1;
        ans = 6;
        pos = 2;
    }

    while (pos < n) {
        if (pos == n - 1) {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            break;
        }

        if (s[0][pos] == s[1][pos]) {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            pos++;

            joutai = 0;
        }
        else {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            else {
                (ans *= 3) %= mod;
            }
            pos += 2;

            joutai = 1;
        }

        debug {
            stderr.write(ans, " ");
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}