import std.stdio,
       std.string,
       std.conv;

void main() {
  int N = readln.chomp.to!(int);
  string[] S;
  bool[] tate;
  for (int i = 0; i < 2; i++) {
    S ~= readln.chomp;
  }
  for (int i = 0; i < N; i++) {
    if (S[0][i] == S[1][i]) {
      tate ~= true;
    }
    else {
      tate ~= false;
      i++;
    }
  }

  long ans = (tate[0] ? 3 : 6);
  for (int i = 1; i < tate.length; i++) {
    long kake;
    if (tate[i]) {
      kake = (tate[i - 1] ? 2 : 1);
    }
    else {
      kake = (tate[i - 1] ? 2 : 3);
    }
    ans = (ans * kake) % 1000000007;
  }

  ans.writeln;
}
