#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 110;
const int M = 1000000007;

int n;
char s[3][N];
LL dp[N][3][3];

int main()
{
    _upgrade
    cin >> n >> (s[1] + 1) >> (s[2] + 1);
    if(s[1][1] != s[2][1])
    {
        dp[1][0][1] = 1;
        dp[1][0][2] = 1;
        dp[1][1][0] = 1;
        dp[1][1][2] = 1;
        dp[1][2][0] = 1;
        dp[1][2][1] = 1;
    }
    else
    {
        dp[1][0][0] = 1;
        dp[1][1][1] = 1;
        dp[1][2][2] = 1;
    }
    for(int i = 2; i <= n; i++)
    {
        if(s[1][i] == s[2][i])
        {
            if(s[1][i - 1] != s[2][i - 1])
            {
                dp[i][0][0] += dp[i - 1][1][2];
                dp[i][0][0] += dp[i - 1][2][1];
                dp[i][1][1] += dp[i - 1][0][2];
                dp[i][1][1] += dp[i - 1][2][0];
                dp[i][2][2] += dp[i - 1][0][1];
                dp[i][2][2] += dp[i - 1][1][0];
            }
            else
            {
                dp[i][0][0] += dp[i - 1][1][1];
                dp[i][0][0] += dp[i - 1][2][2];
                dp[i][1][1] += dp[i - 1][0][0];
                dp[i][1][1] += dp[i - 1][2][2];
                dp[i][2][2] += dp[i - 1][0][0];
                dp[i][2][2] += dp[i - 1][1][1];
            }
        }
        else
        {
            bool p = (s[1][i] == s[1][i - 1]);
            bool q = (s[2][i] == s[2][i - 1]);
            for(int a = 0; a < 3; a++)
            {
                for(int b = 0; b < 3; b++)
                {
                    if(a == b) continue;
                    if(p && q)
                    {
                        dp[i][a][b] += dp[i - 1][a][b];
                    }
                    else if(p && !q)
                    {
                        if(b != 0) dp[i][a][b] += dp[i - 1][a][0];
                        if(b != 1) dp[i][a][b] += dp[i - 1][a][1];
                        if(b != 2) dp[i][a][b] += dp[i - 1][a][2];
                    }
                    else if(!p && q)
                    {
                        if(a != 0) dp[i][a][b] += dp[i - 1][0][b];
                        if(a != 1) dp[i][a][b] += dp[i - 1][1][b];
                        if(a != 2) dp[i][a][b] += dp[i - 1][2][b];
                    }
                    else
                    {
                        for(int c = 0; c < 3; c++)
                            for(int d = 0; d < 3; d++)
                                if(a != c && b != d) dp[i][a][b] += dp[i - 1][c][d];
                    }
                }
            }
        }
        for(int a = 0; a < 3; a++)
            for(int b = 0; b < 3; b++)
            {
                dp[i][a][b] %= M;
                //DBG(i, a, b, dp[i][a][b]);
            }
    }
    LL ans = 0;
    for(int a = 0; a < 3; a++)
        for(int b = 0; b < 3; b++)
            ans += dp[n][a][b];
    cout << ans % M << "\n";
	return 0;
}


Measured memory_bytes: 256