#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 60, mod = 1e9 + 7;
char a[3][N];
int f[N][10][2];

int getCnt( int x ){
    int res = 0;
    for ( int i = 2; i >= 0; i-- ){
        int bit = ( x >> i ) & 1;
        if ( bit ){
            res++;
        }
    }
    return res;
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    scanf("%d\n",&n);
    for ( int i = 1; i <= 2; i++ ){
        for ( int j = 1; j <= n; j++ ){
            scanf("%c",&a[i][j]);
        }
        scanf("\n");
    }
    for ( int msk = 0; msk <= 7; msk++ ){
        for ( int fl = 0; fl <= 1; fl++ ){
            f[n+1][msk][fl] = 1;
        }
    }
    for ( int i = n; i >= 1; i-- ){
        for ( int msk = 0; msk <= 7; msk++ ){
            for ( int fl = 0; fl <= 1; fl++ ){

                if ( a[1][i] == a[2][i] ){
                    for ( int clr = 0; clr <= 2; clr++ ){
                        int bit = ( msk >> clr ) & 1;
                        if ( !bit ){
                            f[i][msk][fl] = ( f[i][msk][fl] + f[i+1][ ( 1 << clr ) ][fl] ) % mod;
                        }
                    }
                }
                else{
                    int cntBits = getCnt(msk);
                    if ( cntBits < 2 ){
                        for ( int clr1 = 0; clr1 <= 2; clr1++ ){
                            for ( int clr2 = 0; clr2 <= 2; clr2++ ){
                                if ( clr1 == clr2 ){
                                    continue;
                                }
                                if ( ( 1 << clr1 ) + ( 1 << clr2 ) + msk == 7 ){
                                    int nxtMsk, nxtfl = 0;
                                    nxtMsk = ( 1 << clr1 ) + ( 1 << clr2 );
                                    if ( clr1 < clr2 ){
                                        nxtfl = 1;
                                    }
                                    f[i][msk][fl] = ( f[i][msk][fl] + f[i+2][nxtMsk][nxtfl] ) % mod;
                                }
                            }
                        }
                        continue;
                    }
                    int upClr = -1, downClr = -1;
                    for ( int clr = 0; clr <= 2; clr++ ){
                        if ( upClr == -1 ){
                            upClr = clr;
                        }
                        else{
                            downClr = clr;
                        }
                    }
                    if ( fl ){
                        swap( upClr, downClr );
                    }
                    for ( int clr1 = 0; clr1 <= 2; clr1++ ){
                        for ( int clr2 = 0; clr2 <= 2; clr2++ ){
                            if ( clr1 == clr2 ){
                                continue;
                            }
                            if ( clr1 != upClr && clr2 != downClr ){

                                int nxtMsk, nxtfl = 0;
                                nxtMsk = ( 1 << clr1 ) + ( 1 << clr2 );
                                if ( clr1 < clr2 ){
                                    nxtfl = 1;
                                }
                                f[i][msk][fl] = ( f[i][msk][fl] + f[i+2][nxtMsk][nxtfl] ) % mod;
                            }
                        }
                    }
                }
            }
        }
    }
    int ans = 0;
    if ( a[1][1] == a[2][1] ){
        for ( int j = 0; j <= 2; j++ ){
            ans = ( ans + f[2][ ( 1 << j ) ][0] ) % mod;
        }
    }
    else{
        for ( int i = 0; i <= 2; i++ ){
            for ( int j = 0; j <= 2; j++ ){
                if ( i == j ){
                    continue;
                }
                int msk = 0, fl = 0;
                msk = ( 1 << j ) + ( 1 << i );
                if ( i < j ){
                    fl = 1;
                }
                ans = ( ans + f[3][msk][fl] ) % mod;
            }
        }
    }
    printf("%d",ans);
    return 0;
}



Measured memory_bytes: 256