p = 10**9+7

N = int(eval(input()))

S1 = input().strip()

S2 = input().strip()

cnt = 1

cur = 0

if N>=2 and S1[0]==S1[1]:

    cnt = cnt*6

    cur = 2

else:

    cnt = cnt*3

    cur = 1

while cur<N:

    if cur<N-1 and S1[cur]==S1[cur+1]:

        if S1[cur-1]==S2[cur-1]:

            cnt = (cnt*2)%p

            cur += 2

        else:

            cnt = (cnt*3)%p

            cur += 2

    elif S1[cur-1]==S2[cur-1]:

        cnt = (cnt*2)%p

        cur += 1

    elif cur>=2 and S1[cur-2]==S1[cur-1]:

        cur += 1

print(cnt)    
p = 10**9+7

N = int(eval(input()))

S1 = input().strip()

S2 = input().strip()

cnt = 1

cur = 0

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

    cnt = 3

    cur += 1

else:

    cnt = 6

    cur += 2

while cur<N:

    if S1[cur]==S2[cur]:

        if S1[cur-1]==S2[cur-1]:

            cnt = (cnt*2)%p

        cur += 1

    else:

        if S1[cur-1]==S2[cur-1]:

            cnt = (cnt*2)%p

        else:

            cnt = (cnt*3)%p

        cur += 2

print(cnt)        
p = 10**9 + 7
N = int(eval(input()))
S1 = input().strip()
S2 = input().strip()
cnt = 1
cur = 0
if N >= 2 and S1[0] == S1[1]:
    cnt = cnt * 6
    cur = 2
else:
    cnt = cnt * 3
    cur = 1
while cur < N:
    if cur < N - 1 and S1[cur] == S1[cur + 1]:
        if S1[cur - 1] == S2[cur - 1]:
            cnt = (cnt * 2) % p
            cur += 2
        else:
            cnt = (cnt * 3) % p
            cur += 2
    elif S1[cur - 1] == S2[cur - 1]:
        cnt = (cnt * 2) % p
        cur += 1
    elif cur >= 2 and S1[cur - 2] == S1[cur - 1]:
        cur += 1
print(cnt)

p = 10**9 + 7
N = int(eval(input()))
S1 = input().strip()
S2 = input().strip()
cnt = 1
cur = 0
if S1[0] == S2[0]:
    cnt = 3
    cur += 1
else:
    cnt = 6
    cur += 2
while cur < N:
    if S1[cur] == S2[cur]:
        if S1[cur - 1] == S2[cur - 1]:
            cnt = (cnt * 2) % p
        cur += 1
    else:
        if S1[cur - 1] == S2[cur - 1]:
            cnt = (cnt * 2) % p
        else:
            cnt = (cnt * 3) % p
        cur += 2
print(cnt)

-if N >= 2 and S1[0] == S1[1]: -    cnt = cnt * 6 -    cur = 2 +if S1[0] == S2[0]: +    cnt = 3 +    cur += 1 -    cnt = cnt * 3 -    cur = 1 +    cnt = 6 +    cur += 2 -    if cur < N - 1 and S1[cur] == S1[cur + 1]: +    if S1[cur] == S2[cur]: -            cur += 2 +        cur += 1 +    else: +        if S1[cur - 1] == S2[cur - 1]: +            cnt = (cnt * 2) % p -            cur += 2 -    elif S1[cur - 1] == S2[cur - 1]: -        cnt = (cnt * 2) % p -        cur += 1 -    elif cur >= 2 and S1[cur - 2] == S1[cur - 1]: -        cur += 1 +        cur += 2