#include<iostream>
#include<string>
#define LL long long
LL MOD = (LL)(1e9+7);
using namespace std;
int main(){
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    LL ans=1;
    int i=0;
    while(i<n){
        //cout<<i<<endl;
        if(i==0){
            if(s1[0]==s2[0]){
                ans*=3;
                i++;
            }
            else if(s1[0]==s1[1]){
                ans*=6;
                i+=2;
            }
        }

        else{
            if(s1[i-1]==s2[i-1] && s1[i]==s2[i]){
                ans*=2;
                ans%=MOD;
                i++;
            }
            if(s1[i-1]==s2[i-1] && s1[i]==s1[i+1]){
                ans*=2;
                ans%=MOD;
                i+=2;
            }
            if(s1[i-2]==s1[i-1] && s1[i]==s1[i+1]){
                ans*=3;
                ans%=MOD;
                i+=2;
            }
            if(s1[i-2]==s1[i-1] && s1[i]==s2[i]){
                i++;
            }
            //cout<<ans<<endl;
        }
    }
    cout<<ans<<endl;
}