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

enum Direction { TATE, YOKO } last;
constexpr int MOD = 1000000007;

int main() {
  int64_t N, sum;
  string S1, S2;
  cin >> N >> S1 >> S2;
  for (int i = 0; i < N; ++i) {
    Direction now = S1[i] == S2[i] ? TATE : YOKO;
    if (i == 0) {
      if (now == TATE) {
        sum = 3;
      } else {
        sum = 6;
        ++i;
      }
    } else {
      if (now == TATE) {
        sum = sum * (last == TATE ? 2 : 1) % MOD;
      } else {
        sum = sum * (last == TATE ? 2 : 3) % MOD;
        ++i;
      }
    }
    last = now;
  }
  cout << sum << endl;
}
