#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};




signed main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    vector<vector<mint>> dp(3, vector<mint>(3, 0));
    if(s[0] == t[0])
        dp[0][0] = dp[1][1] = dp[2][2] = 1;
    else{
        for(int i = 0; i < 3; ++i)
            for(int j = 0; j < 3; ++j)
                if(i != j)
                    dp[i][j] = 1;
    }
    for(int i = 0; i < n - 1; ++i){
        vector<vector<mint>> nex(3, vector<mint>(3, 0));
        for(int c1 = 0; c1 < 3; ++c1){
            for(int c2 = 0; c2 < 3; ++c2){
                for(int d1 = 0; d1 < 3; ++d1){
                    for(int d2 = 0; d2 < 3; ++d2){
                        if((s[i] != s[i + 1]) != (c1 != d1))
                            continue;
                        if((t[i] != t[i + 1]) != (c2 != d2))
                            continue;
                        if((s[i] != t[i]) != (c1 != c2))
                            continue;
                        if((s[i + 1] != t[i + 1]) != (d1 != d2))
                            continue;
                        nex[d1][d2] += dp[c1][c2];
                    }
                }
            }
        }
        dp = move(nex);
    }
    mint ans = 0;
    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            ans += dp[i][j];
    cout << ans << endl;
}


Measured memory_bytes: 3588