#include <iostream>
#include <vector>

using namespace std;

#define M 1000000007;

int main() {

	int n;
	cin >> n;

	vector< vector<char> > mp(n, vector<char>(2));

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> mp[j][i];
		}
	}

	if (n == 1) {
		cout << 3 << endl;
	}
	else {
		long long int ans = 6;

		for (int i = 1; i < n-1; i++) {
			if (mp[i][0] == mp[i+1][0]) {
				ans *= 1;
			}
			else if (mp[i][0] == mp[i][1]) {
				ans *= 2;
			}
			else if (mp[i + 1][0] == mp[i + 1][1]) {
				ans *= 1;
			}
			else {
				ans *= 3;
			}
			ans %= M;
		}
		cout << ans << endl;
	}

	return 0;
}