output_description: Print the number of such ways to paint the dominoes, modulo 1000000007.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S_1
      S_2
attempt: N = int(input())
  S1 = input()
  S2 = input()
  
  MOD = 10**9 + 7
  
  
  class Mint:
      def __init__(self, value=0):
          self.value = value % MOD
          if self.value < 0:
              self.value += MOD
  
      @staticmethod
      def get_value(x):
          return x.value if isinstance(x, Mint) else x
  
      def inverse(self):
          a, b = self.value, MOD
          u, v = 1, 0
          while b:
              t = a // b
              b, a = a - t * b, b
              v, u = u - t * v, v
          if u < 0:
              u += MOD
          return u
  
      def __repr__(self):
          return str(self.value)
  
      def __eq__(self, other):
          return self.value == other.value
  
      def __neg__(self):
          return Mint(-self.value)
  
      def __hash__(self):
          return hash(self.value)
  
      def __bool__(self):
          return self.value != 0
  
      def __iadd__(self, other):
          self.value = (self.value + Mint.get_value(other)) % MOD
          return self
  
      def __add__(self, other):
          new_obj = Mint(self.value)
          new_obj += other
          return new_obj
  
      __radd__ = __add__
  
      def __isub__(self, other):
          self.value = (self.value - Mint.get_value(other)) % MOD
          if self.value < 0:
              self.value += MOD
          return self
  
      def __sub__(self, other):
          new_obj = Mint(self.value)
          new_obj -= other
          return new_obj
  
      def __rsub__(self, other):
          new_obj = Mint(Mint.get_value(other))
          new_obj -= self
          return new_obj
  
      def __imul__(self, other):
          self.value = self.value * Mint.get_value(other) % MOD
          return self
  
      def __mul__(self, other):
          new_obj = Mint(self.value)
          new_obj *= other
          return new_obj
  
      __rmul__ = __mul__
  
      def __ifloordiv__(self, other):
          other = other if isinstance(other, Mint) else Mint(other)
          self *= other.inverse()
          return self
  
      def __floordiv__(self, other):
          new_obj = Mint(self.value)
          new_obj //= other
          return new_obj
  
      def __rfloordiv__(self, other):
          new_obj = Mint(Mint.get_value(other))
          new_obj //= self
          return new_obj
  
  
  p = []
  i = 0
  while i < N:
      if S1[i] == S2[i]:
          p.append(1)
          i += 1
      else:
          p.append(0)
          i += 2
  ans = Mint(1)
  if p[0] == 1:
      ans *= 3
  else:
      ans *= 6
  for i in range(1, len(p)):
      if p[i] == 0:
          if p[i - 1] == 0:
              ans *= 3
          else:
              ans *= 2
      else:
          if p[i - 1] == 0:
              ans *= 1
          else:
              ans *= 2
  print(ans)
  
problem_description: Statement
  
  We have a board with a 2 \times N grid. Snuke covered the board with N
  dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1
  square.
  
  Then, Snuke decided to paint these dominoes using three colors: red, cyan and
  green. Two dominoes that are adjacent by side should be painted by different
  colors. Here, it is not always necessary to use all three colors.
  
  Find the number of such ways to paint the dominoes, modulo 1000000007.
  
  The arrangement of the dominoes is given to you as two strings S_1 and S_2 in
  the following manner:
  
    * Each domino is represented by a different English letter (lowercase or uppercase).
    * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.
samples: [{"input": "3\n    aab\n    ccb", "output": "6\n    \n\nThere are six ways as shown below:\n\n![](https://atcoder.jp/img/arc081/899673bd23529f4fb5e41c6e7d5bc372.png)\n\n* * *"}, {"input": "1\n    Z\n    Z", "output": "3\n    \n\nNote that it is not always necessary to use all the colors.\n\n* * *"}, {"input": "52\n    RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\n    RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn", "output": "958681902"}]