#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<bitset>
using namespace std;
#define rep(i,a,b) for(register int i = a; i < b; ++ i)
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mkp make_pair

const int N = 100;
const ll mod = (ll)1e9 + 7;
char mp[2][N];

int main() {
	int n,i;
	ll ans;
	scanf("%d",&n);
	scanf("%s%s",mp[0],mp[1]);
	ans = 3;
	if(mp[0][0] == mp[1][0]) {
		i = 1;
	}
	else {
		i = 2;
		ans *= 2;
		ans %= mod;
	}
	for(; i < n; ++ i) {
		if(mp[0][i] == mp[1][i]) {
			if(mp[0][i - 1] == mp[1][i - 1]) {
				ans *= 2;
				ans %= mod;
			}
		/*	else {
				ans *= 1;
			}*/
		}
		else {
			if(mp[0][i - 1] == mp[1][i - 1]) {
				ans *= 2;
				ans %= mod;
			}
			else {
				ans *= 3;
				ans %= mod;
			}
			++ i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}