using System;
using System.Collections.Generic;
using System.Linq;

namespace _Permutations
{
    class ProgramPermutations
    {
        public static int[] Digits(int num)
        {
            var d = new Stack<int>();
            if (num == 0) d.Push(0);

            while (num > 0)
            {
                d.Push(num % 10);
                num /= 10;
            }

            return d.ToArray();
        }

        public static int DigitsToNum(int[] digits)
        {
            var result = 0;
            var mult = 1;
            for (var i = digits.Length - 1; i >= 0; i--)
            {
                result += digits[i] * mult;
                mult *= 10;
            }

            return result;
        }

        static IEnumerable<int[]> GetPerms(List<int> seq)
        {
            seq.Sort();
            var len = seq.Count();
            var n = len - 1;
            var lst = new List<int[]> {seq.ToArray()};

            while (true)
            {
                var k = -1;
                for (var i = 0; i < n; i++)
                {
                    if (seq[i] < seq[i + 1]) k = i;
                }
                if (k == -1) break;
                var l = -1;
                for (var i = 0; i < len; i++)
                {
                    if (seq[k] < seq[i]) l = i;
                }
                var temp = seq[k];
                seq[k] = seq[l];
                seq[l] = temp;

                var seqNext = new int[len];
                for (var i = 0; i <= k; i++)
                {
                    seqNext[i] = seq[i];
                }
                for (var i = n; i > k; i--)
                {
                    seqNext[k + len - i] = seq[i];
                }
                lst.Add(seqNext);
                seq = new List<int>(seqNext);
                //Console.WriteLine(DigitsToNum(seqNext));
            }

            return lst;
        }

        static bool GreaterThan(IList<int> num1, IList<int> num2, int k)
        {
            for (var i = 0; i < k; i++)
            {
                if (num1[i] < num2[i]) return false;
                if (num1[i] > num2[i]) return true;
            }
            return false;
        }

        static bool LessThan(IList<int> num1, IList<int> num2, int k)
        {
            for (var i=0; i<k; i++)
            {
                if (num1[i] > num2[i]) return false;
                if (num1[i] < num2[i]) return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            if (args.Count() > 0)
            {
                var r = new Random(1021);

                Console.WriteLine("{0} {1}", args[0], args[1]);
                for (var i=0; i<int.Parse(args[0]); i++)
                {
                    for (var j=0; j<int.Parse(args[1]); j++)
                    {
                        Console.Write(r.Next(0, 10));
                    }
                    Console.WriteLine();
                }

                return;
            }

            var strParams = Console.ReadLine();
            if (string.IsNullOrEmpty(strParams)) return;
            var strnk = strParams.Split();
            var n = int.Parse(strnk[0]);
            var k = int.Parse(strnk[1]);
            var nums = new List<List<int>>();
            for (var i = 0; i < n; i++)
            {
                var strNum = Console.ReadLine();
                if (string.IsNullOrEmpty(strNum)) return;
                var num = strNum.Select(c => c - 48).ToList();
                nums.Add(num);
            }

            // Numbers from 0..k-1 in order
            var seq = new List<int>();
            for (var i=0; i<k; i++)
            {
                seq.Add(i);
            }

            // Permute them
            var permsTemplate = GetPerms(seq);

/*
            foreach (var intse in permsTemplate)
            {
                Console.WriteLine(DigitsToNum(intse));
            }
            return;
*/

            var minDifference = Int32.MaxValue;
            foreach (var perm in permsTemplate)
            {
                // Permute each input number according to the same permutation rule
                //var maxNum = Int32.MinValue;
                //var minNum = Int32.MaxValue;
                var maxNum = new List<int>();
                var minNum = new List<int>();
                for (var i = 0; i < k; i++)
                {
                    maxNum.Add(0);
                    minNum.Add(9);
                }

                foreach (var i in nums)
                {
                    var permDigits = new int[k];
                    for (var j = 0; j < k; j++)
                    {
                        permDigits[j] = i[perm[j]];
                    }
                    if (GreaterThan(permDigits, maxNum, k)) maxNum = new List<int>(permDigits);
                    if (LessThan(permDigits, minNum, k)) minNum = new List<int>(permDigits);
                    //var newNum = DigitsToNum(permDigits);
                    //if (newNum > maxNum) maxNum = newNum;
                    //if (newNum < minNum) minNum = newNum;
                }
                var diff = DigitsToNum(maxNum.ToArray()) - DigitsToNum(minNum.ToArray());
                //Console.WriteLine("{0} - {1} = {2}", DigitsToNum(maxNum.ToArray()), DigitsToNum(minNum.ToArray()), diff);
                if (diff < minDifference) minDifference = diff;
            }
            Console.WriteLine(minDifference);
        }
    }
}


// 1673 ms      !!!  long is much slower than double

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;

namespace sar_cs
{
    class Program
    {
        class Parser
        {
            const int BufSize = 25000;
            TextReader s;
            char[] buf = new char[BufSize];
            int bufPos;
            int bufDataSize;
            bool eos;   // eos read to buffer
            int lastChar = -2;
            int nextChar = -2;
            StringBuilder sb = new StringBuilder();

            void FillBuf()
            {
                if (eos) return;
                bufDataSize = s.Read(buf, 0, BufSize);
                if (bufDataSize == 0) eos = true;
                bufPos = 0;
            }

            int Read()
            {
                if (nextChar != -2)
                {
                    lastChar = nextChar;
                    nextChar = -2;
                }
                else
                {
                    if (bufPos == bufDataSize) FillBuf();
                    if (eos) lastChar = -1;
                    else lastChar = buf[bufPos++];
                }
                return lastChar;
            }

            void Back()
            {
                if (lastChar == -2) throw new Exception();  // no chars were ever read
                nextChar = lastChar;
            }

            public Parser()
            {
                s = Console.In;
            }

            public int ReadInt()
            {
                int res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = -sign;
                    c = Read();
                }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new InvalidDataException();
                Back();
                return checked(res * sign);
            }

            public long ReadLong()
            {
                long res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = -sign;
                    c = Read();
                }
                int len = 0;
                checked
                {
                    while (c >= 0 && !char.IsWhiteSpace((char)c))
                    {
                        if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                        len++;
                        res = res * 10 - c;
                        c = Read();
                    }
                    if (len == 0) throw new InvalidDataException();
                    Back();
                    return res * sign;
                }
            }

            public double ReadDouble()
            {
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));

                int sign = 1;
                if (c == '-')
                {
                    sign = -1;
                    c = Read();
                }

                sb.Length = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    sb.Append((char)c);
                    c = Read();
                }

                Back();
                double res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);
                return res * sign;
            }

            public string ReadLine()
            {
                int c = Read();
                sb.Length = 0;
                while (c != -1 && c != 13 && c != 10)
                {
                    sb.Append((char)c);
                    c = Read();
                }
                if (c == 13)
                {
                    c = Read();
                    if (c != 10) Back();
                }
                return sb.ToString();
            }

            public bool EOF
            {
                get
                {
                    if (Read() == -1) return true;
                    Back();
                    return false;
                }
            }

            public bool SeekEOF
            {
                get
                {
                L0:
                    int c = Read();
                    if (c == -1) return true;
                    if (char.IsWhiteSpace((char)c)) goto L0;
                    Back();
                    return false;
                }
            }
        }

        static void pe()
        {
            Console.WriteLine("???");
            Environment.Exit(0);
        }

        static void re()
        {
            Environment.Exit(55);
        }

        static int nosol()
        {
            Console.WriteLine("ERROR");
            return 0;
        }

        static Stopwatch sw = Stopwatch.StartNew();

        static void Test()
        {
            Random rand = new Random(52345235);
            for (int i = 0; i < 2e6; i++)
            {
            }
        }

        struct Pos
        {
            public int X, Y;

            public Pos(int x, int y)
            {
                X = x; Y = y;
            }

            public Pos(string s)
            {
                X = (int)(s[0] - 'a');
                Y = (int)(s[1] - '0' - 1);
            }

            public bool Neighbor(Pos o)
            {
                return (X != o.X || Y != o.Y) && Math.Abs(X - o.X) <= 1 && Math.Abs(Y - o.Y) <= 1;
            }

        }

        static void LadyaFill(int[,] field, Pos l)
        {
            for (int x = l.X + 1; x < 8; x++)
            {
                int t = field[l.Y, x];
                field[l.Y, x] |= 2;
                if ((t & 1) == 1) break;
            }
            for (int x = l.X - 1; x >= 0; x--)
            {
                int t = field[l.Y, x];
                field[l.Y, x] |= 2;
                if ((t & 1) == 1) break;
            }

            for (int y = l.Y + 1; y < 8; y++)
            {
                int t = field[y, l.X];
                field[y, l.X] |= 2;
                if ((t & 1) == 1) break;
            }

            for (int y = l.Y - 1; y >= 0; y--)
            {
                int t = field[y, l.X];
                field[y, l.X] |= 2;
                if ((t & 1) == 1) break;
            }
        }

        static int Main(string[] args)
        {
            //Test(); return 0;
            //Console.SetIn(File.OpenText("_input"));
            //Console.SetOut(File.CreateText("_out"));
            Parser parser = new Parser();

            while (!parser.SeekEOF)
            {
                string line = parser.ReadLine();
                string[] ll = line.Split(' ');
                if (ll.Length != 4) pe();

                Pos wl1 = new Pos(ll[0]);
                Pos wl2 = new Pos(ll[1]);
                Pos wk = new Pos(ll[2]);
                Pos bk = new Pos(ll[3]);

                int[,] field = new int[8, 8];
                field[wl1.Y, wl1.X] = 1;
                field[wl2.Y, wl2.X] = 1;
                field[wk.Y, wk.X] = 1;
                //field[bk.Y,bk.X]='b';

                LadyaFill(field, wl1);
                LadyaFill(field, wl2);

                for (int y = 0; y < 8; y++)
                    for (int x = 0; x < 8; x++)
                        if (wk.Neighbor(new Pos(x, y))) field[y, x] |= 2;

                bool underAttack = (field[bk.Y, bk.X] & 2) != 0;

                bool canMove = false;
                for (int y = 0; y < 8; y++)
                    for (int x = 0; x < 8; x++)
                        if (bk.Neighbor(new Pos(x, y)))
                            canMove |= (field[y, x] & 2) == 0;

                string res = underAttack && !canMove ? "CHECKMATE" : "OTHER";
                Console.WriteLine(res);

            }
            sw.Stop();
            return 0;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace APlayingwithPaper
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split();

            long a = long.Parse(ab[0]);
            long b = long.Parse(ab[1]);

            long temp = 0;
            long count = 0;

            while (b!=0)
            {
                if (a<b)
                {
                    temp = a;
                    a = b;
                    b = temp;
                }

                count += a / b;
                temp = b;
                b = a % b;
                a = temp;

                if (b==1)
                {
                    count += a;
                    break;
                }

            }

            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int s1 = int.Parse(str[0]);
            int s2 = int.Parse(str[1]);
            int s3 = int.Parse(str[2]);

            int a;
            int b;
            int c;

            c = (int)Math.Sqrt(s2*s3/s1);
            b = s3 / c;
            a = s1 / b;

            //Console.WriteLine(a+" "+b+" "+c);

            int res = (a + b + c) * 4;
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            return (T)Convert.ChangeType(NextString(), typeof(T));
        }

        public IEnumerable<T> NextSeq<T>(int n)
        {
            for (int i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "YES" : "NO");
        }

        public void PrintLine(bool o)
        {
            PrintLine(o ? "YES" : "NO");
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static T CycleGet<T>(this IList<T> self, int index)
        {
            return self[index % self.Count];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            for (int i = 0; i < self.Count; i++)
            {
                self[i] = val;
            }

            return self;
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Key.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion
        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {
            var a = io.NextInt();
            var b = io.NextInt();

            var sa = io.NextSeq<int>(a).Select(x => x - 1).ToArray();
            var isb = new int[1000000];

            isb.Fill(-1);

            for (int i = 0; i < b; i++)
                isb[io.NextInt() - 1] = i;

            var res = 0;

            long[] q = new long[2 * a];

            for (int i = 0, j = 0; j < 2 * a; ++j)
            {
                q[j] = isb[sa.CycleGet(j)];

                if (q[j] == -1)
                {
                    i = j + 1;
                    continue;
                }

                if (j > 0 && q[j] < q[j - 1])
                {
                    long cycles = (q[j - 1] - q[j] + b - 1) / b;
                    q[j] += cycles * b;
                }

                while (i <= j && q[j] - q[i] >= b || j - i + 1 > a)
                {
                    i++;
                }
                res = Math.Max(res, j - i + 1);
            }

            io.PrintLine(res);
        }
    }

}


using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Fox_Dividing_Cheese
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int a = Next();
            int b = Next();

            var divs = new[] {2, 3, 5};
            var na = new int[divs.Length];
            var nb = new int[divs.Length];
            for (int i = 0; i < divs.Length; i++)
            {
                while (a%divs[i] == 0)
                {
                    a /= divs[i];
                    na[i]++;
                }
                while (b%divs[i] == 0)
                {
                    b /= divs[i];
                    nb[i]++;
                }
            }
            if (a == b)
            {
                writer.WriteLine(na.Select((t, i) => Math.Abs(t - nb[i])).Sum());
            }
            else
            {
                writer.WriteLine("-1");
            }

            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class CasketOfStar
{

    public static void ans(int m, int n)
    {
        long k = 1;
        for (int i = 0; i < n; i++) {
            k *= m ;
            k %= 1000000007;
        }
        Console.WriteLine(k);
    }

public static void Main(string[] args)
    {
        int [] arr = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
        if(arr[2] == 1 || arr[2] > arr[0])
        {
            //m^n
            ans(arr[1], arr[0]);
        }
        else if(arr[2] == arr[0])
        {
            //m^(n+1)/2
            ans(arr[1], (arr[0]+1)/2);
        }
        else if(arr[2] % 2 ==0)
        {

            ans(arr[1], 1);
        }
        else
        {
            ans(arr[1], 2);

        }

    }

}


using System;
using System.Linq;

namespace CSharp
{
    public class _723B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] tokens = Console.ReadLine().Split('(', ')').ToArray();

            int longest = Enumerable.Range(0, tokens.Length).Where(i => i % 2 == 0).SelectMany(i => tokens[i].Split('_')).Max(word => word.Length);
            int count = Enumerable.Range(0, tokens.Length).Where(i => i % 2 == 1).SelectMany(i => tokens[i].Split('_')).Count(word => word.Length > 0);

            Console.WriteLine($"{longest} {count}");
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Olymp
{
  public class ProblemSolver
  {
    private readonly Tokenizer input;

    public void Solve()
    {
      var q1x = new int[4];
      var q1y = new int[4];
      var q2x = new int[4];
      var q2y = new int[4];
      for (var i = 0; i < 4; i++)
      {
        q1x[i] = input.ReadInt();
        q1y[i] = input.ReadInt();
      }
      for (var i = 0; i < 4; i++)
      {
        q2x[i] = input.ReadInt();
        q2y[i] = input.ReadInt();
      }
      var x1min = q1x.Min();
      var y1min = q1y.Min();
      var x1max = q1x.Max();
      var y1max = q1y.Max();
      var x2min = q2x.Min();
      var y2min = q2y.Min();
      var x2max = q2x.Max();
      var y2max = q2y.Max();
      var d = (x2max - x2min) / 2;
      for (var x = Max(x1min, x2min); x <= Min(x1max, x2max); x++)
      {
        for (var y = Max(y1min, y2min); y <= Min(y1max, y2max); y++)
        {
          if (x >= x1min && x <= x1max &&
              y >= y1min && y <= y1max &&
              x >= x2min && x <= x2max &&
              y >= y2min && y <= y2max)
          {
            var x0 = x - x2min - d;
            var y0 = y - y2min - d;
            if (x0 + y0 <= d &&
                x0 + y0 >= -d &&
                y0 - x0 <= d &&
                y0 - x0 >= -d)
            {
              Write("YES");
              return;
            }
          }
        }
      }
      Write("NO");
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private readonly TextReader reader;

    public string ReadToEnd()
    {
      return reader.ReadToEnd();
    }

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      var isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = reader.Read();
        if (c == -1)
          throw new EndOfStreamException("Digit expected, but end of stream occurs");
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");
      var result = (char)c - '0';
      c = reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException($"Digit expected, but was: '{(char)c}'");
        result = result * 10 + (char)c - '0';
        c = reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      var a = new int[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public (int, int) Read2Int() =>
      (ReadInt(), ReadInt());

    public (int, int, int) Read3Int() =>
      (ReadInt(), ReadInt(), ReadInt());

    public (int, int, int, int) Read4Int() =>
      (ReadInt(), ReadInt(), ReadInt(), ReadInt());

    public long[] ReadLongArray(int n)
    {
      var a = new long[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      var a = new double[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      var c = reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  internal class Program
  {
    public static void Main()
    {
      var solver = new ProblemSolver(In);
      solver.Solve();
    }
  }

  #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace Codeforces305_C
{

	class Program
	{
		static void Main(string[] args)
		{
			using (var io = new ContestIO())
			{
				var Console = 1;

				var m = io.ReadL();
				var a = io.ReadListL(2);
				var axy = io.ReadListL(2);
				var b = io.ReadListL(2);
				var bxy = io.ReadListL(2);

				long a1 = -1, a2 = -1, b1 = -1, b2 = -1;

				for (var i = 1; i <= 2 * m + 1; i++)
				{
					a[0] = Next(a, axy, m);
					b[0] = Next(b, bxy, m);
					if (a[0] == a[1])
					{
						if (a1 == -1)
						{
							a1 = i;
						}
						else if (a2 == -1)
						{
							a2 = i;
						}
						if (i == b1 || i == b2)
						{
							io.Write(i);
							return;
						}
					}
					if (b[0] == b[1])
					{
						if (b1 == -1)
						{
							b1 = i;
						}
						else if (b2 == -1)
						{
							b2 = i;
						}
						if (i == a1 || i == a2)
						{
							io.Write(i);
							return;
						}
					}
					if (a1 != -1 && a2 != -1 && b1 != -1 && b2 != -1)
						break;
				}

				if (a1 == -1 || a2 == -1 || b1 == -1 || b2 == -1)
				{
					io.Write(-1);
					return;
				}

				var da = a2 - a1;
				var db = b2 - b1;
				for (var i = 0; i <= m; i++)
				{
					long x = a1 + da * i;
					long k = x - b1;
					if (k < 0)
						continue;
					if (k % db == 0)
					{
						io.Write(x);
						return;
					}
				}

				io.Write(-1);
			}
		}

		static long Next(long[] v, long[] xy, long m)
		{
			return (xy[0] * v[0] + xy[1]) % m;
		}
	}

	class ContestIO : IDisposable
	{
		const int BufferSize = 1024 * 8;

		static StreamReader reader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
		static StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(BufferSize), Encoding.ASCII, BufferSize);

		static bool IsDigit(int c)
		{
			return c >= '0' && c <= '9';
		}
		static int Next()
		{
			return reader.Read();
		}

		public int Read()
		{
			int c = Next();
			while (!IsDigit(c))
			{
				c = Next();
			}
			int r = 0;
			while (IsDigit(c))
			{
				r = r * 10 + (c - '0');
				c = Next();
			}
			return r;
		}
		public long ReadL()
		{
			return (long)Read();
		}
		public int[] ReadList(int size)
		{
			var r = new int[size];
			for (var i = 0; i < size; i++)
				r[i] = Read();
			return r;
		}
		public long[] ReadListL(int size)
		{
			var r = new long[size];
			for (var i = 0; i < size; i++)
				r[i] = ReadL();
			return r;
		}

		public void Write(int v)
		{
			writer.Write(v);
			writer.WriteLine();
		}
		public void Write(long v)
		{
			writer.Write(v);
			writer.WriteLine();
		}
		public void Write(IEnumerable<int> arr)
		{
			foreach (var v in arr)
			{
				writer.Write(v);
				writer.Write(' ');
			}
			writer.WriteLine();
		}

		public void Dispose()
		{
			writer.Flush();
		}
	}

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CP_CS
{

    class Task
    {

        static void Solve()
        {
            int n = ReadInt();
            for (int i = (int)Math.Ceiling(Math.Sqrt(n)); i >= 1; i--)
            {
                if (n % i == 0)
                {
                    if (i > n/i)
                    {
                        continue;
                    }
                    Write($"{i} {n/i}");
                    return;
                }
            }
        }

        static string[] Split(string str, int chunkSize)
        {
            return Enumerable.Range(0, str.Length / chunkSize)
                .Select(i => str.Substring(i * chunkSize, chunkSize)).ToArray();
        }

        #region -- Main --

        private static TextReader reader;
        private static TextWriter writer;

        static void Main()
        {
#if DEBUG
            //reader = new StreamReader("..\\..\\input.txt");
            reader = new StreamReader(Console.OpenStandardInput());
            writer = Console.Out;
            //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("pluses.in");
        //writer = new StreamWriter("pluses.out");
#endif
            try
            {
                //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
                //thread.Start();
                //thread.Join();
                Solve();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
            }
            reader.Close();
            writer.Close();
        }

        #endregion
        #region -- Read / Write --

        private static Queue<string> currentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadAndSplitLine(char divisor)
        {
            return reader.ReadLine().Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine());
            return currentLineTokens.Dequeue();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        //public static BigInteger ReadBigInteger()
        //{
        //    return BigInteger.Parse(ReadToken());
        //}

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static bool[] ReadBoolArray()
        {
            return ReadAndSplitLine().ToString().ToCharArray().Select(chr => chr == '1').ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray();
            return matrix;
        }

        public static bool[][] ReadBoolMatrix(int numberOfRows)
        {
            bool[][] matrix = new bool[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadBoolArray();
            return matrix;
        }

        public static bool[][] TransposeBoolMatrix(bool[][] array, int numberOfRows)
        {
            bool[][] matrix = array;
            bool[][] ret = new bool[matrix[0].Length][];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = new bool[numberOfRows];
                for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i];
            }
            return ret;
        }

        public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
        {
            int[][] matrix = ReadIntMatrix(numberOfRows);
            int[][] ret = new int[matrix[0].Length][];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = new int[numberOfRows];
                for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i];
            }
            return ret;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            writer.WriteLine(string.Join(" ", array));
        }

        public static void Write(params object[] array)
        {
            WriteArray(array);
        }
        public static void WriteLines<T>(IEnumerable<T> array)
        {
            foreach (var a in array) writer.WriteLine(a);
        }
        private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
        {
            public new TValue this[TKey key]
            {
                get { return ContainsKey(key) ? base[key] : default(TValue); }
                set { base[key] = value; }
            }
        }
        private static T[] Init<T>(int size) where T : new()
        {
            var ret = new T[size];
            for (int i = 0; i < size; i++) ret[i] = new T();
            return ret;
        }
        #endregion
    }
}


/* Date: 11.01.2019 * Time: 21:45 */
// *

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\000\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\000\\A.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
		string s;

# if ( ONLINE_JUDGE )
		s = Console.ReadLine ();
# else
		s = sr.ReadLine ();
# endif

		string [] ss = s.Split (' ');

		int n = int.Parse (ss [0]);
		int	k = int.Parse (ss [1]);

		int m = k / n + ( k % n > 0 ? 1 : 0 );

# if ( ONLINE_JUDGE )
		Console.WriteLine (m);
# else
		sw.WriteLine (m);
		sw.Close ();
# endif
	}
}


using System;
using System.IO;
using System.Linq;

namespace Codeforces.R276D
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            var lr = tr.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var l = lr[0];
            var r = lr[1];

            tw.WriteLine(Calc(l, r));
        }

        private static long Calc(long l, long r)
        {
            var x = 1L;
            while (x <= (l ^ r))
                x <<= 1;

            return x - 1;
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var t = new BigInteger(cin.NextLong());
			var w = new BigInteger(cin.NextLong());
			var b = new BigInteger(cin.NextLong());
			var tie = Lcm(w, b);
			var extra = BigInteger.Min(w, b) - 1;
			var result = t/tie*(extra + 1);
			var left = t%tie;
			result += BigInteger.Min(left, extra);

			var gcd = Gcd(t, result);

			Console.WriteLine(result / gcd + "/" + t / gcd);
		}

		static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			return b == 0 ? a : Gcd(b, a % b);
		}

		static BigInteger Lcm(BigInteger num1, BigInteger num2)
		{
			return (num1 * num2) / Gcd(num1, num2);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			Console.SetIn(new StreamReader(@"..\..\input.txt"));
#endif
			new Template().Solve();
			Console.ReadLine();
#if DEBUG
			Console.ReadKey();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] toks = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = toks[0];
            int x = toks[1];
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Array.Sort(arr);
            int count = 0;
            for(int i = 0; i <= x; i++)
            {
                if (!arr.Contains(i) && i != x)
                {
                    count++;
                }

                if (i == x && arr.Contains(x))
                    count++;
            }
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Collections;

namespace Task
{
    class Subj
    {
        public long a, b;
        public int c;
    }

    class Program
    {
        Subj[] subjects;

        bool[, ,] done;
        long[, ,] memo;

        int[, ,] nextSubjId;
        int[, ,] nextComplexityShift;

        int n;
        int k;

        long getMax(int day, int lastSubjId, int complexityShift)
        {
            if (day == n)
                return 0;

            if (!done[day, lastSubjId, complexityShift])
            {
                long ans = -1;
                int bestNextSubjId = -1;
                int bestComplexityShift = -1;

                for (int nextSubjId = 0; nextSubjId < subjects.Length; nextSubjId++)
                {
                    Subj nextSubj = subjects[nextSubjId];
                    if (day != 0 && subjects[lastSubjId].c >= nextSubj.c)
                        continue;

                    if (day == 0)
                    {
                        for (long complexity = nextSubj.a; complexity <= nextSubj.b; complexity++)
                        {
                            int nextShift = (int)(complexity - nextSubj.a);
                            long temp = getMax(day + 1, nextSubjId, nextShift);
                            if (temp == -1)
                                continue;

                            temp += complexity;
                            if (temp > ans)
                            {
                                ans = temp;
                                bestNextSubjId = nextSubjId;
                                bestComplexityShift = nextShift;
                            }
                        }
                    }
                    else
                    {
                        Subj lastSubj = subjects[lastSubjId];
                        for (int mode = 0; mode < 2; mode++)
                        {
                            long nextComplexity = mode == 0 ? (lastSubj.a + complexityShift) * k : ((lastSubj.a + complexityShift) + k);
                            if (nextComplexity < nextSubj.a || nextComplexity > nextSubj.b)
                                continue;

                            int nextShift = (int)(nextComplexity - nextSubj.a);
                            long temp = getMax(day + 1, nextSubjId, nextShift);
                            if (temp == -1)
                                continue;

                            temp += nextComplexity;
                            if (temp > ans)
                            {
                                ans = temp;
                                bestNextSubjId = nextSubjId;
                                bestComplexityShift = nextShift;
                            }
                        }
                    }
                }

                memo[day, lastSubjId, complexityShift] = ans;

                if (ans >= 0)
                {
                    nextSubjId[day, lastSubjId, complexityShift] = bestNextSubjId;
                    nextComplexityShift[day, lastSubjId, complexityShift] = bestComplexityShift;
                }

                done[day, lastSubjId, complexityShift] = true;

            }

            return memo[day, lastSubjId, complexityShift];

        }

        void Solve()
        {
            // Place your code here
            n = io.NextInt();
            int m = io.NextInt();
            k = io.NextInt();

            subjects = new Subj[m];

            for (int i = 0; i < m; i++)
            {
                Subj s = new Subj();
                s.a = io.NextLong();
                s.b = io.NextLong();
                s.c = io.NextInt();
                subjects[i] = s;
            }

            done = new bool[n, m, 101];
            memo = new long[n, m, 101];
            nextSubjId = new int[n, m, 101];
            nextComplexityShift = new int[n, m, 101];

            long ans = getMax(0, 0, 0);

            if (ans == -1)
            {
                io.Print("NO");
                return;
            }

            io.Print("YES");
            int curSubj = 0;
            int curShift = 0;
            for (int day = 0; day < n; day++)
            {
                int nextSubj = nextSubjId[day, curSubj, curShift];
                int nextShift = nextComplexityShift[day, curSubj, curShift];

                io.PrintLine("");
                io.Print("{0} {1}", nextSubj + 1, nextShift + subjects[nextSubj].a);

                curSubj = nextSubj;
                curShift = nextShift;
            }

        }

        MyIo io = new MyIo();

        static void Main(string[] args)
        {
            var p = new Program();

            p.Solve();
            p.io.Close();
        }
    }

    class MyIo
    {
        char[] separators = new char[] { ' ', '\t' };

#if TEST
        TextReader inputStream = new StreamReader("..\\..\\input.txt");
#else
        TextReader inputStream = System.Console.In;
#endif
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_Mahmud_and_triangle
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] inp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            List<int> ribs = inp.ToList();
            ribs.Sort();

            for (int i = 0; i < inp.Length - 2; i++)
                if (ribs[i] + ribs[i + 1] > ribs[i + 2]) { Console.WriteLine("YES"); return; }
            Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Mancala
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long[] Holes = new long[14];
            for (int i = 0; i < 14; i++)
            {
                Holes[i] = int.Parse(input[i]);
            }

            long score = 0;
            for (int i = 0; i < 14; i++)
            {
                if (Holes[i] == 0)
                {
                    continue;
                }
                long[] temp = (long[])Holes.Clone();
                long num = Holes[i];
                temp[i] = 0;
                long add = num / 14;
                long bonus = num % 14;
                for (int y = i+1; y <= i+14; y++)
                {
                    temp[y % 14] += add;
                    if (bonus > 0)
                    {
                        temp[y % 14]++;
                        bonus--;
                    }
                }
                long tempScore = SumAll(temp);
                if (tempScore > score)
                {
                    score = tempScore;
                }
            }
            Console.WriteLine(score);
            //Console.ReadKey();
        }

        static long SumAll(long[] Holes)
        {
            long sum = 0;
            for (int i = 0; i < 14; i++)
            {
                if (Holes[i] % 2 == 0)
                    sum += Holes[i];
            }

            return sum;
        }
    }

}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        public static string Check(string s)
        {
            string letters = "aeiouy";

            while (true)
            {
                bool used = false;

                for (int i = 0; i < s.Length - 1; i++)
                {
                    if (letters.Contains(s[i].ToString()) && letters.Contains(s[i + 1].ToString()))
                    {
                        s = s.Remove(i + 1, 1);

                        used = true;
                    }
                }

                if (!used)
                {
                    return s;
                }
            }
        }

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif
            int n = int.Parse(Console.ReadLine());

            string a = Console.ReadLine();

            string a1 = string.Empty;
            string a2 = string.Empty;

            int count = a.Length;

            if (n % 2 != 0)
            {
                for (int i = (n - 1) / 2; i >= 0; i--)
                {
                    a1 = a.Substring(0, i);

                    a2 = a.Substring(i, i);

                    if (a1 == a2 && i > 0)
                    {
                        count = count - a1.Length + 1;
                        break;
                    }
                }
            }
            else
            {
                for (int i = n / 2; i >= 0; i--)
                {
                    a1 = a.Substring(0, i);

                    a2 = a.Substring(i, i);
                    if (a1 == a2 && i > 0)
                    {
                        count = count - a1.Length + 1;
                        break;
                    }
                }

            }

            Console.WriteLine(count);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c < '0' || c > '9');
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res;
            res *= 10;
            res += c - '0';
        }
    }
    private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
    private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

    static void Main(String[] args)
    {
        var data = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        //var n = int.Parse(Console.ReadLine());
        var a = data[0];
        var b = data[1];
        var h = data[2];
        var w = data[3];
        var n = data[4];

        data = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        data.Sort();
        data.Reverse();
        var all = new Dictionary<int, List<Tuple<long, long>>>();
        all[0] = new List<Tuple<long, long>>();
        all[0].Add(new Tuple<long, long>(h, w));
        for(var i = 0; i < Math.Min(60, n); i++)
        {
            var cur = data[i];
            all[i + 1] = new List<Tuple<long, long>>();
            var used = new Dictionary<string, bool>();
            foreach (var prev in all[i])
            {
                if ((prev.Item1 >= a && prev.Item2 >= b) || (prev.Item2 >= a && prev.Item1 >= b))
                {
                    Console.WriteLine(i);
                    return;
                }
                if(prev.Item1 * cur < 0|| prev.Item2 * cur < 0)
                {
                    Console.WriteLine(-1);
                    return;
                }
                var new1 = new Tuple<long, long>(prev.Item1 * cur, prev.Item2);
                var new2 = new Tuple<long, long>(prev.Item1, prev.Item2 * cur);
                //if (prev.Item1 < a && prev.Item2 < b)
                //{
                    if (!used.ContainsKey(new1.Item1 + "#" + new1.Item2))
                    {
                        all[i + 1].Add(new1);
                        used[new1.Item1 + "#" + new1.Item2] = true;
                    }
                    if (!used.ContainsKey(new2.Item1 + "#" + new2.Item2))
                    {
                        all[i + 1].Add(new2);
                        used[new2.Item1 + "#" + new2.Item2] = true;
                    }

            }
        }

        foreach (var prev in all[(int)Math.Min(60, n)])
        {
            if (prev.Item1 >= a && prev.Item2 >= b)
            {
                Console.WriteLine((int)Math.Min(60, n));
                return;
            }
        }

        Console.WriteLine(-1);
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] str = Console.ReadLine().Split(new char[] { ' ' });

			long x = Convert.ToInt64(str[0]);
			long n = Convert.ToInt64(str[1]);

			List<long> primes = new List<long>();

			for (long i = 2; i * i <= x; ++i)
			{
				if (x % i == 0 && isPrime(i))
					primes.Add(i);

				if (x % i == 0 && isPrime(x / i) && !primes.Contains(x / i))
					primes.Add(x / i);
			}

			if (isPrime(x))
				primes.Add(x);

			long mod = 1000000007;
			long res = 1;

			List<long> powers = new List<long>();

			for (int i = 0; i < primes.Count(); ++i)
			{
				powers.Add(powerInFact(n, primes[i]));
			}

			for (int i = 0; i < primes.Count(); ++i)
			{
				if (powers[i] != 0)
				{
					res = (res * (binpow(primes[i], powers[i], mod) % mod)) % mod;
				}
			}

			Console.WriteLine(res);
			Console.ReadLine();
		}

		public static bool isPrime(long n)
		{
			for (long i = 2; i * i <= n; ++i)
			{
				if (n % i == 0)
					return false;
			}

			return true;
		}

		public static long powerInFact(long n, long k)
		{
			long res = 0;
			while (n > 0)
			{
				n /= k;
				res += n;
			}
			return res;
		}

		public static long binpow(long a, long n, long mod)
		{
			if (n == 0)
				return 1;
			if (n % 2 == 1)
				return ((binpow(a, n - 1, mod) % mod) * a) % mod;
			else
			{
				long b = binpow(a, n / 2, mod) % mod;
				return (b * b) % mod;
			}
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B_Sum
{
    public class Sum
    {
        static int GetNotation(string input)
        {
            int max = 0;
            foreach (char c in input)
                max = Math.Max(max, (int)c);
            return max - 47;
        }

        static int Calculate(int notation, int result_10)
        {
            int output = 0;
            int temp = result_10;

            do
            {
                output++;
                temp = temp / notation;
            } while (temp >= notation);
            output++;
            return output;

        }

        static int Convert_10(int notation, string x)
        {

            int count = 0;
            int output = 0;
            for (int i = x.Length - 1; i >= 0; i--)
            {
                int temp = ((int)x[i] - 48) * Pow(notation, count);
                count++;
                output += temp;
            }
            return output;
        }

        static int Pow(int x, int g)
        {
            if (g == 0) return 1;
            else return x * Pow(x, g - 1);
        }

        static public int MaxLength(string input)
        {
            int notation = GetNotation(input);
            string[] s = input.Split(' ');
            int x = Convert_10(notation, s[0]);
            int y = Convert_10(notation, s[1]);
            return Calculate(notation, x + y);
        }
    }
    class Program
    {

        static void Main(string[] args)
        {
            Sum X = new Sum();
            Console.WriteLine(Sum.MaxLength(Console.ReadLine()));
            //Console.WriteLine(Convert_10(9, "78"));
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Primes_or_Palindromes
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var pals = new List<int>();

            for (int j = 1; j < 10; j++)
            {
                pals.Add(j);
            }
            for (int i = 1; i < 1000; i++)
            {
                string s = i.ToString();
                char[] cc = s.ToCharArray();
                Array.Reverse(cc);
                var sr = new string(cc);

                pals.Add(int.Parse(s + sr));
                for (int j = 0; j < 10; j++)
                {
                    pals.Add(int.Parse(s + j + sr));
                }
            }

            pals.Sort();

            var primes = new List<int> {2, 3, 5, 7};
            for (int i = 11; i < 2000000; i += 2)
            {
                bool f = false;
                for (int j = 0; primes[j]*primes[j] <= i; j++)
                {
                    if (i%primes[j] == 0)
                    {
                        f = true;
                        break;
                    }
                }
                if (!f)
                    primes.Add(i);
            }

            long p = Next();
            long q = Next();

            int l = 1;
            for (int i = 1; i < 2000000; i++)
            {
                int index1 = primes.BinarySearch(i);
                if (index1 < 0)
                    index1 = ~index1;
                else
                {
                    index1++;
                }
                int index2 = pals.BinarySearch(i);
                if (index2 < 0)
                    index2 = ~index2;
                else
                {
                    index2++;
                }

                if (q*index1 <= p*index2)
                {
                    l = i;
                }
            }

            writer.WriteLine(l);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


/*
csc -debug C.cs && mono --debug C.exe <<< "3 3 0"
*/

using System;
using System.Collections.Generic;
using System.Linq;

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    public static void SolveCodeForces() {
        var sc = new Scanner();
        var n = sc.NextInt();
        var m = sc.NextUlong();
        var k = sc.NextInt();

        const ulong MOD = 998244353ul;

        var S = new ulong[n, k+1];
        S[0, 0] = m;

        for (var i = 1; i < n; i++) {

            S[i, 0] = m;

            for (var j = 1; j <= k; j++) {
                S[i, j] = (  S[i-1, j-1] * (m-1) + S[i-1, j]  ) % MOD;
            }

        }

        System.Console.WriteLine(S[n-1, k]);
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static T ElementWithMax<T>(this IEnumerable<T> seq, Func<T, long> func) {
        var bi = default(T);
        var bv = long.MinValue;
        foreach (var item in seq) {
            var v = func(item);
            if (v > bv) {
                bi = item;
                bv = v;
            }
        }
        return bi;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray() {
        var array = Array();
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Linq;

namespace Codeforces.R316D1
{
    public struct ModInteger : IEquatable<ModInteger>
    {
        readonly int mod;
        readonly long value;
        public ModInteger(int mod, long value = 0L)
        {
            this.mod = mod;
            this.value = value % mod;
            if (value < 0)
            {
                this.value = value + mod;
            }
        }

        public bool Equals(ModInteger other)
        {
            return mod == other.mod && value == other.value;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is ModInteger))
            {
                return false;
            }
            var other = (ModInteger)obj;
            return Equals(other);
        }

        public override int GetHashCode()
        {
            return (int)value;
        }

        public static bool operator ==(ModInteger left, ModInteger right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(ModInteger left, ModInteger right)
        {
            return !(left == right);
        }

        public static ModInteger LeftShift(ModInteger left, int right)
        {
            return left << right;
        }

        public static ModInteger operator <<(ModInteger left, int right)
        {
            if (right > 32)
            {
                return left << 32 << (right - 32);
            }
            return new ModInteger(left.mod, left.value << right);
        }

        public static ModInteger Add(ModInteger left, int right)
        {
            return left + right;
        }

        public static ModInteger operator +(ModInteger left, int right)
        {
            return new ModInteger(left.mod, left.value + right);
        }

        public static ModInteger operator ++(ModInteger m)
        {
            return m + 1;
        }

        public static ModInteger Multiply(ModInteger left, int right)
        {
            return new ModInteger(left.mod, left.value * right);
        }

        public static ModInteger operator *(ModInteger left, int right)
        {
            return Multiply(left, right);
        }

        public static ModInteger Div(int left, int right, int mod)
        {
            return Pow(right, mod - 2, mod) * left;
        }

        public static ModInteger Pow(long x, int n, int mod)
        {
            var res = 1L;
            for (; n > 0; n >>= 1)
            {
                if ((n & 1) == 1)
                {
                    res = res * x % mod;
                }
                x = x * x % mod;
            }
            return new ModInteger(mod, res);
        }

        public static ModInteger ToModInteger(int value)
        {
            return new ModInteger(0, value);
        }

        public static implicit operator int(ModInteger value)
        {
            return (int)value.value;
        }

        public static int ToInt32(ModInteger value)
        {
            return value;
        }

        public static ModInteger Increment(ModInteger item)
        {
            return ++item;
        }
    }
    public static class Solver
    {
        const int mod = 1000000007;
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            Contract.Requires(tr != null);
            Contract.Requires(tw != null);

            tw.WriteLine(Parse(tr));
        }

        private static int Parse(TextReader tr)
        {
            var info = CultureInfo.InvariantCulture;
            tr.ReadLine();
            var a = tr.ReadLine().Split().Select(x => int.Parse(x, info)).ToArray();

            return Calc(a);
        }

        private static ModInteger Calc(int[] a)
        {
            int num1 = a.Count(x => x == 1);
            int num2 = a.Length - num1;

            return F(num1, num2);
        }

        private static ModInteger F(int a, int b)
        {
            var res = new ModInteger(mod, 1);

            for (int i = 0; i < b; ++i)
            {
                res *= a + 1 + i;
            }

            if (a == 0)
            {
                return res;
            }

            var I = new ModInteger[a + 1];
            I[0] = new ModInteger(mod, 1);
            I[1] = new ModInteger(mod, 1);
            for (int i = 2; i <= a; ++i)
            {
                I[i] = I[i - 1] + (i - 1) * I[i - 2];
            }
            return res * I[a];
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string getString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> getLongList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long getLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Edge
		{
			public int v;

			public int w;
		}

		public class Vertex
		{
			public List<Edge> edges;

			public int ct;

			public bool was;
		}

		public static bool canAuto(string s, string s1)
		{
			var l = 0;
			for (var i = 0; i < s1.Length; ++i)
			{
				while (l < s.Length && s[l] != s1[i])
					l++;
				if (l == s.Length)
					return false;
				l++;
			}
			return true;
		}

		public static bool canArray(string s, string s1)
		{
			var l = s.ToCharArray().ToList();
			var l1 = s1.ToCharArray().ToList();
			l.Sort();
			l1.Sort();
			if (l.Count != l1.Count)
				return false;

			for (var i = 0; i < l.Count; ++i)
				if (l[i] != l1[i])
					return false;

			return true;
		}

		public static bool canBoth(string s, string s1)
		{
			var l = s.ToCharArray().ToList();
			var l1 = s1.ToCharArray().ToList();
			l.Sort();
			l1.Sort();
			var ll = 0;
			for (var i = 0; i < l1.Count; ++i)
			{
				while (ll < l.Count && l[ll] != l1[i])
					ll++;
				if (ll == l.Count)
					return false;
				ll++;
			}

			return true;
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var pos = new List<List<int>>();
			var ar = new List<List<int>>();
			for (var i = 0; i < 5; ++i)
			{
				pos.Add(new List<int>());
				for (var j = 0; j < 5; ++j)
					pos[i].Add(1);
			}
			ar.Add(getList());
			ar.Add(getList());
			ar.Add(getList());
			for (var i = 0; i < 3; ++i)
				for (var j = 0; j < 3; ++j)
				{
					if (ar[i][j] % 2 == 1)
					{
						var x = i + 1;
						var y = j + 1;
						pos[x - 1][y] = 1 - pos[x - 1][y];
						pos[x][y - 1] = 1 - pos[x][y - 1];
						pos[x][y] = 1 - pos[x][y];
						pos[x][y + 1] = 1 - pos[x][y + 1];
						pos[x + 1][y] = 1 - pos[x + 1][y];
					}
				}
			for (var i = 1; i <= 3; ++i)
			{
				for (var j = 1; j <= 3; ++j)
					Console.Write(pos[i][j]);
				Console.WriteLine();
			}
			Console.ReadLine();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

// (づ*ω*)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int TrailingZeroes(int x)
    {
        int ret = 0;
        while (x % 2 == 0)
        {
            ret++;
            x >>= 1;
        }
        return ret;
    }

    public object Solve()
    {
        int x = ReadInt();
        int k = ReadInt();
        double p = ReadInt() / 100.0;
        double q = 1 - p;

        const int MASK = 1 << 8;
        const int MAX_ONES = 250;
        var dp = new double[MASK, MAX_ONES];

        int rep;
        if (x % MASK == 0)
            rep = TrailingZeroes(x) - 8;
        else
        {
            rep = 0;
            int xx = x >> 8;
            while (xx % 2 == 1)
            {
                rep++;
                xx >>= 1;
            }
        }
        dp[x % MASK, rep] = 1;

        for (int step = 0; step < k; step++)
        {
            var ndp = new double[MASK, MAX_ONES];
            for (int i = 0; i < MASK; i++)
                for (int j = 0; j < MAX_ONES; j++)
                    if (dp[i,j] > 0)
                    {
                        if (i == 0)
                        {
                            ndp[0, j + 1] += dp[0, j] * p;
                            ndp[1, 0] += dp[0, j] * q;
                        }
                        else
                        {
                            int ii = (i << 1) % MASK;
                            int jj;
                            if (ii == 0)
                                jj = 0;
                            else
                                jj = (i >> 7 & 1) == 1 ? j + 1 : 0;
                            ndp[ii, jj] += dp[i, j] * p;

                            ii = i + 1;
                            if (ii == MASK)
                                ndp[0, j] += dp[i, j] * q;
                            else
                                ndp[ii, j] += dp[i, j] * q;
                        }
                    }
            dp = ndp;
        }

        double ans = 0;

        for (int i = 0; i < MASK; i++)
            for (int j = 0; j < MAX_ONES; j++)
                if (i == 0)
                    ans += (8 + j) * dp[0, j];
                else
                    ans += TrailingZeroes(i) * dp[i, j];

        return ans.ToString(CultureInfo.InvariantCulture);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = Console.In;
        writer = new StreamWriter(Console.OpenStandardOutput());
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read/Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Web;

class Program
{
    static int Max(int a1, int a2, int a3)
    {
        int max = a1 > a2 ? a1 : a2;
        return a3 > max ? a3 : max;
    }

    static int Max(int a1, int a2)
    {
        return a1 > a2 ? a1 : a2;
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int mod = 1000000007;

        var a = new int[n + 1];
        var b = new int[n + 1];
        var c = new int[n + 1];
        var d = new int[n + 1];

        a[1] = 1;
        b[1] = 1;
        c[1] = 1;
        d[1] = 0;

        for (int i = 2; i <= n; i++)
        {
            a[i] = ((b[i - 1] + c[i - 1])%mod + d[i - 1])%mod;
            b[i] = ((a[i - 1] + c[i - 1])%mod + d[i - 1])%mod;
            c[i] = ((b[i - 1] + a[i - 1])%mod + d[i - 1])%mod;
            d[i] = ((b[i - 1] + c[i - 1])%mod + a[i - 1])%mod;
        }

        Console.WriteLine(d[n]);
    }

}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace prA {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            HashSet<string> set = new HashSet<string>();
            string s = reader.ReadLine();
            char[] a = s.ToCharArray();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.Length; i++) {
                sb.Clear();
                for (int j = i; j < s.Length; j++) {
                    sb.Append(a[j]);
                }
                for (int j = 0; j < i; j++) {
                    sb.Append(a[j]);
                }
                set.Add(sb.ToString());
            }

            writer.Write(set.Count);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var data = Console.ReadLine().Split().Select(d => int.Parse(d)).ToArray();

            var x = new int[3];
            var y = new int[3];
            x[0] = data[0];
            y[0] = data[1];
            x[1] = data[2];
            y[1] = data[3];
            x[2] = data[4];
            y[2] = data[5];

            for (int i = 0; i < 3; i++)
                for (int j = i + 1; j < 3; j++)
                {
                    var a = length(x[i], y[i], x[j], y[j]);
                    var tp = getOther(i, j);
                    var b = length(x[i], y[i], x[tp], y[tp]);
                    var c = length(x[j], y[j], x[tp], y[tp]);

                    if (checkPif(a, b, c))
                    {
                        Console.WriteLine("RIGHT");
                        return;
                    }
                }

            var ixs = new int[3];
            var iys = new int[3];
            for (int i = 0; i < 3; i++)
                for (int j = i + 1; j < 3; j++)
                {

                    var tp = getOther(i, j);

                    ixs[0] = x[i];
                    ixs[1] = x[j];
                    ixs[2] = x[tp];

                    iys[0] = y[i];
                    iys[1] = y[j];
                    iys[2] = y[tp];

                    for (int k = 0; k < 3; k++)
			        {
                        ixs[k] ++;
                        var a = length(ixs[0], iys[0], ixs[1], iys[1]);
                        var b = length(ixs[0], iys[0], ixs[2], iys[2]);
                        var c = length(ixs[1], iys[1], ixs[2], iys[2]);

                        if (!checkTr(a, b, c))
                        {
                            ixs[k]--;
                            continue;
                        }

                        if (checkPif(a, b, c))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }

                        ixs[k]--;
			        }

                    for (int k = 0; k < 3; k++)
                    {
                        ixs[k]--;
                        var a = length(ixs[0], iys[0], ixs[1], iys[1]);
                        var b = length(ixs[0], iys[0], ixs[2], iys[2]);
                        var c = length(ixs[1], iys[1], ixs[2], iys[2]);

                        if (!checkTr(a, b, c))
                        {
                            ixs[k]++;
                            continue;
                        }

                        if (checkPif(a, b, c))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }

                        ixs[k]++;
                    }

                    for (int k = 0; k < 3; k++)
                    {
                        iys[k]++;
                        var a = length(ixs[0], iys[0], ixs[1], iys[1]);
                        var b = length(ixs[0], iys[0], ixs[2], iys[2]);
                        var c = length(ixs[1], iys[1], ixs[2], iys[2]);

                        if (!checkTr(a, b, c))
                        {
                            iys[k]--;
                            continue;
                        }

                        if (checkPif(a, b, c))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }

                        iys[k]--;
                    }

                    for (int k = 0; k < 3; k++)
                    {
                        iys[k]--;
                        var a = length(ixs[0], iys[0], ixs[1], iys[1]);
                        var b = length(ixs[0], iys[0], ixs[2], iys[2]);
                        var c = length(ixs[1], iys[1], ixs[2], iys[2]);

                        if (!checkTr(a, b, c))
                        {
                            iys[k]++;
                            continue;
                        }

                        if (checkPif(a, b, c))
                        {
                            Console.WriteLine("ALMOST");
                            return;
                        }

                        iys[k]++;
                    }
                }

            Console.WriteLine("NEITHER");

        }

        static HashSet<int> vars = new HashSet<int>() { 0, 1, 2 };
        static int getOther(int a, int b)
        {
            var s = new HashSet<int> { a, b };
            s.SymmetricExceptWith(vars);
            return s.FirstOrDefault();
        }

        static double length(int x1, int y1, int x2, int y2)
        {
            return Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
        }

        static bool checkTr(double a, double b, double c)
        {
            if (a + b <= c)
            {
                return false;
            }
            else if (a + c <= b)
            {
                return false;
            }
            else if (b + c <= a)
            {
                return false;
            }

            return true;
        }

        static bool checkPif(double a, double b, double c)
        {
            var a2 = a * a;
            var b2 = b * b;
            var c2 = c * c;
            if (Math.Abs(a2 + b2 - c2) < 0.0000001)
            {
                return true;
            }
            else if (Math.Abs(a2 + c2 - b2) < 0.0000001)
            {
                return true;
            }
            else if (Math.Abs(b2 + c2 - a2) < 0.0000001)
            {
                return true;
            }

            return false;
        }
    }
}