#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
char str[2][60];
const ll mod=1e9+7;
int main()
{
	int n;
	scanf("%d%s%s",&n,str[0],str[1]);
	ll ans;
	if(str[0][0]==str[1][0])ans=3;
	else ans=6;
	rep(i,1,n)
	{
		if(str[0][i-1]==str[1][i-1])ans=ans*2%mod;
		else if(str[0][i]!=str[0][i-1]&&str[0][i]!=str[1][i])ans=ans*3%mod;
	}
	printf("%lld\n",ans);
	return 0;
}
