#include <iostream>
#include <vector>
#include <string>
#define mod 1000000007

using namespace std;

int main(void){
	int n;

	string s1, s2;

	cin >> n >> s1 >> s2;

	long long int num = 0;

	int x = 0;

	if (s1[0] == s2[0]){
		num = 3;
		x++;
	}
	else {
		num = 6;
		x = 2;
	}


	while (x < n){
		if (s1[x] == s2[x]){
			if (s1[x-1] == s2[x-1]){
				num = 2 * num % mod;
				x++;
			}
			else {
				x++;
			}
		}
		else {
			if (s1[x-1] == s2[x-1]){
				num = 2 * num % mod;
				x += 2;
			}
			else {
				num = 3 * num % mod;
				x += 2;
			}
		}
	}

	cout << num << endl;
}