#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define bit(i) (1LL<<(i))
#define log(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#define endr cerr<<'\n'
#define endl '\n'
#ifndef DEBUG
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
#define int long long
#define mod inf

int n, block[N], ind = 0, dp[N][3], dp1[N][3][3];
string row1, row2;


void solveDP()
{
  if (block[1] == 0)
  {
    rep(c1, 3) rep(c2, 3)
    {
      if (c1 == c2) continue;
      dp1[1][c1][c2] = 1;
    }
  }
  else
  {
    rep(c0, 3)
    {
      dp[1][c0] = 1;
    }
  }

  for (int i=2; i<=ind; ++i)
  {
    if (block[i] == 1 && block[i-1] == 1)
    {
      rep(c0, 3) rep(c1, 3)
      {
        //if (c0 == c1) continue;
        if (c0 == c1) continue;
        dp[i][c0] += dp[i-1][c1];
        dp[i][c0] %= mod;
      }
    }
    else if (block[i] == 1 && block[i-1] == 0)
    {
      rep(c0, 3) rep(c1, 3) rep(c2, 3)
      {
        //if (c0 == c1 || c0 == c2 || c1 == c2) continue;
        if (c0 == c1 || c0 == c2 || c1 == c2) continue;
        dp[i][c0] += dp1[i-1][c1][c2];
        dp[i][c0] %= mod;
      }
    }
    else if (block[i] == 0 && block[i-1] == 1)
    {
      rep(c1, 3) rep(c2, 3) rep(c3, 3)
      {
        //if (c1 == c2 || c1 == c3 || c2 == c3) continue;
        if (c3 == c1 || c3 == c2 || c1 == c2) continue;
        dp1[i][c1][c2] += dp[i-1][c3];
        dp1[i][c1][c2] %= mod;
      }
    }
    else if (block[i] == 0 && block[i-1] == 0)
    {
      rep(c1, 3) rep(c2, 3) rep(c3, 3) rep(c4, 3)
      {
        //if (c1 == c2 || c1 == c3 || c1 == c4 || c2 == c3 || c2 == c4 || c3 == c4) continue;
        if (c1 == c2 || c3 == c4 || c1 == c3 || c2 == c4) continue;
        dp1[i][c1][c2] += dp1[i-1][c3][c4];
        dp1[i][c1][c2] %= mod;
      }
    }
  }

  int rst = 0;
  if (block[ind] == 1)
  {
    rep(c0, 3) rst += dp[ind][c0], rst %= mod;
  }
  else
  {
    rep(c1, 3) rep(c2, 3)
    {
      if (c1 == c2) continue;
      rst += dp1[ind][c1][c2], rst %= mod;
    }
  }

  cout<<rst;
}


void solve()
{
  cin>>n>>row1>>row2;
  row1 = '#' + row1 + '#';
  row2 = '#' + row2 + '#';

  for (int i=1; i<=n;)
  {
    if (row1[i] == row1[i+1]) block[++ind] = 0, i+=2; //dwa poziome
    else if (row1[i] == row2[i]) block[++ind] = 1, ++i; //pion
  }
  pa(block, ind);
  pv(ind);

  solveDP();

  for (int i=1; i<=ind; ++i)
  {
    pv(i);
    if (block[i] == 1)
    {
      rep(c0, 3)
      {
        pv(c0, dp[i][c0]);
      }
    }
    else
    {
      rep(c1, 3) rep(c2, 3)
      {
        pv(c1, c2, dp1[i][c1][c2]);
      }
    }

    endr;
  }
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


Measured memory_bytes: 4352