#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;

using lint = long long;
const lint MOD = 1e9 + 7;
const int INF = 1e9;
const lint LINF = 1e18;
using flt = double;
const flt E = exp(1.0);
const flt PI = acos(-1.0);

// Class ModInteger<MOD>
template <lint mod>
class ModInteger {
    public:
    lint val;

    // Constructor
    ModInteger(): val(0) {}
    ModInteger(lint ival): val(ival >= 0? ival%mod: mod - (-ival)%mod) {}

    // Comparators
    bool operator !() {return val == 0;}
    bool operator <(ModInteger that) {return val < that.val;}
    bool operator >(ModInteger that) {return val > that.val;}
    bool operator <=(ModInteger that) {return val <= that.val;}
    bool operator >=(ModInteger that) {return val >= that.val;}
    bool operator ==(ModInteger that) {return val == that.val;}
    bool operator !=(ModInteger that) {return val != that.val;}

    // Basic operations
    ModInteger operator ++() {val++; return *this;}
    ModInteger operator --() {val--; return *this;}

    ModInteger& operator +=(ModInteger that) {val = (val + that.val)%mod; return *this;}
    ModInteger& operator -=(ModInteger that) {val = ((val - that.val)%mod + mod)%mod; return *this;}
    ModInteger& operator *=(ModInteger that) {val = (val*that.val)%mod; return *this;}
    ModInteger& operator /=(ModInteger that) {
        lint inv = that.val, rem = 1, power = mod - 2;
        while (power > 1) {if (power%2) rem = (rem*inv)%mod; inv = (inv*inv)%mod; power /= 2;}
        inv = (rem*inv)%mod;
        val = (val*inv)%mod;
        return *this;
    }

    ModInteger operator +(ModInteger that) {return ModInteger(*this) += that;}
    ModInteger operator -(ModInteger that) {return ModInteger(*this) -= that;}
    ModInteger operator *(ModInteger that) {return ModInteger(*this) *= that;}
    ModInteger operator /(ModInteger that) {return ModInteger(*this) /= that;}
    
    ModInteger& operator %=(ModInteger that) {val = val%that.val; return *this;}
    ModInteger operator %(ModInteger that) {return ModInteger(*this) %= that;}
}; using mint = ModInteger<MOD>;

// ModInteger input & output
istream& operator >>(istream& is, mint& n) {return is >> n.val;}
ostream& operator <<(ostream& os, mint n) {return os << n.val;}

// Macros
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define bit(n) (lint)1<<n
#define mrep(it, m) for (auto it = m.begin(); it != num.end(); it++)
#define fi first
#define se second
#define pint pair<int, int>
#define plint pair<lint, lint>
#define mp make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vlint vector<lint>
#define vvlint vector<vector<lint>>
#define pb push_back
#define all(v) v.begin(), v.end()
#define asort(v) sort(all(v))
#define dsort(v) sort(all(v)); reverse(all(v))
#define maxval(v) *max_element(all(v))
#define maxindex(v) distance(v.begin(), max_element(all(v)))
#define minval(v) *min_element(all(v))
#define minindex(v) distance(v.begin(), min_element(all(v)))

// Sort by an arbitrary comparator (example)
/*
    sort(all(v), [](pint a, pint b) {return !(a.se == b.se)? a.se < b.se: a.fi < b.fi;});
*/

// Basic functions (be careful of overflowing!)
template <typename Tp>
Tp gcd(Tp m, Tp n) {
    if (!m || !n) {cout << "GCD error: zero inputed" << endl; return 0;}
    else if (!(m%n)) return n;
    else return gcd(n, m%n);
}
template <typename Tp>
Tp lcm(Tp m, Tp n) {
    if (!m || !n) {cout << "LCM error: zero inputed" << endl; return 0;}
    else return m*n/gcd(m, n);
}
template <typename Tp1, typename Tp2>
Tp1 ipow(Tp1 a, Tp2 p) {// For integers
    if (p < 0) {cout << "Power error: a minus number inputed" << endl; return 0;}
    else if (!p) return 1;
    Tp1 res = a, rem = 1;
    while (p > 1) {if (p%2) rem *= res; res *= res; p /= 2;}
    return rem*res;
}
template <typename Tp>
Tp fact(Tp n) {// Facorial: requires O(n)
    if (n < 0) {cout << "Factorial error: a minus number inputed" << endl; return 0;}
    else if (!n) return 1;
    else if (n == 1) return 1;
    else return n*fact(n - 1);
}
template <typename Tp>
void pfact(Tp n, map<Tp, int>& res) {// Prime factorization: requires O(sqrt(n))
    if (n <= 1) {cout << "Prime factorization error: cannot factorize an integer less than 2" << endl; return;}
    if (res.size()) cout << "Prime factorization warning: the map already contains some numbers" << endl;
    Tp pos = 2, pmax = n;
    while (pos*pos <= pmax) {if (!(n%pos)) {res[pos]++; n /= pos;} else pos++;}
    if (n != 1) res[n]++;
    return;
}
template <typename Tp>
Tp comb(Tp n, Tp r) {// Requires O(r)
    if (n < 0 || r < 0) {cout << "Combination error: a minus number inputed" << endl; return 0;}
    else {lint res = 1; rep(i, r) res *= (n - i)/(i + 1); return res;}
}

// Format for cout
/*
    // Integers
    cout << 42; -> 42
    cout << setfill('0') << setw(6) << 42; -> 000042

    // Floats
    cout << PI; -> 3.14159
    cout << fixed << PI; -> 3.141593 
    cout << fixed << setprecision(8) << PI; -> 3.14159265
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    // Input
    int n; cin >> n;
    string S[2]; cin >> S[0] >> S[1];

    // Initialize
    int pos = 0, prev; mint ans;
    if (S[0][0] == S[1][0]) {ans = 3; prev = 1;} else {ans = 6; pos++; prev = 2;}
    pos++;

    // Calculate
    while (pos < n) {
        if (prev == 1) {
            if (S[0][pos] == S[1][pos]) ans *= 2;
            else {ans *= 2; pos++; prev = 2;}
        } else {
            if (S[0][pos] == S[1][pos]) prev = 1;
            else {ans *= 3; pos++;}
        }
        pos++;
    }

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

Measured memory_bytes: 256