/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

constexpr int MOD = 1000 * 1000 * 1000 + 7;

class arc81D {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<string> v(2);
        for (int i = 0; i < 2; ++i) {
            in >> v[i];
        }
        vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(3, vector<long long>(3, 0)));
        //dp[i][j][k] = num ways to end after i with color j on top, k on bot
        int i;
        if (v[0][0] == v[1][0]) {
            i = 0;
            dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
        } else {
            i = 1;
            dp[1][0][1] = dp[1][0][2] = dp[1][1][0] = dp[1][1][2] = dp[1][2][0] = dp[1][2][1] = 1;
        }
        for (; i < N; ++i) {
            if (v[0][i + 1] == v[1][i + 1]) {
                for (int j = 0; j < 3; ++j) {
                    for (int k = 0; k < 3; ++k) {
                        if (j != 0 && k != 0) {
                            dp[i + 1][0][0] += dp[i][j][k];
                            dp[i + 1][0][0] %= MOD;
                        }
                        if (j != 1 && k != 1) {
                            dp[i + 1][1][1] += dp[i][j][k];
                            dp[i + 1][1][1] %= MOD;
                        }
                        if (j != 2 && k != 2) {
                            dp[i + 1][2][2] += dp[i][j][k];
                            dp[i + 1][2][2] %= MOD;
                        }
                    }
                }
            } else {
                for (int j = 0; j < 3; ++j) {
                    for (int k = 0; k < 3; ++k) {
                        for (int a = 0; a < 3; ++a) {
                            if (a != j) {
                                for (int b = 0; b < 3; ++b) {
                                    if (b != a && b != k) {
                                        dp[i + 2][a][b] += dp[i][j][k];
                                        dp[i + 2][a][b] %= MOD;
                                    }
                                }
                            }
                            
                        }
                    }
                }
            }
        }
        /*for (int i = 0; i <= N; ++i) {
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 3; ++k) {
                    out << dp[i][j][k] << " ";
                }
                out << "\n";
            }
            out << "\n";
        }*/
        long long res = 0;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                res += dp[N - 1][j][k];
            }
        }
        out << res % MOD << "\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);

	arc81D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256