MOD = 10**9 + 7

N = int(eval(input()))

S = eval(input())

S2 = eval(input())

check = []

flg = False

for i in range(N-1):

    if flg:

        check.append(2)

        flg = False

        continue

    if S[i] == S[i+1]:

        flg = True

    else:

        check.append(1)

if flg:

    check.append(2)

else:

    check.append(1)

ans = 3 if check[0] == 1 else 6

for i in range(1,len(check)):

    if check[i-1] == 1:

        ans *= 2

    elif check[i] == 2 and check[i-1] == 2:

        ans *= 3

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

N = int(eval(input()))

S1 = eval(input())

S2 = eval(input())

check = []

index = 0

while index < N:

    if S1[index] == S2[index]:

        check.append(1)

        index += 1

    else:

        check.append(2)

        index += 2

ans = 3 if check[0] == 1 else 6

for i in range(1,len(check)):

    if check[i-1] == 1:

        ans *= 2

    elif check[i] == 2:

        ans *= 3

    ans %= MOD

print(ans)
MOD = 10**9 + 7
N = int(eval(input()))
S = eval(input())
S2 = eval(input())
check = []
flg = False
for i in range(N - 1):
    if flg:
        check.append(2)
        flg = False
        continue
    if S[i] == S[i + 1]:
        flg = True
    else:
        check.append(1)
if flg:
    check.append(2)
else:
    check.append(1)
ans = 3 if check[0] == 1 else 6
for i in range(1, len(check)):
    if check[i - 1] == 1:
        ans *= 2
    elif check[i] == 2 and check[i - 1] == 2:
        ans *= 3
print((ans % MOD))

MOD = 10**9 + 7
N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
check = []
index = 0
while index < N:
    if S1[index] == S2[index]:
        check.append(1)
        index += 1
    else:
        check.append(2)
        index += 2
ans = 3 if check[0] == 1 else 6
for i in range(1, len(check)):
    if check[i - 1] == 1:
        ans *= 2
    elif check[i] == 2:
        ans *= 3
    ans %= MOD
print(ans)

-S = eval(input()) +S1 = eval(input()) -flg = False -for i in range(N - 1): -    if flg: +index = 0 +while index < N: +    if S1[index] == S2[index]: +        check.append(1) +        index += 1 +    else: -        flg = False -        continue -    if S[i] == S[i + 1]: -        flg = True -    else: -        check.append(1) -if flg: -    check.append(2) -else: -    check.append(1) +        index += 2 -    elif check[i] == 2 and check[i - 1] == 2: +    elif check[i] == 2: -print((ans % MOD)) +    ans %= MOD +print(ans)