#include<iostream>
using namespace std;

int mod = 1000000007;

int N;
string a,b;
int main () {
    cin >> N >> a >> b;
    long long int cnt = ( a[0] != b[0] ? 6 : 3 );

    for(int i=1; i<N; i++) {
        if( a[i] == a[i-1] ) continue;
        if( a[i-1] == b[i-1] ) cnt *= 2;
        else if( a[i] != b[i] ) cnt *= 3;
        cnt %= mod;
    }
    cout << cnt << endl;
    return 0;
}
