#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define  mem memset(a,0,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;

typedef long long ll;
using namespace std;

int main()
{
    char a[2][100];
    int n,i,j;
    cin>>n;
    cin>>a[0];
    cin>>a[1];
    int x=-1;
    ll sum=1;
    for(i=0;i<n;i++)
    {
        if(a[0][i]==a[0][i+1])
        {
            if(x==-1)
            {
                sum=sum*3*2;
                sum=sum%mo;
            }
            else if(x==1)
            {
                sum=sum*2;
                sum=sum%mo;
            }
            else if(x==0)
            {
                sum=sum*3;
                sum=sum%mo;
            }
            x=0;
        }
        else if(a[0][i]==a[1][i])
        {
            if(x==-1)
            {
                sum=sum*3;
                sum=sum%mo;
            }
            else if(x==1)
            {
                sum=sum*2;
                sum=sum%mo;
            }
            else if(x==0)
            {
                sum=sum*1;
                sum=sum%mo;
            }
            x=1;
        }
    }
    cout<<sum<<endl;
    return 0;
}