#include <iostream>

int main(){
    int n;
    unsigned long long ans;
    std::string s1, s2;
    std::cin >> n >> s1 >> s2;
    int i;
    if(s1[0]==s1[1]){
        i = 2;
        ans = 6;
    } else {
        i = 1;
        ans = 3;
    }
    int p;
    for(; i < n; i++){
        if(s1[i]==s1[i+1]){
            if(s1[i-2]==s1[i-1]) p = 3;
            else p = 2;
            i++;
        } else {
            if(s1[i-2]==s1[i-1]) p = 1;
            else p = 2;
        }
        ans = (ans * p) % 1000000007;
    }
    std::cout << ans << std::endl;
}
