#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE << '\n';
    SetConsoleTextAttribute(hConsole, 7);
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "NO";
    exit(0);
}
const int NMAX = 3 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int n;
string s1, s2;
ll dp[4][4][60]; // top, bot
int cur;

const int rosu = 1;
const int verde = 2;
const int albastru = 3;

int main()
{
    FASTIO;
    cin >> n >> s1 >> s2;
    if(n == 1) return cout << 3, 0;
    if(s1[0] == s1[1])
    {
        dp[verde][rosu][1] = 1;
        dp[rosu][verde][1] = 1;
        dp[verde][albastru][1] = 1;
        dp[albastru][verde][1] = 1;
        dp[rosu][albastru][1] = 1;
        dp[albastru][rosu][1] = 1;
        cur = 2;
    }
    else
    {
        dp[rosu][rosu][0] = 1;
        dp[verde][verde][0] = 1;
        dp[albastru][albastru][0] = 1;
        cur = 1;
    }

    while(1)
    {
        ll s;
        if(cur >= s1.size())
        {
            s = dp[rosu][rosu][cur - 1] + dp[verde][verde][cur - 1] + dp[albastru][albastru][cur - 1] + dp[rosu][verde][cur - 1] + dp[verde][rosu][cur - 1] + dp[rosu][albastru][cur - 1] + dp[albastru][rosu][cur - 1] + dp[albastru][verde][cur - 1] + dp[verde][albastru][cur - 1];
            return cout << s % MOD, 0;
        }

        if(s1[cur] == s1[cur + 1] && cur + 1 < s1.size())
        {
            dp[rosu][verde][cur + 1] = dp[albastru][rosu][cur - 1] + dp[albastru][albastru][cur - 1] + dp[verde][rosu][cur - 1] + dp[verde][albastru][cur - 1];
            dp[verde][rosu][cur + 1] = dp[rosu][albastru][cur - 1] + dp[albastru][albastru][cur - 1] + dp[rosu][verde][cur - 1] + dp[albastru][verde][cur - 1];

            dp[rosu][albastru][cur + 1] = dp[albastru][rosu][cur - 1] + dp[verde][verde][cur - 1] + dp[verde][rosu][cur - 1] + dp[albastru][verde][cur - 1];
            dp[albastru][rosu][cur + 1] = dp[rosu][albastru][cur - 1] + dp[verde][verde][cur - 1] + dp[rosu][verde][cur - 1] + dp[verde][albastru][cur - 1];


            dp[albastru][verde][cur + 1] = dp[rosu][albastru][cur - 1] + dp[rosu][rosu][cur - 1] + dp[verde][rosu][cur - 1] + dp[verde][albastru][cur - 1];
            dp[verde][albastru][cur + 1] = dp[albastru][rosu][cur - 1] + dp[rosu][rosu][cur - 1] + dp[rosu][verde][cur - 1] + dp[albastru][verde][cur - 1];

            dp[rosu][verde][cur + 1] %= MOD;
            dp[verde][rosu][cur + 1] %= MOD;
            dp[rosu][albastru][cur + 1] %= MOD;
            dp[albastru][rosu][cur + 1] %= MOD;
            dp[albastru][verde][cur + 1] %= MOD;
            dp[verde][albastru][cur + 1] %= MOD;

            cur += 2;
            continue;
        }

        s = dp[rosu][rosu][cur - 1] + dp[verde][verde][cur - 1] + dp[albastru][albastru][cur - 1] + dp[rosu][verde][cur - 1] + dp[verde][rosu][cur - 1] + dp[rosu][albastru][cur - 1] + dp[albastru][rosu][cur - 1] + dp[albastru][verde][cur - 1] + dp[verde][albastru][cur - 1];
        dp[rosu][rosu][cur] = s - dp[rosu][rosu][cur - 1] - dp[rosu][verde][cur - 1] - dp[verde][rosu][cur - 1] - dp[rosu][albastru][cur - 1] - dp[albastru][rosu][cur - 1];
        dp[verde][verde][cur] = s - dp[verde][verde][cur - 1] - dp[rosu][verde][cur - 1] - dp[verde][rosu][cur - 1] - dp[verde][albastru][cur - 1] - dp[albastru][verde][cur - 1];
        dp[albastru][albastru][cur] = s - dp[albastru][albastru][cur - 1] - dp[rosu][albastru][cur - 1] - dp[albastru][rosu][cur - 1] - dp[verde][albastru][cur - 1] - dp[albastru][verde][cur - 1];

        dp[rosu][rosu][cur] %= MOD;
        dp[verde][verde][cur] %= MOD;
        dp[albastru][albastru][cur] %= MOD;

        cur++;


    }

    return 0;
}


Measured memory_bytes: 256