#include <iostream>
#include <string>    
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans;
string s1, s2;
#define mod 1000000007

int main() {
	cin >> n >> s1 >> s2;
	
	bool flag;//1 color : 2color
	for(int i = 0; i < n; i++){
		if(i == 0){
			if(s1[0] == s2[0]){ans = 3; flag = true;}
			else{ans = 6; flag = false; i++;}
		}
		else{
			if(flag){
				if(s1[i] == s2[i]){ans *= 2;}
				else{ans *= 2; flag = false; i++;}
			}
			else{
				if(s1[i] == s2[i]){flag = true;}
				else{ans *= 3; flag = false; i++;}
			}
			ans %= mod;
		}
	}
	
	cout << ans;
	return 0;
}