using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;


namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            long ans = 0;
            bool tate = false;
            
            for(var i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    if (s[i] == t[i])
                    {
                        ans = 3;
                        tate = true;
                    }
                    else
                    {
                        ans = 6;
                        tate = false;
                        i++;
                    }
                }
                else
                {
                    if (s[i] == t[i])
                    {
                        if (tate)
                        {
                            ans = (ans * 2) % mod;
                        }
                        tate = true;
                    }
                    else
                    {
                        if (tate)
                        {
                            ans = (ans * 2) % mod;
                        }
                        else
                        {
                            ans = (ans * 3) % mod;
                        }
                        tate = false;
                        i++;
                    }
                }
            }

            Console.WriteLine(ans);


            //Console.Out.Flush();
        }

        

    }
    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

   public static class Tool
        {
            static public void Initialize<T>(ref T[] array, T initialvalue)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = initialvalue;
                }
            }
            static public long ModuloP(long value, long mod)
            {
                long r = value % mod;

                if (r * mod < 0)
                {
                    r += mod;
                }
                return r;
            }

        }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 13140