MOD = 10**9+7

n = int(eval(input()))

s = eval(input())

p = eval(input())

ans = 0

f = 0

i = 0

while i < n:

    if i > n:break

    if s[i] == p[i]:

        if i == 0:

            ans = 3

        else:

            if f == 1:

                ans *= 1

            else:

                ans *= 2

        f = 0

    else:

        if i == 0:

            ans = 6

        else:

            if f == 1:

                ans *= 3

            else:

                ans *= 2

        f = 1

        i += 1

    i += 1

    ans %= MOD

print((ans%MOD))

MOD = 10**9+7

n = int(eval(input()))

s = eval(input())

p = eval(input())

ans = 0

f = 0

i = 0

two = False

while i < n:

    if i == 0:

        if s[i] == p[i]:

            ans = 3

        else:

            ans = 6

            i += 1

            two = True

        i += 1

        continue

    if i >= n:break

    if s[i] == p[i]:

        if two:

            pass

        else:

            ans *= 2

        two = False

    else:

        if two:

            ans *= 3

        else:

            ans *= 2

        two = True

        i += 1

    i += 1

    ans %= MOD

print(ans)

MOD = 10**9 + 7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
while i < n:
    if i > n:
        break
    if s[i] == p[i]:
        if i == 0:
            ans = 3
        else:
            if f == 1:
                ans *= 1
            else:
                ans *= 2
        f = 0
    else:
        if i == 0:
            ans = 6
        else:
            if f == 1:
                ans *= 3
            else:
                ans *= 2
        f = 1
        i += 1
    i += 1
    ans %= MOD
print((ans % MOD))

MOD = 10**9 + 7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
two = False
while i < n:
    if i == 0:
        if s[i] == p[i]:
            ans = 3
        else:
            ans = 6
            i += 1
            two = True
        i += 1
        continue
    if i >= n:
        break
    if s[i] == p[i]:
        if two:
            pass
        else:
            ans *= 2
        two = False
    else:
        if two:
            ans *= 3
        else:
            ans *= 2
        two = True
        i += 1
    i += 1
    ans %= MOD
print(ans)

+two = False -    if i > n: +    if i == 0: +        if s[i] == p[i]: +            ans = 3 +        else: +            ans = 6 +            i += 1 +            two = True +        i += 1 +        continue +    if i >= n: -        if i == 0: -            ans = 3 +        if two: +            pass -            if f == 1: -                ans *= 1 -            else: -                ans *= 2 -        f = 0 +            ans *= 2 +        two = False -        if i == 0: -            ans = 6 +        if two: +            ans *= 3 -            if f == 1: -                ans *= 3 -            else: -                ans *= 2 -        f = 1 +            ans *= 2 +        two = True -print((ans % MOD)) +print(ans)