#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

const ll MOD = 1000 * 1000 * 1000 + 7;

ll dp[100][3][3];

int main() {
    int n;
    map<char, int> recorder;
    string s[2];
    cin >> n;
    cin >> s[0] >> s[1];

    if (s[0][0] == s[1][0]) {
        dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
        for (int i = 0; i < n - 1; i++) {
            for (int c1 = 0; c1 < 3; c1++) {
                for (int c2 = 0; c2 < 3; c2++) {
                    if (dp[i][c1][c2] == 0) continue;

                    // 同色
                    if (s[0][i + 1] == s[1][i + 1]) {
                        for (int c3 = 0; c3 < 3; c3++) {
                            if (c1 == c3 || c2 == c3) continue;
                            dp[i + 1][c3][c3] += dp[i][c1][c2];
                            dp[i + 1][c3][c3] %= MOD;
                        }
                    } else {
                        // 異なる色
                        for (int c3 = 0; c3 < 3; c3++) {
                            for (int c4 = 0; c4 < 3; c4++) {
                                if (c3 == c4 || c1 == c3 || c2 == c4) continue;
                                dp[i + 2][c3][c4] += dp[i][c1][c2];
                                dp[i + 2][c3][c4] %= MOD;
                            }
                        }
                    }

                }
            }
        }
    } else {
        for (int c1 = 0; c1 < 3; c1++) {
            for (int c2 = 0; c2 < 3; c2++) {
                if (c1 != c2) {
                    dp[1][c1][c2] = 1;
                }
            }
        }
        for (int i = 1; i < n - 1; i++) {
            for (int c1 = 0; c1 < 3; c1++) {
                for (int c2 = 0; c2 < 3; c2++) {
                    if (dp[i][c1][c2] == 0) continue;

                    // 同色
                    if (s[0][i + 1] == s[1][i + 1]) {
                        for (int c3 = 0; c3 < 3; c3++) {
                            if (c1 == c3 || c2 == c3) continue;
                            dp[i + 1][c3][c3] += dp[i][c1][c2];
                            dp[i + 1][c3][c3] %= MOD;
                        }
                    } else {
                        // 異なる色
                        for (int c3 = 0; c3 < 3; c3++) {
                            for (int c4 = 0; c4 < 3; c4++) {
                                if (c3 == c4 || c1 == c3 || c2 == c4) continue;
                                dp[i + 2][c3][c4] += dp[i][c1][c2];
                                dp[i + 2][c3][c4] %= MOD;
                            }
                        }
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (int c1 = 0; c1 < 3; c1++) {
        for (int c2 = 0; c2 < 3; c2++) {
            ans += dp[n - 1][c1][c2];
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256