import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int n; readV(n);
  string[] s; readC(2, s);

  bool[] b;
  for (auto i = 0; i < n; ++i) {
    if (s[0][i] == s[1][i]) {
      b ~= true;
    } else {
      b ~= false;
      ++i;
    }
  }

  auto nb = b.length.to!int, dp = new mint[][][](nb, 3, 3);
  if (b[0])
    foreach (i; 0..3)
      dp[0][i][i] = 1;
  else
    foreach (i; 0..3)
      foreach (j; 0..3)
        if (i != j)
          dp[0][i][j] = 1;

  foreach (k; 1..nb)
    if (b[k]) {
      foreach (i; 0..3)
        foreach (x; 0..3)
          foreach (y; 0..3)
            if (i != x && i != y)
              dp[k][i][i] += dp[k-1][x][y];
    } else {
      foreach (i; 0..3)
        foreach (j; 0..3)
          foreach (x; 0..3)
            foreach (y; 0..3)
              if (i != j && i != x && j != y)
                dp[k][i][j] += dp[k-1][x][y];
    }

  auto r = mint(0);
  foreach (i; 0..3)
    foreach (j; 0..3)
      r += dp[$-1][i][j];

  writeln(r);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}
