#include <cmath>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
inline void read(int &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}
inline void read(long long &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}
inline void write(long long x){
    static const int maxlen=100;
    static char s[maxlen];
        if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    int len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(int i=len-1;i>=0;--i) putchar(s[i]);
}
inline void write(int x){
    static const int maxlen=100;
    static char s[maxlen];
        if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    int len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(int i=len-1;i>=0;--i) putchar(s[i]);
}

const int maxn=210;

int n;
char s[maxn];
//long long f[maxn][10];
int a[maxn];
const int P=1000000007;

int main(){
    read(n);
    scanf("%s",s);
    scanf("%s",s);
    int cnt=0;
    for (int i=0;i<n;i++)
        {
            if  ( (i<n-1) && (s[i]==s[i+1]) )
                {
                    a[++cnt]=2;
                    i++;
                    continue;
                }
            else
                a[++cnt]=1;
        }

    /*f[0][0]=1;
    for (int i=0;i<cnt;i++)
        for (int j=0;j<  7 ;j++)
        {
            //printf("%d %d %d\n",i,j,f[i][j]);
            if (f[i][j])
                {
                    if (a[i+1]==2)
                        {
                            if ( ( j&k )==0 )
                                f[i+1][k]+=f[i][j];
                        }
                    else
                    {
                        for (int k=1; k <  7 ;k = k*2 )
                            if (  (j&k )==0 )
                            {
                                //printf("%d %d %d\n",i, j ,k);
                                f[i+1][k]+=f[i][j];
                            }
                    }
                }
        }
    for (int i=1;i<=2;i++)
    {
        for (int j=1;j<=7;j++)
            printf("%d ",f[i][j]);
        puts("");
    }
    long long ans=0;
        if (a[cnt]==2)
            for (int k=1;k< 7 ;k++)
                ans= ( ans +f[ cnt ][ k ])%P;
        else
            for (int k=1;k< 7 ;k = (k<<1) )
                ans= ( ans +f[ cnt ][ k ])%P;*/
    long long ans=1;
    for (int i=1;i<=cnt;i++)
        if (a[i]==2)
        {
            if (i==1)
                ans=( ans*6ll )%P;
            else
                if (a[i-1]==2)
                    ans=( ans*3ll)%P;
                else
                    ans=( ans*2ll)%P;
        }
        else
        {
            if (i==1)
                ans=3;
            else
                if (a[i-1]==2)
                    ans=ans;
                else
                    ans=( ans*2ll)%P;
        }
    write(ans%P);
    puts("");
    return 0;
}


Measured memory_bytes: 256