#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
    ll N;
    vector<string> S(2);
    cin >> N >> S[0] >> S[1];

    stack<char> mode;
    mint ans;
    ll idx = 0;

    if (N == 1) {
        cout << 3 << endl;
        return 0;
    }

    if (S[0][0] == S[1][0]) {
        ans = 3;
        mode.push('X');
        idx = 1;
    } else {
        ans = 3 * 2;
        mode.push('Y');
        idx = 2;
    }

    // cout << "idx:" << idx << ", ans:" << ans << endl;

    while (idx < N) {
        if (mode.top() == 'X') {
            if (S[0][idx] == S[1][idx]) {
                ans *= 2;
                idx += 1;
                mode.push('X');
            } else {
                ans *= 2;
                idx += 2;
                mode.push('Y');
            }
        } else if (mode.top() == 'Y') {
            if (S[0][idx] == S[1][idx]) {
                ans *= 1;
                idx += 1;
                mode.push('X');
            } else {
                ans *= 3;
                idx += 2;
                mode.push('Y');
            }
        }

        // cout << "idx:" << idx << ", ans:" << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584