#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int n, mod = 1000000007;
string s[2];
ll ans = 1;

int main() {
	cin >> n >> s[0] >> s[1];
	
	bool flag;
	for (int i = 0; i < n; i++) {
		//cout << "i:" << i << endl;
		if (s[0][i] != s[1][i]) {
			if (i == 0)ans *= 6;
			else if (flag)ans *= 3;
			else ans *= 2;

			i++;
			flag = true;
		}
		else {
			if (i == 0)ans *= 3;
			else if (!flag)ans *= 2;

			flag = false;
		}
		ans %= mod;
	}

	cout << ans << endl;
}