#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1000000007
using namespace std;

int p[3][3];

int main(){
  p[0][1]=3;
  p[0][2]=6;
  p[1][1]=2;
  p[1][2]=2;
  p[2][1]=1;
  p[2][2]=3;
  int N;
  string s,S2;
  long int ans = 1;
  cin >> N >> s >> S2;
  vector<int> v(1,0);
  FOR(i,0,N){
    if(s[i] == s[i+1]){
      v.push_back(2);
      i++;
    }
    else{
      v.push_back(1);
    }
  }
  FOR(i,0,v.size()-1){
    ans *= p[v[i]][v[i+1]];
    ans %= INF;
  }
  cout << ans << endl;
}

//0→2 6
//0→1 3
//2→1 1
//2→2 3
//1→1 2
//1→2 2
