N = int(eval(input()))

grids = [[s for s in eval(input())],[s for s in eval(input())]]

MOD = 1000000007



if grids[0][0] == grids[1][0]:

  prv_row_type = 1

  ans = 3

  posx = 1

else:

  prv_row_type = -1

  ans = 6

  posx = 2



while posx < N:

  if grids[0][posx] ==  grids[1][posx]:

    if prv_row_type == 1: ans  *= 2

    else: ans *= 1

    prv_row_type = 1

    posx += 1

  else:

    if prv_row_type == 1: ans *= 2

    else: ans *= 3

    prv_row_type = -1

    posx += 2



print((ans%MOD))
MOD = 10 ** 9 + 7

N = int(eval(input()))

S1 = eval(input())

S2 = eval(input())



ans = 1

prv_ptn = 0 # 1 or 2

i = 0

while i < N:

    if S1[i] == S2[i]:

        if prv_ptn == 0:

            ans *= 3

        elif prv_ptn == 1:

            ans *= 2

        else:

            ans *= 1

        ans %= MOD

        prv_ptn = 1

        i += 1

    else:

        if prv_ptn == 0:

            ans *= 6

        elif prv_ptn == 1:

            ans *= 2

        else:

            ans *= 3

        ans %= MOD

        prv_ptn = 2

        i += 2

print((ans % MOD))

N = int(eval(input()))
grids = [[s for s in eval(input())], [s for s in eval(input())]]
MOD = 1000000007
if grids[0][0] == grids[1][0]:
    prv_row_type = 1
    ans = 3
    posx = 1
else:
    prv_row_type = -1
    ans = 6
    posx = 2
while posx < N:
    if grids[0][posx] == grids[1][posx]:
        if prv_row_type == 1:
            ans *= 2
        else:
            ans *= 1
        prv_row_type = 1
        posx += 1
    else:
        if prv_row_type == 1:
            ans *= 2
        else:
            ans *= 3
        prv_row_type = -1
        posx += 2
print((ans % MOD))

MOD = 10**9 + 7
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
ans = 1
prv_ptn = 0  # 1 or 2
i = 0
while i < N:
    if S1[i] == S2[i]:
        if prv_ptn == 0:
            ans *= 3
        elif prv_ptn == 1:
            ans *= 2
        else:
            ans *= 1
        ans %= MOD
        prv_ptn = 1
        i += 1
    else:
        if prv_ptn == 0:
            ans *= 6
        elif prv_ptn == 1:
            ans *= 2
        else:
            ans *= 3
        ans %= MOD
        prv_ptn = 2
        i += 2
print((ans % MOD))

+MOD = 10**9 + 7 -grids = [[s for s in eval(input())], [s for s in eval(input())]] -MOD = 1000000007 -if grids[0][0] == grids[1][0]: -    prv_row_type = 1 -    ans = 3 -    posx = 1 -else: -    prv_row_type = -1 -    ans = 6 -    posx = 2 -while posx < N: -    if grids[0][posx] == grids[1][posx]: -        if prv_row_type == 1: +S1 = eval(input()) +S2 = eval(input()) +ans = 1 +prv_ptn = 0  # 1 or 2 +i = 0 +while i < N: +    if S1[i] == S2[i]: +        if prv_ptn == 0: +            ans *= 3 +        elif prv_ptn == 1: -        prv_row_type = 1 -        posx += 1 +        ans %= MOD +        prv_ptn = 1 +        i += 1 -        if prv_row_type == 1: +        if prv_ptn == 0: +            ans *= 6 +        elif prv_ptn == 1: -        prv_row_type = -1 -        posx += 2 +        ans %= MOD +        prv_ptn = 2 +        i += 2