#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

// {{{ ModInt
template<int _MOD>
struct ModInt {
   static const auto MOD = _MOD;
   template<class T> using integral_only = typename enable_if<is_integral<T>::value>::type;
    int x;   
   constexpr ModInt() : x() {}
   template<class T, integral_only<T>* = nullptr>
    ModInt(T _x=0) {
      x = _x % MOD;
      if(x<0) x+=MOD;
   }
    ModInt operator-() const { return {x == 0? 0 : MOD-x}; }
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        x = (long long)x * a.x % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt a) {
        return (*this) *= a.inv();
    }
    ModInt operator+(const ModInt a) const { return ModInt(*this) += a; }
    ModInt operator-(const ModInt a) const { return ModInt(*this) -= a; }
    ModInt operator*(const ModInt a) const { return ModInt(*this) *= a; }
    ModInt operator/(const ModInt a) const { return ModInt(*this) /= a; }
    ModInt inv() const {
       // for prime MOD
        return pow(MOD-2);
    }
   ModInt inv2() const {
      // work for non-prime MOD if gcd(x,MOD) = 1
      int a = x, b = MOD, u = 1, v = 0;
      while(b != 0) {
         int t = a / b;
         a -= t * b;
         u -= t * v;
         swap(a, b);
         swap(u, v);
      }
      return u;
   }
   template<class T, integral_only<T>* = nullptr>
    ModInt pow(T t) const {
      ModInt r = 1, p = *this;
      while(t) {
         if(t & 1) r *= p;
         p *= p;
         t >>= 1;
      }
        return r;
    }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    bool operator<(ModInt rhs) const { return x < rhs.x; }
    bool operator<=(ModInt rhs) const { return x <= rhs.x; }
    bool operator>(ModInt rhs) const { return x > rhs.x; }
    bool operator>=(ModInt rhs) const { return x >= rhs.x; }
    friend string to_string(ModInt i) { return to_string(i.x); }
    friend istream& operator>>(istream&i,ModInt&a) { return i>>a.x; }
    friend ostream& operator<<(ostream&o,const ModInt&a) { return o<<a.x; }
};
const int MOD=1000000007;
using mint=ModInt<MOD>;
// }}}

const int N=60;
char s[2][N];
mint dp[5][5], ndp[5][5];
int main() {
   int n;
   cin >> n;
   for (int i=0; i<2; i++) {
      scanf("%s", s[i]);
   }
   for (int i=0; i<3; i++) {
      for (int j=0; j<3; j++) {
         if ( s[0][0]==s[1][0] ) {
            if ( i==j ) {
               dp[i][j]=1;
            }
         } else {
            if ( i!=j ) {
               dp[i][j]=1;
            }
         }
      }
   }
   for (int k=1; k<n; k++) {
      memset(ndp,0,sizeof(ndp));
      for (int i=0; i<3; i++) {
         for (int j=0; j<3; j++) {
            for (int a=0; a<3; a++) {
               for (int b=0; b<3; b++) {
                  if ( s[0][k]==s[1][k] ) {
                     // case 
                     // bb or bc
                     // aa.   aa
                     if ( i!=j ) continue;
                     if ( i==a || j==b ) continue;
                     if ( s[0][k-1]==s[1][k-1] ) {
                        if ( a==b ) {
                           ndp[i][j]+=dp[a][b];
                        }
                     } else {
                        if ( a!=b ) {
                           ndp[i][j]+=dp[a][b];
                        }
                     }
                  } else {
                     if ( i==j ) continue;
                     if ( s[0][k-1]==s[0][k] ) {
                        //  case
                        // ab
                        // ab
                        if ( i!=a || j!=b ) continue;
                        ndp[i][j]+=dp[a][b];
                     } else {
                        // case:
                        // aa, ab
                        // bc, cd
                        if ( i==a || j==b ) continue;
                        if ( s[0][k-1]==s[1][k-1] ) {
                           if ( a!=b ) continue;
                           ndp[i][j]+=dp[a][b];
                        } else {
                           if ( a==b ) continue;
                           ndp[i][j]+=dp[a][b];
                        }
                     }
                  }
               }
            }
         }
      }
      swap(dp,ndp);
   }
   mint ans=0;
   for (int i=0; i<3; i++) {
      for (int j=0; j<3; j++) {
         if ( s[0][n-1]==s[1][n-1] ) {
            if ( i==j ) ans+=dp[i][j];
         } else {
            if ( i!=j )ans+=dp[i][j];
         }
      }
   }
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 256