#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

#define pii pair<int, int>
#define pll pair<long long, long long>
#define mp make_pair
#define fr first
#define sc second
#define tiii tuple<int, int, int>
#define tlll tuple<long long, long long, long long>
#define mt make_tuple
#define ll long long
#define ld long double
#define pb push_back

#define int long long

const int MOD = 1e9 + 7;

int dp[55][5][5];

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    s1 = '0' + s1;
    s2 = '0' + s2;


    for (int i = 0; i < 55; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                dp[i][j][k] = 0;

    if (s1[1] == s2[1])
    {
        for (int i = 1; i < 4; i++)
            dp[1][i][i] = 1;
    }
    else
    {
        for (int i = 1; i < 4; i++)
            for (int j = 1; j < 4; j++)
                if (j != i)
                    dp[1][i][j] = 1;
    }

    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < 4; j++)
        {
            for (int k = 1; k < 4; k++)
            {
                //if (i < 10)
                //    cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
                if (s1[i] == s2[i])
                {
                    if (j != k) continue;
                    if (s1[i + 1] == s2[i + 1])
                    {
                        for (int j1 = 1; j1 < 4; j1++)
                            if (j1 != j)
                            {
                                dp[i + 1][j1][j1] += dp[i][j][j];
                                dp[i + 1][j1][j1] %= MOD;
                            }
                    }
                    else
                    {
                        for (int j1 = 1; j1 < 4; j1++)
                            for (int k1 = 1; k1 < 4; k1++)
                                if (j1 != j && k1 != j && j1 != k1)
                                {
                                    dp[i + 1][j1][k1] += dp[i][j][j];
                                    dp[i + 1][j1][k1] %= MOD;
                                }
                    }
                }

                else
                {
                    if (s1[i + 1] == s2[i + 1])
                    {
                        for (int j1 = 1; j1 < 4; j1++)
                            if (j1 != j && j1 != k)
                            {
                                dp[i + 1][j1][j1] += dp[i][j][k];
                                dp[i + 1][j1][j1] %= MOD;
                            }
                    }
                    else if (s1[i + 1] == s1[i])
                    {
                        dp[i + 1][j][k] += dp[i][j][k];
                        dp[i + 1][j][k] %= MOD;
                    }
                    else
                    {
                        for (int j1 = 1; j1 < 4; j1++)
                            for (int k1 = 1; k1 < 4; k1++)
                                if (j1 != j && k1 != k && j1 != k1)
                                {
                                    dp[i + 1][j1][k1] += dp[i][j][k];
                                    dp[i + 1][j1][k1] %= MOD;
                                }
                    }
                }
            }
        }
    }

    int sm = 0;
    for (int j = 1; j < 4; j++)
        for (int k = 1; k < 4; k++)
            sm = (sm + dp[n][j][k]) % MOD;

    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 256