#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
string S1, S2;
template <int mod>
struct ModInt
{
    ll x;

    constexpr ModInt(ll a = 0) noexcept
    {
        x = a % mod;
    }
    constexpr ll value() noexcept
    {
        return x;
    }
    constexpr const ll value() const noexcept
    {
        return x;
    }
    constexpr ModInt Pow(ll n) noexcept
    {
        ModInt<mod> ans(1), mul(x);
        for (int i = 0; i < 31; i++)
        {
            if (n & (1 << i))
            {
                ans *= mul;
            }
            mul *= mul;
        }
        return ans;
    }
    constexpr ModInt &operator+=(const ModInt y) noexcept
    {
        x += y.x;
        if (x >= mod)
        {
            x -= mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt y) noexcept
    {
        if (x < y.x)
        {
            x += mod;
        }
        x -= y.x;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt y) noexcept
    {
        x = x * y.x % mod;
        return *this;
    }
    constexpr ModInt factorial() noexcept
    {
        int k = x;
        ModInt<mod> tmp(x);
        for (int i = 1; i < k; i++)
        {
            tmp *= ModInt<mod>(k - i);
        }
        return tmp;
    }
    constexpr ll inverse() noexcept
    {
        return this->Pow(mod - 2).x;
    }
    constexpr ModInt &operator/=(const ModInt y) noexcept
    {
        return (*this) * y.Pow(mod - 2);
    }
    constexpr ModInt operator+(const ModInt y) const noexcept
    {
        return ModInt(*this) += y;
    }
    constexpr ModInt operator*(const ModInt y) const noexcept
    {
        return ModInt(*this) *= y;
    }
    constexpr ModInt operator-(const ModInt y) const noexcept
    {
        return ModInt(*this) -= y;
    }
    constexpr ModInt operator/(const ModInt y) const noexcept
    {
        return *this /= y;
    }
    friend constexpr ostream &operator<<(ostream &os, const ModInt<mod> &x) noexcept
    {
        return os << x.value();
    }
};
using mint = ModInt<(int)(1000000007)>;
mint Ans(1);
int N;
void solve(int y, int prev) //prev==true なら前のやつが縦、そうでないなら横
{
    if (y == N)
    {
        return;
    }
    int adj = 0;
    if (prev == 1)
    {
        adj = 1;
    }
    else if (prev == 0)
    {
        adj = 2;
    }

    if (S1[y] == S2[y]) //縦に置いてるとき
    {
        Ans *= mint(3 - adj);
        solve(y + 1, 1);
    }
    else
    {
        if (adj == 0)
            Ans *= mint(6);
        else if (adj == 1)
        {
            Ans *= mint(2);
        }
        else if (adj == 2)
        {
            Ans *= mint(3);
        }

        solve(y + 2, 0);
    }
}

int main()
{

    cin >> N;

    cin >> S1;
    cin >> S2;
    solve(0, -1);
    cout << Ans.value();
    return 0;
}

Measured memory_bytes: 256