#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << x << endl;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; //
    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
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= 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
    {
        mint res(*this);
        return res /= a;
    }
};
int main()
{
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;
    vector<vector<vector<mint>>> dp(N, vector<vector<mint>>(3, vector<mint>(3, 0)));

    bool is_tate = (S1[0] == S2[0]);
    if (is_tate)
    {
        dp[0][0][0] = 1;
        dp[0][0][1] = 0;
        dp[0][0][2] = 0;
        dp[0][1][0] = 0;
        dp[0][1][1] = 1;
        dp[0][1][2] = 0;
        dp[0][2][0] = 0;
        dp[0][2][1] = 0;
        dp[0][2][2] = 1;
    }
    else
    {
        dp[0][0][0] = 0;
        dp[0][0][1] = 1;
        dp[0][0][2] = 1;
        dp[0][1][0] = 1;
        dp[0][1][1] = 0;
        dp[0][1][2] = 1;
        dp[0][2][0] = 1;
        dp[0][2][1] = 1;
        dp[0][2][2] = 0;
        dp[1] = dp[0];
    }

    rep(i, N - 1)
    {
        is_tate = (S1[i + 1] == S2[i + 1]);
        if (!is_tate)
        {
            if (i == 0 && S1[0] == S1[1])
            {
                continue;
            }
            dp[i + 1][0][0] = 0;
            dp[i + 1][0][1] = dp[i][1][0] + dp[i][1][2] + dp[i][2][0] + dp[i][2][2];
            dp[i + 1][0][2] = dp[i][2][0] + dp[i][1][0] + dp[i][2][1] + dp[i][1][1];

            dp[i + 1][1][0] = dp[i + 1][0][1];
            dp[i + 1][1][1] = 0;
            dp[i + 1][1][2] = dp[i + 1][0][1];
            dp[i + 1][2][0] = dp[i + 1][0][1];
            dp[i + 1][2][1] = dp[i + 1][0][1];
            dp[i + 1][2][2] = 0;
            dp[i + 2] = dp[i + 1];
            //cout << dp[i + 1][0][1].x << "yoko" << endl;
            i++;
        }
        else if (is_tate)
        {
            dp[i + 1][0][0] = dp[i][1][2] + dp[i][2][1] + dp[i][1][1] + dp[i][2][2];
            dp[i + 1][0][1] = 0;
            dp[i + 1][0][2] = 0;
            dp[i + 1][1][0] = 0;
            dp[i + 1][1][1] = dp[i + 1][0][0];
            dp[i + 1][1][2] = 0;
            dp[i + 1][2][0] = 0;
            dp[i + 1][2][1] = 0;
            dp[i + 1][2][2] = dp[i + 1][0][0];
            //cout << dp[i + 1][0][0].x << "tate" << endl;
        }
    }

    mint ans = dp[N - 1][0][0] +
               dp[N - 1][0][1] +
               dp[N - 1][0][2] +
               dp[N - 1][1][0] +
               dp[N - 1][1][1] +
               dp[N - 1][1][2] +
               dp[N - 1][2][0] +
               dp[N - 1][2][1] +
               dp[N - 1][2][2];

    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256