N = int(eval(input()))



S1 = eval(input())

S2 = eval(input())

MOD = 1000000007



if S1[0] == S2[0]:

    ans = 3

    pre = 1

else:

    ans = 6

    pre = 2

for i in range(1, N):

    if S1[i] == S1[i - 1]: continue

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

        if pre == 1:

            ans *= 2

        pre = 1

    else:

        if pre == 1:

            ans *= 2

        else:

            ans *= 3

        pre = 2

    ans %= MOD

print(ans)

MOD=10**9+7

N = int(eval(input()))

s1 = list(eval(input()))

s2 = list(eval(input()))

pre = s1[0] == s2[0]

if s1[0] == s2[0]:

    ans = 3

    idx = 1



else:

    ans = 6

    idx = 2

while idx < N:

    if pre:

        ans *= 2

    else:

        if s1[idx] != s2[idx]:

            ans *= 3



    pre=s1[idx] == s2[idx]

    if s1[idx] == s2[idx]:

        idx += 1

    else:

        idx += 2



print((ans%MOD))

N = int(eval(input()))
S1 = eval(input())
S2 = eval(input())
MOD = 1000000007
if S1[0] == S2[0]:
    ans = 3
    pre = 1
else:
    ans = 6
    pre = 2
for i in range(1, N):
    if S1[i] == S1[i - 1]:
        continue
    if S1[i] == S2[i]:
        if pre == 1:
            ans *= 2
        pre = 1
    else:
        if pre == 1:
            ans *= 2
        else:
            ans *= 3
        pre = 2
    ans %= MOD
print(ans)

MOD = 10**9 + 7
N = int(eval(input()))
s1 = list(eval(input()))
s2 = list(eval(input()))
pre = s1[0] == s2[0]
if s1[0] == s2[0]:
    ans = 3
    idx = 1
else:
    ans = 6
    idx = 2
while idx < N:
    if pre:
        ans *= 2
    else:
        if s1[idx] != s2[idx]:
            ans *= 3
    pre = s1[idx] == s2[idx]
    if s1[idx] == s2[idx]:
        idx += 1
    else:
        idx += 2
print((ans % MOD))

+MOD = 10**9 + 7 -S1 = eval(input()) -S2 = eval(input()) -MOD = 1000000007 -if S1[0] == S2[0]: +s1 = list(eval(input())) +s2 = list(eval(input())) +pre = s1[0] == s2[0] +if s1[0] == s2[0]: -    pre = 1 +    idx = 1 -    pre = 2 -for i in range(1, N): -    if S1[i] == S1[i - 1]: -        continue -    if S1[i] == S2[i]: -        if pre == 1: -            ans *= 2 -        pre = 1 +    idx = 2 +while idx < N: +    if pre: +        ans *= 2 -        if pre == 1: -            ans *= 2 -        else: +        if s1[idx] != s2[idx]: -        pre = 2 -    ans %= MOD -print(ans) +    pre = s1[idx] == s2[idx] +    if s1[idx] == s2[idx]: +        idx += 1 +    else: +        idx += 2 +print((ans % MOD))