import sys

input = sys.stdin.readline

from collections import *



N = int(eval(input()))

S1 = input()[:-1]

S2 = input()[:-1]

i = 0

ans = 1

MOD = 10**9+7



while i<N:

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

        if i==0:

            ans *= 3

            ans %= MOD

        else:

            if flag==0:

                ans *= 2

                ans %= MOD

        

        flag = 0

        i += 1

    else:

        if i==0:

            ans *= 6

        else:

            if flag==0:

                ans *= 2

                ans %= MOD

            else:

                ans *= 3

                ans %= MOD

        

        flag = 1

        i += 2



print(ans)
N = int(eval(input()))

S1 = eval(input())

S2 = eval(input())

ans = 1

MOD = 10**9+7

i = 0

flag = True



while i<N:

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

        if i==0:

            ans *= 3

        else:

            if flag:

                ans *= 2

        

        i += 1

        flag = True

    else:

        if i==0:

            ans *= 6

        else:

            if flag:

                ans *= 2

            else:

                ans *= 3

        

        i += 2

        flag = False

    

    ans %= MOD



print(ans)
import sys

input = sys.stdin.readline
from collections import *

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

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

-import sys - -input = sys.stdin.readline -from collections import * - -S1 = input()[:-1] -S2 = input()[:-1] -i = 0 +S1 = eval(input()) +S2 = eval(input()) +i = 0 +flag = True -            ans %= MOD -            if flag == 0: +            if flag: -                ans %= MOD -        flag = 0 +        flag = True -            if flag == 0: +            if flag: -                ans %= MOD -                ans %= MOD -        flag = 1 +        flag = False +    ans %= MOD