#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

template <long long modulo> class Modulo {
private:
  long long inv() {
    long long p = mod - 2;
    long long ans = 1;
    for (; p != 0; p >>= 1LL) {
      if (p & 1LL)
        ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }

public:
  long long mod = modulo;
  unsigned long long x;
  Modulo() : x(0) {}
  Modulo(signed int s) {
    while (s < 0)
      s += mod;
    x = s % mod;
  }
  Modulo(signed long long s) {
    while (s < 0)
      s += mod;
    x = s % mod;
  }
  operator int() { return (int)x; }
  operator long long() { return (long long)x; }
  Modulo &operator+=(Modulo q) {
    if ((x += q.x) >= mod)
      x -= mod;
    return *this;
  }
  Modulo &operator-=(Modulo q) {
    if ((x += mod - q.x) >= mod)
      x -= mod;
    return *this;
  }
  Modulo &operator*=(Modulo q) {
    x = (unsigned long long)x * q.x % mod;
    return *this;
  }
  Modulo &operator/=(Modulo q) {
    x = (unsigned long long)x * q.inv() % mod;
    return *this;
  }
  Modulo operator+(Modulo q) { return Modulo(*this) += q; }
  Modulo operator-(Modulo q) { return Modulo(*this) -= q; }
  Modulo operator*(Modulo q) { return Modulo(*this) *= q; }
  Modulo operator/(Modulo q) { return Modulo(*this) /= q; }
  template <typename T> Modulo &operator+=(const T q) {
    if ((x += q) >= mod)
      x -= mod;
    return *this;
  }
  template <typename T> Modulo &operator-=(const T q) {
    if ((x += mod - q) >= mod)
      x -= mod;
    return *this;
  }
  template <typename T> Modulo &operator*=(const T q) {
    x = (unsigned long long)x * q % mod;
    return *this;
  }
  template <typename T> Modulo &operator/=(const T q) {
    x = (unsigned long long)x * (Modulo(q)).inv() % mod;
    return *this;
  }
  template <typename T> Modulo operator+(const T q) {
    return Modulo(*this) += q;
  }
  template <typename T> Modulo operator-(const T q) {
    return Modulo(*this) -= q;
  }
  template <typename T> Modulo operator*(const T q) {
    return Modulo(*this) *= q;
  }
  template <typename T> Modulo operator/(const T q) {
    return Modulo(*this) /= q;
  }
};

const long long MOD = 1000000007LL; // 10e9 + 7

void solve(long long N, vector<string> S) {
  Modulo<MOD> ans(1);

  bool preX = false;
  bool first = true;
  REP(i, N) {
    ll buf = 0;
    if (S[0][i] == S[1][i]) {
      // ||
      if (first) {
        buf = 3;
      } else {
        buf = preX ? 2 : 1;
      }
      preX = true;

    } else {
      // ==

      if (first) {
        buf = 6;
      } else {
        buf = preX ? 2 : 3;
      }
      i++;
      preX = false;
    }
    first = false;
    cerr << "*" << buf << " ";

    ans *= buf;
  }
  cerr << endl;

  cout << (ll)ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  vector<string> S(2 - 1 + 1);
  cin >> N;
  for (int i = 0; i <= 2 - 1; i++) {
    cin >> S[i];
  }
  solve(N, S);
  return 0;
}


Measured memory_bytes: 256