//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 55, MOD = 1000000007;
int n, dp[3][3][N], hor[N];

void add(int & x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    string a, b;
    cin >> n >> a >> b;
    int m = 0, i = 0;
    while (i < n) {
        if (i < n - 1 && a[i] == a[i + 1]) {
            m++;
            hor[m] = 1;
            i += 2;
        }   else {
            m++;
            i++;
        }
    }
    if (hor[1]) {
        dp[0][1][1] = dp[0][2][1] = dp[1][0][1] = 1;
        dp[1][2][1] = dp[2][0][1] = dp[2][1][1] = 1;
    }   else {
        dp[0][0][1] = dp[1][0][1] = dp[2][0][1] = 1;
    }
    for (int i = 2; i <= m; i++) {
        if (hor[i]) {
            if (hor[i - 1]) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        for (int l = 0; l < 3; l++) {
                            for (int h = 0; h < 3; h++) {
                                if (j == l || k == h || j == k || l == h) {
                                    continue;
                                }
                                add(dp[j][k][i], dp[l][j][i - 1]);
                            }
                        }
                    }
                }
            }   else {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        for (int l = 0; l < 3; l++) {
                            if (j == k || j == l || k == l) {
                                continue;
                            }
                            add(dp[j][k][i], dp[l][0][i - 1]);
                        }
                    }
                }
            }
        }   else {
            if (hor[i - 1]) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        for (int l = 0; l < 3; l++) {
                            if (j == k || j == l || k == l) {
                                continue;
                            }
                            add(dp[j][0][i], dp[k][l][i - 1]);
                        }
                    }
                }
            }   else {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (j == k) {
                            continue;
                        }
                        add(dp[j][0][i], dp[k][0][i - 1]);
                    }
                }
            }
        }
    }
    int res = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            add(res, dp[i][j][m]);
        }
    }
    cout << res;
}


Measured memory_bytes: 256