#include<bits/stdc++.h>

using namespace std;

#define INF LLONG_MAX
#define ll long long int
#define MP make_pair
#define PF push_front
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define F first
#define S second
#define tr(i,c) for(__typeof(c.begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(i,v) for(__typeof(v.rbegin()) i = (v).rbegin() ; i != (v).rend() ; i++)
#define sint(n); scanf("%d",&n);
#define sll(n); scanf("%lld",&n);
#define pint(n); printf ("%d\n",n);
#define pll(n); printf ("%lld\n",n);
#define sst(n); scanf("%s",n);
#define pst(n); printf ("%s\n",n);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define set(a,b) memset(a, b, sizeof(a))
#define DRT() ll tst;cin>>tst;for(ll test=1;test<=tst;test++)
#define present(c,x) ((c).find(x) != (c).end())

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll MOD = 1000000007;

/*
    Inbuilt GCC compiler functions
    __gcd(x, y)
    
    int __builtin_ffs (int x)    [ Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero ]
    int __builtin_ffsll (long long) [ Similar to __builtin_ffs, except the argument type is long long ]
    
    int __builtin_clz (unsigned int x)  [ Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined ]
    int __builtin_clzll (unsigned long long)   [ Similar to __builtin_clz, except the argument type is unsigned long long ]
    
    int __builtin_popcount (unsigned int x)  [ Returns the number of 1-bits in x ]
    int __builtin_popcountll (unsigned long long)  [ Similar to __builtin_popcount, except the argument type is unsigned long long ]
*/


inline void add(ll &x, ll y){x+=y; if(x>=MOD)x-=MOD; if(x<0)x+=MOD;}
inline ll mul(ll x, ll y){ return ((ll)x * y)%MOD;}
ll gcd(ll a, ll b){ if(b)return gcd(b,a%b); return a;}
ll power(ll a ,ll p){ll ret = 1; while(p){if(p&1)ret=mul(ret,a); a=mul(a,a); p/=2;}return ret;}
ll phi(ll n){ ll ret=n; ll i = 2;                    // Counts the positive integers up to a given integer n that are relatively prime to n
    if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;}
    for(i=3; i*i<=n; i++)if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;}
    if(n>1)ret-=ret/n;return ret;
}

typedef pair<ll, ll> PLL;
typedef vector<ll> VLL;

int main()
{
    ll n;
    cin>>n;
    char s[2][100];
    sst(s[0]);
    sst(s[1]);
    
    ll ans = 1;
    char mode, stats[100];
    f(i, 0, n)
    {
        if (s[0][i] == s[1][i])
            mode = 'v';
        else
        {
            mode = 'h';
        }
        stats[i] = mode;
        //cout<<mode<<endl;
        if (mode == 'v')
        {
            if (i==0)
                ans=3;
            else
            {
                if (stats[i-1] == 'v')
                    ans*=2;
                else
                    ans*=1;
            }
        }
        else
        {
            if (i==0)
                ans=3*2;
            else
            {
                if (stats[i-1] == 'v')
                    ans*=2;
                else
                    ans*=3;
            }
        }
        ans %= MOD;
        if (mode == 'h')
            i++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256