#include <iostream>
#include <vector>
using namespace std;
const long long mod = (1e9) + 7;

int main(){
  int N;
  cin >> N;
  vector<string> S(2);
  for(int i = 0; i < 2; ++i) cin >> S[i];
  long long ans = 3;
  for(int i = 0; i < N; ++i){
    
    if(S[0][i] != S[1][i]){
      if(i > 0 && S[0][i-1] != S[1][i-1])
        ans *= 3;
      else ans *= 2;
      ans %= mod;
      ++i;
    }else if(i > 0 && S[0][i-1] == S[1][i-1]){
      ans *= 2;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
