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

namespace Codeforces
{
    public class Input
    {
        private static string _line;

        public static bool Next()
        {
            _line = Console.ReadLine();
            return !string.IsNullOrEmpty(_line);
        }

        public static bool Next(out long a)
        {
            var ok = Next();
            a = ok ? long.Parse(_line) : 0;
            return ok;
        }

        public static bool Next(out long a, out long b)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
            }
            else
            {
                a = b = 0;
            }

            return ok;
        }

        public static bool Next(out long a, out long b, out long c)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
            }
            else
            {
                a = b = c = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
            }
            else
            {
                a = b = c = d = 0;
            }
            return ok;
        }

        public static bool Next(out long a, out long b, out long c, out long d, out long e)
        {
            var ok = Next();
            if (ok)
            {
                var array = _line.Split(' ').Select(long.Parse).ToArray();
                a = array[0];
                b = array[1];
                c = array[2];
                d = array[3];
                e = array[4];
            }
            else
            {
                a = b = c = d = e = 0;
            }
            return ok;
        }

        public static List<long> Numbers()
        {
            return !Next() ? new List<long>() : _line.Split(' ').Select(long.Parse).ToList();
        }

        public static bool Next(out string value)
        {
            value = string.Empty;
            if (!Next()) return false;
            value = _line;
            return true;
        }
    }

    public class DisjointSet
    {
        private readonly int[] _parent;
        private readonly int[] _rank;
        public int Count { get; private set; }

        public DisjointSet(int count, int initialize = 0)
        {
            Count = count;
            _parent = new int[Count];
            _rank = new int[Count];
            for (var i = 0; i < initialize; i++) _parent[i] = i;
        }

        private DisjointSet(int count, int[] parent, int[] rank)
        {
            Count = count;
            _parent = parent;
            _rank = rank;
        }

        public void Add(int v)
        {
            _parent[v] = v;
            _rank[v] = 0;
        }

        public int Find_Recursive(int v)
        {
            if (_parent[v] == v) return v;
            return _parent[v] = Find(_parent[v]);
        }

        public int Find(int v)
        {
            if (_parent[v] == v) return v;
            var last = v;
            while (_parent[last] != last) last = _parent[last];
            while (_parent[v] != v)
            {
                var t = _parent[v];
                _parent[v] = last;
                v = t;
            }
            return last;
        }

        public int this[int v]
        {
            get { return Find(v); }
            set { Union(v, value); }
        }

        public void Union(int a, int b)
        {
            a = Find(a);
            b = Find(b);
            if (a == b) return;
            if (_rank[a] < _rank[b])
            {
                var t = _rank[a];
                _rank[a] = _rank[b];
                _rank[b] = t;
            }
            _parent[b] = a;
            if (_rank[a] == _rank[b]) _rank[a]++;
        }

        public int GetSetCount()
        {
            var result = 0;
            for (var i = 0; i < Count; i++)
            {
                if (_parent[i] == i) result++;
            }
            return result;
        }

        public DisjointSet Clone()
        {
            var rank = new int[Count];
            _rank.CopyTo(rank, 0);
            var parent = new int[Count];
            _parent.CopyTo(parent, 0);
            return new DisjointSet(Count, parent, rank);
        }

        public override string ToString()
        {
            return string.Join(",", _parent.Take(50));
        }
    }

    public class Matrix
    {
        public static Matrix Create(int i, int j)
        {
            var m = new Matrix(i, j);
            return m;
        }

        public static Matrix Create(int i)
        {
            var m = new Matrix(i, i);
            return m;
        }

        public long Modulo { get; set; }

        private readonly int _width;
        private readonly int _height;
        private readonly long[,] _data;
        public int Width{get { return _width; }}
        public int Height{get { return _height; }}

        private Matrix(int i, int j)
        {
            Modulo = 1000000000000000000L;
            _width = j;
            _height = i;
            _data = new long[_height, _width];
        }

        public static Matrix operator *(Matrix m1, Matrix m2)
        {
            if (m1.Width != m2.Height) throw new InvalidDataException("m1.Width != m2.Height");
            var m = Create(m2.Width, m1.Height);
            m.Modulo = m1.Modulo;
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                {
                    for (var k = 0; k < m1.Width; k++)
                        m[j, i] += (m1[j, k]*m2[k, i]) % m1.Modulo;
                    m[j, i] %= m1.Modulo;
                }
            return m;
        }

        public static Matrix operator +(Matrix m1, Matrix m2)
        {
            var m = m1.Clone();
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                    m[j, i] = (m[j, i] + m2[j, i]) % m1.Modulo;
            return m;
        }

        public static Matrix operator -(Matrix m1, Matrix m2)
        {
            var m = m1.Clone();
            for (var i=0;i<m2.Width;i++)
                for (var j = 0; j < m1.Height; j++)
                    m[j, i] = (m[j, i] - m2[j, i]) % m1.Modulo;
            return m;
        }

        public static Matrix operator *(Matrix m1, long l)
        {
            var m = m1.Clone();
            for (var i=0;i<m1.Width;i++)
                for (var j=0;j<m1.Height;j++)
                        m[j, i] = (m[j, i] * l) % m.Modulo;
            return m;
        }

        public static Matrix operator *(long l, Matrix m1)
        {
            return m1*l;
        }

        public static Matrix operator +(Matrix m1, long l)
        {
            var m = m1.Clone();
            for (var i = 0; i < m1.Width; i++)
                    m[i, i] = (m[i, i] + l) % m.Modulo;
            return m;
        }

        public static Matrix operator +(long l, Matrix m1)
        {
            return m1 + l;
        }

        public static Matrix operator -(Matrix m1, long l)
        {
            return m1 + (-l);
        }

        public static Matrix operator -(long l, Matrix m1)
        {
            var m = m1.Clone() * -1;
            return m + l;
        }

        public Matrix BinPower(long l)
        {
            var n = 1;
            var m = Clone();
            var result = new Matrix(m.Height, m.Width) + 1;
            result.Modulo = m.Modulo;
            while (l != 0)
            {
                var i = l & ~(l - 1);
                l -= i;
                while (n < i)
                {
                    m = m*m;
                    n <<= 1;
                }
                result *= m;
            }
            return result;
        }

        public void Fill(long l)
        {
            l %= Modulo;
            for (var i = 0; i < _height; i++)
                for (var j = 0; j < _width; j++)
                    _data[i, j] = l;
        }

        public Matrix Clone()
        {
            var m = new Matrix(_width, _height);
            Array.Copy(_data, m._data, _data.Length);
            m.Modulo = Modulo;
            return m;
        }

        public long this[int i, int j]
        {
            get { return _data[i, j]; }
            set { _data[i, j] = value % Modulo; }
        }
    }
}

namespace Codeforces.TaskE
{
    public class Task
    {
        public static void Main()
        {
            var task = new Task();
            try
            {
                task.Solve();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex);
                throw;
            }
        }

        bool Check(long b, long a)
        {
            if (a == 0) return false;
            if (!Check(a, b%a)) return true;
            return (b/a)%(a + 1)%2 == 0;
            var c = b/a - 1;
            if (a%2 == 1) return c%2 == 1;
            return c%(a+1)==1;
        }

        void Solve()
        {
            long t;
            Input.Next(out t);

            for (var i = 0; i < t; i++)
            {
                long a, b;
                Input.Next(out a, out b);
                if (a < b)
                {
                    var c = b;
                    b = a;
                    a = c;
                }
                Console.WriteLine(Check(a,b) ? "First" : "Second");
            }
        }
    }
}


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

namespace D.Polyline
{
    class Program
    {
        static void Main(string[] args)
        {
            long[][] p = new long[3][];
            for (var i = 0; i < 3; ++i)
                p[i] = new long[2];
            for(var i = 0; i < 3; ++i) {
                var nm = Console.ReadLine().Split();
                p[i][0] = long.Parse(nm[0]);
                p[i][1] = long.Parse(nm[1]);
            }
            Console.WriteLine(function(p));
        }
        static long function(long[][] p)
        {
            long[] x = p[0];
            long[] y = p[1];
            long[] z = p[2];
            long _x = x[0];
            long _y = y[0];

            if (x[0] == y[0] && y[0] == z[0])
                return 1;

            if (x[1] == y[1] && y[1] == z[1])
                return 1;
            if (check(x, y, z) || check(x, z, y) || check(y, x, z))
                return 2;

            return 3;

        }
        static bool check(long[] p1, long[] p2, long[] p3)
        {
            if ((p1[0] == p2[0] || p2[0] == p3[0]) && belongY(p1, p2, p3))
                return true;
            if ((p1[1] == p2[1] || p2[1] == p3[1]) && belongX(p1, p2, p3))
                return true;
            return false;
        }
        static bool belongX(long[] p1, long[] p2, long[] p3)
        {
            return Math.Min(p1[0], p3[0]) <= p2[0] && p2[0] <= Math.Max(p1[0], p3[0]);
        }
        static bool belongY(long[] p1, long[] p2, long[] p3)
        {
            return Math.Min(p1[1], p3[1]) <= p2[1] && p2[1] <= Math.Max(p1[1], p3[1]);
        }
    }
}


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

namespace Polyline
{
    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 x = new int[3];
            var y = new int[3];
            for (int i = 0; i < 3; i++)
            {
                x[i] = Next();
                y[i] = Next();
            }

            if ((x[0] == x[1] && x[0] == x[2]) || (y[0] == y[1] && y[0] == y[2]))
                writer.WriteLine("1");
            else if ((x[0] == x[1] && -1 != Math.Sign(y[0] - y[2])*Math.Sign(y[1] - y[2]))
                     || (x[0] == x[2] && -1 != Math.Sign(y[0] - y[1])*Math.Sign(y[2] - y[1]))
                     || (x[2] == x[1] && -1 != Math.Sign(y[2] - y[0])*Math.Sign(y[1] - y[0]))
                     || (y[0] == y[1] && -1 != Math.Sign(x[0] - x[2])*Math.Sign(x[1] - x[2]))
                     || (y[0] == y[2] && -1 != Math.Sign(x[0] - x[1])*Math.Sign(x[2] - x[1]))
                     || (y[2] == y[1] && -1 != Math.Sign(x[2] - x[0])*Math.Sign(x[1] - x[0]))
                )

            {
                writer.WriteLine("2");
            }
            else
                writer.WriteLine("3");

            writer.Flush();
        }

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


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

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var games = sr.ReadArrayOfInt32();
            var count = Int32.MaxValue;
            var oneCount = 0;
            for (var i = 0; i < games.Length; i++) {
                if (games[i] == 1) {
                    var zeroCount = 0;
                    for (var j = i + 1; j < games.Length; j++) {
                        if (games[j] == 0)
                            zeroCount++;
                    }
                    count = Math.Min(count, zeroCount + oneCount);
                    oneCount++;
                }
            }
            count = Math.Min(count, oneCount);
            if (count == Int32.MaxValue)
                count = 0;

            sw.Write(n - count);
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		int max = 0;
		int[] B = new int[N];
		for(int i=0;i<=N;i++){
			int cnt = 0;
			for(int j=0;j<N;j++){
				if(B[j] != A[j]) cnt++;
			}
			max = Math.Max(max,cnt);
			if(i<N) B[i] = 1;
		}
		Console.WriteLine(max);
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


using System;

namespace _630E_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Array.ConvertAll(Console.ReadLine().Split(' '), x => Convert.ToInt64(x));
            long x1 = temp[0];
            long y1 = temp[1];
            long x2 = temp[2];
            long y2 = temp[3];

            long answer = ((y2 - y1)/2 + 1)*(x2 - x1 + 1) - (x2 - x1)/2;

            Console.WriteLine(answer);
        }
    }
}


using System;
using Math = System.Math;
using Dec = System.Decimal;
using System.Globalization;
using System.Linq;

namespace taskA
{
	class newDecimal {
	private
			Int64 Z, F, kol;
	public newDecimal(decimal t, Int64 Kol) {
			kol = Kol;
			Z = Dec.ToInt64 (t);
			Int64 p = 1;
			for (int i = 0; i < kol; i ++)
				p *= 10L;
			F = Dec.ToInt64 ((t - Z) * p);
		}
		public void print () {
			Console.Write ("{0}.", Z);
			int sz = F.ToString ().Length;
			for (int i = 0; i < kol - sz; i ++)
				Console.Write (0);
			Console.Write (F);
		}
	}

	class MainClass
	{
		public static void Main(string[] args) {
			int[] a = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray();
			int x1 = a [0], y1 = a [1], x2 = a [2], y2 = a [3];
			int r1 = x2 - x1 + 1;
			int r2 = y2 - y1 + 1;
			long ans = (r2 / 2L) * r1;
			if (r2 % 2 == 1)
				ans += (r1 + 1L) / 2L;
			Console.WriteLine (ans);
		}
	}
}


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

namespace problemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var sp = Console.ReadLine().Split();
            int[] a = new int[3];
            for (int i = 0; i < 3; ++i)
                a[i] = int.Parse(sp[i]);

            System.Collections.Generic.HashSet<int> hashSet = new System.Collections.Generic.HashSet<int>();

            a[0] %= a[1];
            int d = -1;
            int pos = 0;
            while(a[0] != 0 && (!hashSet.Contains(a[0])))
            {
                hashSet.Add(a[0]);
                a[0] *= 10;
                d = a[0] / a[1];
                if (d == a[2])
                    break;
                ++pos;
                a[0] %= a[1];
            }
            Console.WriteLine((d == a[2] || a[0] == a[2]) ? pos+1 : -1);
        }
    }
}


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

namespace Position_in_Fraction
{
    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)
        {
            writer.WriteLine(Solve(args));

            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int a = Next();
            int b = Next();
            int c = Next();

            a %= b;
            a *= 10;

            var h = new HashSet<int> {a};
            for (int i = 1;; i++)
            {
                while (a < b)
                {
                    a *= 10;
                    if (c == 0)
                        return i;
                    i++;
                }

                int cc = a/b;

                if (cc == c)
                    return i;

                int aa = (a - cc*b)*10;

                if (!h.Add(aa))
                    return -1;

                a = aa;

                if (a == 0)
                {
                    if (c == 0)
                        return i + 1;
                    return -1;
                }
            }
        }

        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.IO;
using System.Text;

namespace Square_Earth
{
    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 n = Next(), x1 = Next(), y1 = Next(), x2 = Next(), y2 = Next();

            int d = D(x1, x2, n, y1 == y2) + D(y1, y2, n, x1 == x2);

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

        private static int D(int x, int y, int n, bool one)
        {
            if (Math.Abs(x - y) == n)
                return n;

            if (one)
                return Math.Abs(x - y);

            return Math.Min(x + y, n - x + n - y);
        }

        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.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace _43
{
    class Program
    {

        static void Main(string[] args)
        {

            int x1, x2, y1, y2,n;
            string []s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0].ToString());
            x1 =int.Parse(s[1]);
            y1 = int.Parse(s[2]);
            x2 = int.Parse(s[3]);
            y2 = int.Parse(s[4]);
            int p = 4 * n;
            int ans = Math.Abs(x1 - x2) + Math.Abs(y1 - y2);
            if (Math.Abs(x1 - x2) == n) ans += 2 * Math.Min(y1, y2);
            if (Math.Abs(y1 - y2) == n) ans += 2 * Math.Min(x1, x2);

            Console.WriteLine(Math.Min(ans,p-ans));

        }
    }
}


#define Online

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

delegate double F(double x);
delegate decimal Fdec(decimal x);

class Program
{//

    static void Rec(int v, int[] a, ref long cnt)
    {
        if (v == a.Length)
        {
            for (int i = 0, j = 0, p = 0; i < a.Length; i++)
            {
                p = a[i];
                j = 0;
                while (j < a.Length)
                {
                    if (p == 0) { break; }
                    p = a[p];
                    j++;
                }
                if (j == a.Length)
                    return;
            }
            cnt++;
        }
        else
        {
            for (int i = 0; i < a.Length; i++)
            {
                a[v] = i;
                Rec(v + 1, a, ref cnt);
            }
        }
    }

    static void Main(string[] args)
    {

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if FileIO
        StreamReader sr = new StreamReader("frozen.in");
        StreamWriter sw = new StreamWriter("frozen.out");
        Console.SetIn(sr);
        Console.SetOut(sw);
#endif

        int n, k;
        string[] input = ReadArray();
        const long mod=1000000007;
        n = int.Parse(input[0]);
        k = int.Parse(input[1]);
        long cnt = 0;
        int[] a = new int[k];
        Rec(0, a, ref cnt);
        for (int i = 0; i < n - k; i++)
        {
            cnt = (cnt * (n - k)) % mod;
        }
        Console.WriteLine(cnt);

#if Online
        Console.ReadLine();
#endif

#if FileIO
        sr.Close();
        sw.Close();
#endif
    }

    static string[] ReadArray()
    {
        return Console.ReadLine().Split(' ');
    }

    static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }
}

static class ArrayUtils
{
    public static int BinarySearch(int[] a, int val)
    {
        int left = 0;
        int right = a.Length - 1;
        int mid;

        while (left < right)
        {
            mid = left + ((right - left) >> 1);
            if (val <= a[mid])
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }
        }

        if (a[left] == val)
            return left;
        else
            return -1;
    }

    public static double Bisection(F f, double left, double right, double eps)
    {
        double mid;
        while (right - left > eps)
        {
            mid = left + ((right - left) / 2d);
            if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                right = mid;
            else
                left = mid;
        }
        return (left + right) / 2d;
    }

    public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
    {
        decimal m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3m;
            m2 = r - (r - l) / 3m;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
    {
        double m1, m2;
        while (r - l > eps)
        {
            m1 = l + (r - l) / 3d;
            m2 = r - (r - l) / 3d;
            if (f(m1) < f(m2))
                if (isMax)
                    l = m1;
                else
                    r = m2;
            else
                if (isMax)
                    r = m2;
                else
                    l = m1;
        }
        return r;
    }

    public static void Merge(int[] A, int p, int q, int r, int[] L, int[] R)
    {
        for (int i = p; i <= q; i++)
            L[i] = A[i];
        for (int i = q + 1; i <= r; i++)
            R[i] = A[i];

        for (int k = p, i = p, j = q + 1; k <= r; k++)
        {
            if (i > q)
            {
                for (; k <= r; k++, j++)
                    A[k] = R[j];
                return;
            }
            if (j > r)
            {
                for (; k <= r; k++, i++)
                    A[k] = L[i];
                return;
            }
            if (L[i] <= R[j])
            {
                A[k] = L[i];
                i++;
            }
            else
            {
                A[k] = R[j];
                j++;
            }
        }
    }

    public static void Merge_Sort(int[] A, int p, int r, int[] L, int[] R)
    {
        if (!(p < r)) return;
        int q = p + ((r - p) >> 1);
        Merge_Sort(A, p, q, L, R);
        Merge_Sort(A, q + 1, r, L, R);
        Merge(A, p, q, r, L, R);
    }

    static void Shake(int[] a)
    {
        Random rnd = new Random(Environment.TickCount);
        int temp, b, c;
        for (int i = 0; i < a.Length; i++)
        {
            b = rnd.Next(0, a.Length);
            c = rnd.Next(0, a.Length);
            temp = a[b];
            a[b] = a[c];
            a[c] = temp;
        }
    }
}


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

namespace Polo_the_Penguin_and_Houses
{
    internal class Program
    {
        private const int mod = 1000000007;
        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 n = Next();
            int k = Next();

            var first = new int[k];
            first[0] = 0;

            int count = 0;
            do
            {
                if (first[0] == 1)
                    break;

                var f = new bool[first.Length];
                bool ok = true;
                for (int i = 1; i < f.Length; i++)
                {
                    int index = i;
                    for (int j = 0; j < k; j++)
                    {
                        index = first[index];
                        if (index == 0)
                            break;
                    }
                    if (index != 0)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                    count++;
            } while (Next(first, k));

            long ans = count*(k);
            for (int i = n - k; i >= 1; i--)
            {
                ans = (ans*(n - k))%mod;
            }

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

        private static bool Next(int[] nn, int k)
        {
            for (int i = nn.Length - 1; i >= 0; i--)
            {
                nn[i]++;
                if (nn[i] == k)
                {
                    nn[i] = 0;
                }
                else
                {
                    return true;
                }
            }
            return false;
        }

        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.IO;
using System.Text;

namespace Board_Game
{
    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 xp = Next(), yp = Next(), xv = Next(), yv = Next();

            if (xp <= xv && yp <= yv || xp + yp <= Math.Max(xv, yv))
                writer.WriteLine("Polycarp");
            else
                writer.WriteLine("Vasiliy");
            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.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class C
    {
        private static ThreadStart s_threadStart = new C().Go;
        private static bool s_time = false;
        private static double s_eps = 1e-16;

        private void Go()
        {
            int px = GetInt();
            int py = GetInt();
            int vx = GetInt();
            int vy = GetInt();

            if (px <= vx && py <= vy)
            {
                Wl("Polycarp"); return;
            }
            if(vx <= px && vy <= py)
            {
                Wl("Vasiliy"); return;
            }

            if (px > vx)
            {
                if (px <= vy - py)
                {
                    Wl("Polycarp"); return;
                }
                Wl("Vasiliy"); return;
            }

            if (py <= vx - px)
            {
                Wl("Polycarp"); return;
            }
            Wl("Vasiliy"); return;
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 200 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString(), CultureInfo.InvariantCulture);
        }

        private static long GetLong()
        {
            return long.Parse(GetString(), CultureInfo.InvariantCulture);
        }

        private static double GetDouble()
        {
            return double.Parse(GetString(), CultureInfo.InvariantCulture);
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        #endregion
    }
}


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' };

        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

            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());

            char[] aChar = ("" + a).ToCharArray();
            char[] bChar = ("" + b).ToCharArray();

            if (aChar.Length < bChar.Length)
            {
                Array.Sort(aChar);

                Array.Reverse(aChar);

                Console.WriteLine(new string(aChar));

                return;
            }

            int[] aDigit = new int[10];
            int[] bDigit = new int[10];

            foreach (char ch in aChar)
            {
                aDigit[ch - '0']++;
            }

            foreach (char ch in bChar)
            {
                bDigit[ch - '0']++;
            }

            bool same = true;

            for (int i = 0; i < 10; i++)
            {
                if (aDigit[i] != bDigit[i])
                {
                    same = false;
                }
            }

            if (same)
            {
                Console.WriteLine(b);
                return;
            }

            long answer = 0;

            for (int divide = 0; divide < aChar.Length; divide++)
            {
                if (divide >= 1)
                {
                    if (aDigit[bChar[divide - 1] - '0'] == 0)
                    {
                        break;
                    }

                    aDigit[bChar[divide - 1] - '0']--;
                }

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < divide; i++)
                {
                    sb.Append(bChar[i]);
                }

                int usedLower = -1;

                for (int d = (bChar[divide] - '0') - 1; d >= (divide == 0 ? 1 : 0); d--)
                {
                    if (aDigit[d] > 0)
                    {
                        usedLower = d;
                        break;
                    }
                }

                if (usedLower < 0)
                {
                    continue;
                }

                sb.Append((char)('0' + usedLower));

                aDigit[usedLower]--;

                for (int i = divide + 1; i < aChar.Length; i++)
                {
                    for (int d = 9; d >= 0; d--)
                    {
                        for (int x = 0; x < aDigit[d] && i < aChar.Length; x++, i++)
                        {
                            sb.Append((char)('0' + d));
                        }
                    }
                }

                aDigit[usedLower]++;

                answer = Math.Max(answer, long.Parse(sb.ToString()));
            }

            Console.WriteLine(answer);

#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.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' };

        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

            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());

            char[] aChar = ("" + a).ToCharArray();
            char[] bChar = ("" + b).ToCharArray();

            if (aChar.Length < bChar.Length)
            {
                Array.Sort(aChar);

                Array.Reverse(aChar);

                Console.WriteLine(new string(aChar));

                return;
            }

            int[] aDigit = new int[10];
            int[] bDigit = new int[10];

            foreach (char ch in aChar)
            {
                aDigit[ch - '0']++;
            }

            foreach (char ch in bChar)
            {
                bDigit[ch - '0']++;
            }

            bool same = true;

            for (int i = 0; i < 10; i++)
            {
                if (aDigit[i] != bDigit[i])
                {
                    same = false;
                }
            }

            if (same)
            {
                Console.WriteLine(b);
                return;
            }

            long answer = 0;

            for (int divide = 0; divide < aChar.Length; divide++)
            {
                if (divide >= 1)
                {
                    if (aDigit[bChar[divide - 1] - '0'] == 0)
                    {
                        break;
                    }

                    aDigit[bChar[divide - 1] - '0']--;
                }

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < divide; i++)
                {
                    sb.Append(bChar[i]);
                }

                int usedLower = -1;

                for (int d = (bChar[divide] - '0') - 1; d >= (divide == 0 ? 1 : 0); d--)
                {
                    if (aDigit[d] > 0)
                    {
                        usedLower = d;
                        break;
                    }
                }

                if (usedLower < 0)
                {
                    continue;
                }

                sb.Append((char)(usedLower + '0'));

                aDigit[usedLower]--;

                for (int i = divide + 1; i < aChar.Length; i++)
                {
                    for (int d = 9; d >= 0; d--)
                    {
                        for (int x = 0; x < aDigit[d] && i < aChar.Length; x++, i++)
                        {
                            sb.Append((char)(d + '0'));
                        }
                    }
                }

                aDigit[usedLower]++;

                answer = Math.Max(answer, long.Parse(sb.ToString()));
            }

            Console.WriteLine(answer);

#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.IO;
using System.Text;

namespace Solution_for_Cube
{
    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)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            int n = 24;

            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
            {
                a[i] = Next();
            }

            if (check(a))
                return true;

            var b = new int[n + 1];

            b[13] = a[5];
            b[14] = a[6];
            b[15] = a[7];
            b[16] = a[8];

            b[5] = a[17];
            b[6] = a[18];
            b[7] = a[19];
            b[8] = a[20];

            b[17] = a[21];
            b[18] = a[22];
            b[19] = a[23];
            b[20] = a[24];

            b[21] = a[13];
            b[22] = a[14];
            b[23] = a[15];
            b[24] = a[16];

            b[1] = a[3];
            b[2] = a[1];
            b[3] = a[4];
            b[4] = a[2];

            b[9] = a[10];
            b[10] = a[12];
            b[11] = a[9];
            b[12] = a[11];

            if (check(b))
                return true;

            var c = new int[n + 1];

            c[1] = a[18];
            c[2] = a[20];
            c[3] = a[17];
            c[4] = a[19];

            c[5] = a[6];
            c[6] = a[8];
            c[7] = a[5];
            c[8] = a[7];

            c[9] = a[14];
            c[10] = a[16];
            c[11] = a[13];
            c[12] = a[15];

            c[13] = a[2];
            c[14] = a[4];
            c[15] = a[1];
            c[16] = a[3];

            c[17] = a[10];
            c[18] = a[12];
            c[19] = a[9];
            c[20] = a[11];

            c[21] = a[23];
            c[22] = a[21];
            c[23] = a[24];
            c[24] = a[22];

            if (check(c))
                return true;

            return false;
        }

        private static bool check(int[] a)
        {
            if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]
                && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])
            {
                for (int i = 3; i < a.Length; i += 3)
                {
                    if (a[i] != a[i - 2])
                        return false;
                    i++;
                    if (a[i] != a[i - 2])
                        return false;
                }

                var b = new[] {a[1], a[5], a[9], a[22]};
                var c = new[] {a[2], a[6], a[10], a[21]};

                for (int i = 1; i < 4; i += 2)
                {
                    bool ok = true;

                    for (int j = 0; j < 4; j++)
                    {
                        if (b[(j + i)%4] != c[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        return true;
                }
            }
            return false;
        }

        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.Generic;
using System.Linq;
using System.Text;

namespace _86A
{
    class Program
    {
        static void Main(string[] args)
        {
            int l = 0, r = 0;
            string input = Console.ReadLine();
            l = Convert.ToInt32(input.Split(' ')[0]);
            r = Convert.ToInt32(input.Split(' ')[1]);

            string sl = l.ToString();
            string sr = r.ToString();

            ulong num = 0;

            if (sr.Length > sl.Length)
            {
                if (Convert.ToInt16(sr[0]) - 48 >= 5)
                {
                    string biggest = "5";
                    for (int i = 0; i < sr.Length - 1; i++)
                    {
                        biggest += "0";
                    }
                    num = Convert.ToUInt64(biggest);
                }
                else
                {
                    num = Convert.ToUInt64(r);
                }
            }
            else if (sr.Length == sl.Length)
            {
                if (r == l)
                {
                    num = Convert.ToUInt64(r);
                }

                else if (Convert.ToInt16(sr[0]) - 48 >= 5 && Convert.ToInt16(sl[0]) - 48 >= 5)
                {
                    num = Convert.ToUInt64(l);
                }
                else if (Convert.ToInt16(sr[0]) - 48 <= 4 && Convert.ToInt16(sl[0]) - 48 <= 4)
                {
                    num = Convert.ToUInt64(r);
                }
                else
                {
                    string biggest = "5";
                    for (int i = 0; i < sr.Length-1; i++)
                    {
                        biggest += "0";
                    }
                    num = Convert.ToUInt64(biggest);

                }

            }

            Console.WriteLine(refl(num) * num);
            Console.ReadLine();

        }

        static public ulong refl(ulong num)
        {
            string sr = num.ToString();
            string nine = "";
            for (int i = 0; i < sr.Length; i++)
            {
                nine += "9";
            }
            return(Convert.ToUInt64(nine) - num);
        }
    }
}


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

class Solver
{
    public void Solve()
    {
        /*
        long max = 0;
        for (int i = 0; ; i++)
        {
            long a = _search(i, i);
            if (a > max)
            {
                Debug.WriteLine(i + "\t" + a+"\tmax");
                max = a;
            }
            else
                Debug.WriteLine(i + "\t" + a);

        }
        */

        var ss = CF.ReadLine().Split(' ');
        int l = int.Parse(ss[0]);
        int r = int.Parse(ss[1]);

        int d = _d(r);
        long dmax = 0;
        {
            for (int i = 0; i < d ; i++)
            {
                dmax *= 10;
                if( i==0)
                    dmax += 4;
                else
                    dmax += 9;
            }
        }

        int n;
        if (r < dmax)
            n = r;
        else if (l > dmax)
            n = l;
        else
            n = (int)dmax;

        CF.WriteLine(_search(n, n));
    }

    int _d(int n)
    {
        int d = 0;
        {
            int tmp = n;
            for (; ; )
            {
                if (tmp == 0)
                    break;
                d += 1;
                tmp /= 10;
            }
        }
        return d;
    }

    long _search(int l,int r)
    {
        long max = 0;
        for (int i = l; i <= r; i++)
        {
            int tmp = i;
            Stack<int> ds = new Stack<int>();
            for (; ; )
            {
                if (tmp == 0)
                    break;
                ds.Push(tmp % 10);
                tmp/= 10;
            }

            long o=0;
            foreach (var d in ds)
            {
                o *= 10;
                o += (9-d);
            }

            long p = (long)o * i;
            max = Math.Max(p, max);
        }
        return max;
    }

    //  test
    static Utils CF = new Utils(new[]{
@"
1 1000000000
",

@"
1 999
",

@"
500000000 999999999
",
@"
3 7
",
 @"
1 1
",
 @"
8 10
"

    });
    #region test

    static void Main(string[] args)
    {
#if DEBUG
        for (int t=0;t<CF.TestCount;t++ )
        {
            CF.Test(t);
            new Solver().Solve();
        }
#else
        new Solver().Solve();
#endif
    }

    class Utils
    {
        public void Test(int t)
        {
            _lines = new List<string>();
            string[] ss = _test_input[t].Replace("\n", "").Split('\r');
            for (int i = 0; i < ss.Length; i++)
            {
                if (
                    (i == 0 || i == ss.Length - 1) &&
                    ss[i].Length == 0
                    )
                    continue;

                _lines.Add(ss[i]);
            }
        }

        public int TestCount
        {
            get
            {
                return _test_input.Length;
            }
        }

        public string ReadLine()
        {
#if DEBUG
            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;

#else
            //return _sr.ReadLine();
        return Console.In.ReadLine();
#endif
        }

        public void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            //_sw.WriteLine(o);
        Console.WriteLine(o);
#endif
        }

        public void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
                //_sw.Write(o);
        Console.Write(o);
#endif
        }

        string[] _test_input;

        List<string> _lines;

#if DEBUG
        public Utils(string[] test_input)
        {
            _test_input = test_input;
        }
#else

        public Utils(string[] dummy)
        {
            //_sr = new System.IO.StreamReader("input.txt");
            //_sw = new System.IO.StreamWriter("output.txt");
        }
#endif

    }

    #endregion
}


using System;

namespace GeneticEngineering
{
    partial class GeneticEngineering
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            char current;
            int count = 1, min = 0;

            current = s[0];

            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] == current)
                    count++;
                else
                {
                    current = s[i];

                    if (count % 2 == 0)
                        min++;

                    count = 1;
                }
            }

            if (count % 2 == 0)
                min++;

            Console.WriteLine(min);
        }
    }

    partial class GeneticEngineering
    {
        static string[] tokens = new string[0];
        static int cur_token = 0;

        static void ReadArray(char sep)
        {
            cur_token = 0;
            tokens = Console.ReadLine().Split(sep);
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int NextInt()
        {
            if (cur_token == tokens.Length)
                ReadArray(' ');
            return int.Parse(tokens[cur_token++]);
        }

        static long NextLong()
        {
            if (cur_token == tokens.Length)
                ReadArray(' ');
            return long.Parse(tokens[cur_token++]);
        }

        static double NextDouble()
        {
            if (cur_token == tokens.Length)
                ReadArray(' ');
            return double.Parse(tokens[cur_token++]);
        }

        static decimal NextDecimal()
        {
            if (cur_token == tokens.Length)
                ReadArray(' ');
            return decimal.Parse(tokens[cur_token++]);
        }

        static string NextToken()
        {
            if (cur_token == tokens.Length)
                ReadArray(' ');
            return tokens[cur_token++];
        }

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


using System;
using System.Collections.Generic;

namespace JustShit
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int j = 0;
            int kol = 0;

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

            for (int i = 0; i < str.Length; i++)
            {
                if (i == 0)
                {
                    count.Add(1);
                }
                else if (Convert.ToChar(str[i]) == Convert.ToChar(str[i - 1]))
                {
                    count[j] += 1;
                }
                else
                {
                    j += 1;
                    count.Add(1);
                }
            }

            for (int i = 0; i < count.Count; i++)
            {
                if (count[i] % 2 == 0)
                {
                    kol += 1;
                }
            }

            Console.WriteLine(kol);
        }
    }
}


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

namespace ForAll
{
    class Program
    {

        static void Main(string[] args)
        {
            Int64[] parametrs = Array.ConvertAll(Console.ReadLine().Split(' '),Int64.Parse);

            Int64 n = parametrs[0], l = parametrs[1],r = parametrs[2];

            Int64 lengthString = (Int64)Math.Pow(2, ((Int64)Math.Log(n, 2)) + 1) - 1;

            int counter = 0;
            for (Int64 i = l; i < r + 1; i++)
            {
                if (BinarySearch(lengthString, n, i) >= 1)
                    counter++;
            }

            Console.WriteLine(counter);
        }

        static int BinarySearch(Int64 lengthValue,Int64 root,Int64 index)
        {
            Int64 current = lengthValue / 2 + 1;
            Int64 path = current;
            while (current!=index)
            {
                path = path / 2;
                if (index < current)
                    current = current - path;
                else
                    current = current + path;
                if (root > 1)
                    root = root / 2;
            }

            if (index % 2 == 0)
                return (int)(root % 2);
            else return (int)(root);
        }

    }
}


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

namespace Codeforces
{
	internal class Template
	{
		private Dictionary<Tuple<long, long, long>, long> dp;

		private void Solve()
		{
			dp = new Dictionary<Tuple<long, long, long>, long>();

			var n = cin.NextLong();
			var l = cin.NextLong();
			var r = cin.NextLong();

			if (n == 0)
			{
				Console.WriteLine(0);
				return;
			}

			var count = Count(n, l-1, r-1);
			Console.WriteLine(count);
		}

		private long Count(long n, long l, long r)
		{
			if (n == 1)
			{
				return 1;
			}

			if (dp.ContainsKey(Tuple.Create(n, l, r)))
			{
				return dp[Tuple.Create(n, l, r)];
			}

			var idx = 0;
			var nn = n;
			while (nn > 1)
			{
				idx++;
				nn/=2;
			}
			var len = 1L;
			for (var i = 0; i < idx; i++)
			{
				len *= 2;
				len++;
			}
			var middle = len/2;
			var sum = 0L;
			if (l <= middle && r >= middle)
			{
				sum += n%2;
				if (l < middle)
				{
					sum += Count(n/2, l, middle - 1);
				}
				if (r > middle)
				{
					sum += Count(n/2, 0, r - middle - 1);
				}
			}
			else if (l < middle)
			{
				sum += Count(n/2, l, r);
			}
			else
			{
				sum += Count(n/2, l - middle - 1, r - middle - 1);
			}
			dp[Tuple.Create(n, l, r)] = sum;
			return sum;
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#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.IO;
using System.Text;

namespace Code_For_1
{
    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)
        {
            long n = Next();
            long l = Next();
            long r = Next();

            string s = Convert.ToString(n, 2);

            long step = 1;
            long sum = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '1')
                {
                    long bl = (l - step + 2*step - 1)/(2*step);
                    long br = (r + 1 - step + 2*step - 1)/(2*step);
                    sum += br - bl;
                }

                step *= 2;
            }

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

        private static long Next()
        {
            int c;
            long 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.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            //using (var sw = new StreamWriter("output.txt"))
            {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        private long l;
        private long r;
        private int answ;

        public void Solve(InputReader sr, TextWriter sw)
        {
            var input = sr.ReadArray(Int64.Parse);
            var n = input[0];
            l = input[1];
            r = input[2];
            Divide(n, 1L);
            sw.WriteLine(answ);
        }

        private void Divide(long n, long indx)
        {
            if (indx > r)
            {
                return;
            }
            if (n == 0 || n == 1)
            {
                if (indx >= l && indx <= r && n == 1L)
                {
                    answ++;
                }
                return;
            }
            var log = GetLog2(n);
            var power = GetPower(2L, log) / 2 - 1L;
            if (indx + (power) * 2 + 1L < l)
            {
                return;
            }
            Divide(n / 2, indx);
            if (indx + power >= l && indx + power <= r && n % 2 == 1L)
            {
                answ++;
            }
            Divide(n / 2, indx + power + 1L);
        }

        private long GetLog2(long n)
        {
            var log = 0;
            while (n > 0) {
                n /= 2;
                log++;
            }

            return log;
        }

        public long GetPower(long n, long p)
        {
            var power = 1L;
            for (var i = 0; i < p; i++) {
                power *= n;
            }

            return power;
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


//#define EXTENDSTACKSIZE

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

namespace CF
{
    internal class Program
    {
        private const int stackSize = 64 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var m = sr.NextInt32();
            var coffee = sr.ReadArrayOfInt64();
            var start = 1;
            var end = n;
            var sum = coffee.Sum();
            if (sum < m)
            {
                sw.WriteLine(-1);
                return;
            }

            Array.Sort(coffee, (a, b) => -a.CompareTo(b));
            var answ = -1;
            while (start <= end)
            {
                var mid = (start + end) / 2;
                var res = 0L;
                for (var i = 0; i < mid; i++)
                {
                    res += coffee[i];
                }

                var indx = 0;
                var usedCount = Enumerable.Repeat(1, mid).ToArray();
                    for (var i = mid; i < n; i++)
                    {
                        res += Math.Max(0, coffee[i] - usedCount[indx]);
                        usedCount[indx]++;
                        indx++;
                        indx = indx % mid;
                    }

                if (res >= m)
                {
                    end = mid - 1;
                    answ = mid;
                }
                else
                {
                    start = mid + 1;
                }
            }

            sw.WriteLine(answ);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N;
    long M;
    long[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();

        A = sc.LongArray();

        Array.Sort(A, (l, r) => r.CompareTo(l));

        /*
         * mページ書く
         *
         * n個コーヒー
         *
         * iはa_iカフェイン
         *
         * k杯飲む
         * 1杯目 a_i
         * 2    a_i-1
         * ...
         *
         * 最小日数
         */

        int ok = N + 1;
        int ng = 0;
        while (ok - ng > 1)
        {
            int mid = (ok + ng) / 2;
            if (F(mid)) ok = mid;
            else ng = mid;
        }

        if(ok <= N)
        {
            Console.WriteLine(ok);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }

    // d日
    bool F(int d)
    {
        //
        long t = 0;
        for (int i = 0; i < N; i++)
        {
            t += Math.Max(0, A[i] - i / d);
        }

        return t >= M;

    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;

namespace Caesar
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n1, n2, k1, k2, mod = 100000000;
			string[] line = Console.ReadLine().Split();
			n1 = Convert.ToInt32(line[0]);
			n2 = Convert.ToInt32(line[1]);
			k1 = Convert.ToInt32(line[2]);
			k2 = Convert.ToInt32(line[3]);
			int[,,] dp = new int[n1 + 1, n2 + 1, 2];
			dp[0, 0, 0] = dp[0, 0, 1] = 1;
			for (int i = 0; i <= n1; i++)
			{
				for (int j = 0; j <= n2; j++)
				{
					if (i == 0 && j != 0)
					{
						if (j <= k2) dp[i, j, 1] = 1;
						else dp[i, j, 1] = 0;
						dp[i, j, 0] = 0;
					}
					else if (i != 0 && j == 0)
					{
						if (i <= k1) dp[i, j, 0] = 1;
						else dp[i, j, 0] = 0;
						dp[i, j, 1] = 0;
					}
					else
					{
						for (int k = 1; k <= k1; k++)
						{
							if (k <= i)
							{
								dp[i, j, 0] = (dp[i, j, 0] + dp[i - k, j, 1]) % mod;
							}
						}
						for (int k = 1; k <= k2; k++)
						{
							if (k <= j)
							{
								dp[i, j, 1] = (dp[i, j, 1] + dp[i, j - k, 0]) % mod;
							}
						}
					}
				}
			}
			Console.WriteLine((dp[n1, n2, 0] + dp[n1, n2, 1]) % mod);
			Console.ReadLine();
		}
	}
}