#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <time.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <math.h>
//#include <bits/stdc++.h>
#define ll long long
#define int64 long long
#define mem(x,y) memset(x,y,sizeof(x))
#define ull unsigned long long
#define pb push_back
#define INF 0x3f3f3f3f
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1
#define pi 3.141592653589793238462
#define stdio std::ios::sync_with_stdio(false)

using namespace std;

inline bool nextDouble(double &num) {
    char in;
    double Dec = 0.1;
    bool IsN = false, IsD = false;
    in = getchar();
    if (in == EOF) return false;
    while (in != '-' && in != '.' && (in < '0' || in > '9'))
        in = getchar();
    if (in == '-') {
        IsN = true;
        num = 0;
    } else if (in == '.') {
        IsD = true;
        num = 0;
    } else num = in - '0';
    if (!IsD) {
        while (in = getchar(), in >= '0' && in <= '9') {
            num *= 10;
            num += in - '0';
        }
    }
    if (in != '.') {
        if (IsN) num = -num;
        return true;
    } else {
        while (in = getchar(), in >= '0' && in <= '9') {
            num += Dec * (in - '0');
            Dec *= 0.1;
        }
    }
    if (IsN) num = -num;
    return true;
}
inline bool nextInt(int &num) {
    char in;
    bool IsN = false;
    in = getchar();
    if (in == EOF) return false;
    while (in != '-' && (in < '0' || in > '9')) in = getchar();
    if (in == '-') {
        IsN = true;
        num = 0;
    } else num = in - '0';
    while (in = getchar(), in >= '0' && in <= '9') {
        num *= 10, num += in - '0';
    }
    if (IsN) num = -num;
    return true;
}
inline bool nextLong(ll &num) {
    char in;
    bool IsN = false;
    in = getchar();
    if (in == EOF) return false;
    while (in != '-' && (in < '0' || in > '9')) in = getchar();
    if (in == '-') {
        IsN = true;
        num = 0;
    } else num = in - '0';
    while (in = getchar(), in >= '0' && in <= '9') {
        num *= 10, num += in - '0';
    }
    if (IsN) num = -num;
    return true;
}
inline void Out(int a) {
    if (a < 0) {
        putchar('-');
        a = -a;
    }
    if (a >= 10) {
        Out(a / 10);
    }
    putchar(a % 10 + '0');
}
const int maxn = 1e5 + 5;
const int maxm = 1e3 + 5;
const int mod = 1e9 + 7;
const int seed = 10007;
const double eps = 1e-6;
string s[2];

int main() {
    stdio;
    int n;
    cin >> n;
    for (int i = 0; i < 2; i++) {
        cin >> s[i];
    }
    ll ans = 1;
    int dir = -1;
    //heng 0 shu 1
    if (s[0][0] == s[0][1]) {
        ans = ans * 3 * 2;
        dir = 0;
        //cout<<"*3*2"<<endl;
    } else if (s[0][0] == s[1][0]) {
        ans = ans * 3;
        dir = 1;
        //cout<<"*3"<<endl;
    }
    for (int i = (dir == 0 ? 2 : 1); i < n; i++) {
        if (i < n - 1 && s[0][i] == s[0][i + 1]) {
            //cout<<"i="<<i<<":  ";
            if (dir == 0) {
                ans *= 3;
                //cout<<"*3"<<endl;
            } else {
                ans *= 2;
                dir = 0;
                //cout<<"*2"<<endl;
            }
            ans %= mod;
            i++;
        } else if (s[0][i] == s[1][i]) {
            //cout<<"i="<<i<<":  ";
            if (dir == 0) ans *= 1, dir = 1;
            else ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256