//####################################################################
//#####In the Name Of Allah,the Most Gracious,the Most Merciful.######
//####################################################################
//############Created by Sazid Rahman Simanto on 3/20/17.#############
//#####Copyright 2017 Sazid Rahman Simanto. All rights reserved.######
//####################################################################

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define MSET(a,x) memset(a,x,sizeof a)
#define FOR(i,x,y) for(int i=(x);i<=(y);i++)
#define FORR(i,x,y) for(int i=(x);i<(y);i++)
#define ROF(i,x,y) for(int i=(y);i>=(x);i--)
#define SQ(x) ((x)*(x))
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ff first
#define ss second
#define pb push_back
#define inf             1061109567
#define maxn            100010
#define esp             1e-6
#define mod             1000000007
#define ll              long long
#define ull             unsigned long long
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define read()          freopen("input.txt", "r", stdin)
#define write()         freopen("output.txt", "w", stdout)


typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef complex<double> base;
const double PI = acos(- 1);

template <class T> inline T bigmod(T a, T b,T M) {
        ll ret = 1;
        for(; b > 0; b >>= 1) {
                if(b & 1) ret = (ret * a) % M;
                a = (a * a) % M;
        }
        return ret;
}

template <class T> inline T gcd ( T a, T b ) {

        while (b) {
                a = a % b;
                swap ( a, b );
        }
        return a;
}


template <class T> inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }

template <class T> inline T poww(T a, T b) {
        ll ret = 1;
        for(; b > 0; b >>= 1) {
                if(b & 1) ret = ret * a;
                a = a * a;
        }
        return (T)ret;
}

pii exEuclid(int a, int b) {
        if(b == 0) return pii(1, 0);
        else {
                pii r = exEuclid(b, a % b);
                return pii(r.ss, r.ff - r.ss * (a / b));
        }
}

int modInv(int a, int m) { pii ret = exEuclid(a, m); return ((ret.ff % m) + m ) % m; }



int Set(int N, int pos) {return N = N | (1 << pos);}
int reset(int N, int pos) {return N = N & ~ (1 << pos);}
bool check(int N, int pos) {return (bool) (N & (1 << pos));}

//####################################################################
//##################Template Ends Here################################
//####################################################################
string up , dw, m;
int arr[110], n;
ll dp[110][3][10];

ll dpfun(int i, int last, int color, int c1, int c2)
{
        if(i >= n) return 1;

        if(dp[i][last][color] != -1) return dp[i][last][color];

        ll ret = 0;

        if(!last){
                if(arr[i] == 2){
                        FOR(j, 1, 3){
                                FOR(k, 1, 3){
                                        if(j == k) continue;
                                        ret = (ret + dpfun(i + 1, 2, j + k, j, k)) % mod;
                                }
                        }
                }
                else{
                        FOR(j, 1, 3) ret = (ret + dpfun(i + 1, 1, j, 0, 0)) % mod;
                }
        }
        else if(last == 1){
                if(arr[i] == 1){
                        FOR(j, 1, 3){
                                if(j != color)
                                        ret = (ret + dpfun(i + 1, 1, j, 0, 0)) % mod;
                        }
                }
                else{
                       FOR(j, 1, 3){
                                FOR(k, 1, 3){
                                        if(j == k || j == color || k == color) continue;
                                        ret = (ret + dpfun(i + 1, 2, j + k, j, k)) % mod;
                                }
                        }
                }
        }
        else{
                if(arr[i] == 1){
                        ret = (ret + dpfun(i + 1, 1, 6 - color, 0, 0)) % mod;
                }
                else{
                       FOR(j, 1, 3){
                                FOR(k, 1, 3){
                                        if(j == k || (j == c1) || (k == c2)) continue;
                                        ret = (ret + dpfun(i + 1, 2, j + k, j, k)) % mod;
                                }
                        }
                }
        }

        return dp[i][last][color] = ret;
}

int main()
{

        cin >> m >> up >> dw;

        for(int i = 0; i < up.size(); ){
                if(up[i] == dw[i]){
                        arr[n ++] = 1;
                        i++;
                }
                else{
                        arr[n ++] = 2;
                        i += 2;
                }
        }
        MSET(dp, -1);

        ll ans = dpfun(0, 0, 0, 0, 0);

        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256