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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            const int MOD = 998244353;

            var ntt = new NTTFast(MOD);

            int n = ReadInt();
            int k = ReadInt();
            int[] d = ReadIntArray();

            int m = 1;
            int p = 0;
            while (m < 5 * n)
            {
                m <<= 1;
                p++;
            }

            int[] a = new int[m];
            for (int i = 0; i < k; i++)
            {
                a[d[i]] = 1;
            }

            ntt.FFT(a);

            for (int i = 0; i < m; i++)
            {
                a[i] = ntt.Power(a[i], n / 2);
            }

            ntt.FFT(a);

            long invM = ntt.Inv(m);

            long ans = 0;
            for (int i = 0; i < a.Length; i++)
            {
                long c = a[i] * invM % MOD;
                ans = (ans + c * c) % MOD;
            }

            Writer.WriteLine(ans);
        }

        public class NTTFast
        {
            private int curBase = 1;
            private int[] roots = { 0, 1 };
            private int[] rev = { 0, 1 };
            private int maxBase = -1;
            private int root = -1;

            private readonly int MOD;

            public NTTFast(int mod)
            {
                MOD = mod;
            }

            private void Init()
            {
                int tmp = MOD - 1;
                maxBase = 0;
                while (tmp % 2 == 0)
                {
                    tmp /= 2;
                    maxBase++;
                }
                root = 2;
                while (true)
                {
                    if (Power(root, 1 << maxBase) == 1)
                    {
                        if (Power(root, 1 << (maxBase - 1)) != 1)
                        {
                            break;
                        }
                    }
                    root++;
                }
            }

            void ensure_base(int nBase)
            {
                if (maxBase == -1)
                {
                    Init();
                }
                if (nBase <= curBase)
                {
                    return;
                }
                if (nBase > maxBase)
                {
                    throw new InvalidOperationException();
                }
                Array.Resize(ref rev, 1 << nBase);
                for (int i = 0; i < (1 << nBase); i++)
                {
                    rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nBase - 1));
                }
                Array.Resize(ref roots, 1 << nBase);
                while (curBase < nBase)
                {
                    int z = Power(root, 1 << (maxBase - 1 - curBase));
                    for (int i = 1 << (curBase - 1); i < (1 << curBase); i++)
                    {
                        roots[i << 1] = roots[i];
                        roots[(i << 1) + 1] = (int)((long)roots[i] * z % MOD);
                    }
                    curBase++;
                }
            }

            public void FFT(int[] a)
            {
                int n = a.Length;
                if ((n & (n - 1)) != 0)
                {
                    throw new InvalidOperationException();
                }
                int zeros = get__builtin_ctz(n);
                ensure_base(zeros);
                int shift = curBase - zeros;
                for (int i = 0; i < n; i++)
                {
                    if (i < (rev[i] >> shift))
                    {
                        int tmp = a[i];
                        a[i] = a[rev[i] >> shift];
                        a[rev[i] >> shift] = tmp;
                    }
                }
                for (int k = 1; k < n; k <<= 1)
                {
                    for (int i = 0; i < n; i += 2 * k)
                    {
                        for (int j = 0; j < k; j++)
                        {
                            int x = a[i + j];
                            int y = (int)((long)a[i + j + k] * roots[j + k] % MOD);
                            a[i + j] = x + y - MOD;
                            if (a[i + j] < 0)
                            {
                                a[i + j] += MOD;
                            }
                            a[i + j + k] = x - y + MOD;
                            if (a[i + j + k] >= MOD)
                            {
                                a[i + j + k] -= MOD;
                            }
                        }
                    }
                }
            }

            // todo: rename? remove?
            private int get__builtin_ctz(int n)
            {
                int c = 0;
                while (n > 0 && (n & 1) == 0)
                {
                    c++;
                    n >>= 1;
                }
                return c;
            }

            public int[] Multiply(int[] a, int[] b, int eq = 0)
            {
                int need = a.Length + b.Length - 1;
                int nbase = 0;
                while ((1 << nbase) < need)
                {
                    nbase++;
                }
                ensure_base(nbase);
                int sz = 1 << nbase;
                Array.Resize(ref a, sz);
                Array.Resize(ref b, sz);
                FFT(a);
                if (eq != 0)
                {
                    b = a;
                }
                else
                {
                    FFT(b);
                }
                int invSz = Inv(sz);
                for (int i = 0; i < sz; i++)
                {
                    a[i] = (int)((long)(int)((long)a[i] * b[i] % MOD) * invSz % MOD);
                }
                Array.Reverse(a, 1, a.Length - 1);
                FFT(a);

                int newSize = need;
                while (newSize > 0 && a[newSize - 1] == 0)
                {
                    newSize--;
                }
                Array.Resize(ref a, newSize);

                return a;
            }

            public int[] Square(int[] a)
            {
                return Multiply(a, a, 1);
            }

            public int Power(int a, long b)
            {
                int res = 1;
                while (b > 0)
                {
                    if ((b & 1) > 0)
                    {
                        res = (int)((long)res * a % MOD);
                    }
                    a = (int)((long)a * a % MOD);
                    b >>= 1;
                }
                return res;
            }

            public int Inv(int a)
            {
                a %= MOD;
                if (a < 0)
                {
                    a += MOD;
                }
                int b = MOD;
                int u = 0;
                int v = 1;
                while (a != 0)
                {
                    int t = b / a;
                    b -= t * a;

                    int tmp = a;
                    a = b;
                    b = tmp;

                    u -= t * v;

                    tmp = u;
                    u = v;
                    v = tmp;
                }
                if (u < 0)
                {
                    u += MOD;
                }
                return u;
            }
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        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 string ReadLine()
        {
            return Reader.ReadLine();
        }

        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 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.Text;

namespace B
{
    class Program
    {
        static int intFromStrBase(string s, int b)
        {
            int[] a = s.Select(c => c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'Z' ? c - 'A' + 10 : 999).ToArray();
            if (a.Any(x => x >= b))
                return -1;

            int sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum = sum * b + a[i];
                if (sum > 60)
                    return -1;
            }

            return sum;
        }

        static bool possible(string h, string m, int b)
        {
            int ih = intFromStrBase(h, b);
            int im = intFromStrBase(m, b);
            return (ih >= 0 && ih <= 23 && im >= 0 && im <= 59);
        }

        static void Main(string[] args)
        {
            string[] hm = Console.ReadLine().Split(':');
            while (hm[0].Length > 1 && hm[0].StartsWith("0"))
                hm[0] = hm[0].Substring(1);
            while (hm[1].Length > 1 && hm[1].StartsWith("0"))
                hm[1] = hm[1].Substring(1);

            List<int> poss = new List<int>();
            for (int i = 1; i <= 100; i++)
                if (possible(hm[0], hm[1], i))
                    poss.Add(i);

            if (possible(hm[0], hm[1], 99))
                Console.WriteLine(-1);
            else if(poss.Count == 0)
                Console.WriteLine(0);
            else
                foreach(var x in poss)
                    Console.Write("{0} ", x);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        int x1, y1, x2, y2,x,y;
        sc.Make(out x1, out y1, out x2, out y2, out x, out y);
        if (Abs(x2 - x1) % x != 0 || Abs(y2 - y1) % y != 0) Fail("NO");
        var a = Abs(x2 - x1) / x;
        var b = Abs(y2 - y1) / y;
        if (a % 2 == b % 2) Fail("YES");
        Console.WriteLine("NO");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


#define Online

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

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    partial class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            A();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {
            int n = ReadInt();
            int minx = int.MaxValue;
            int maxx = int.MinValue;
            int miny = int.MaxValue;
            int maxy = int.MinValue;
            int S=0;
            for (int i = 0; i < n; i++)
            {
                ReadArray(' ');
                int x1=NextInt();
                int y1=NextInt();
                int x2=NextInt();
                int y2=NextInt();
                minx = Math.Min(minx, x1);
                miny = Math.Min(miny, y1);
                maxx = Math.Max(maxx, x2);
                maxy = Math.Max(maxy, y2);
                S+=(x2-x1)*(y2-y1);
            }
            if (maxx - minx == maxy - miny && S == (maxx - minx) * (maxy - miny)) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }

        static void B()
        {
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    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<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            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 (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

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

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            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].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            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);
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R, comp);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int 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;
            }
        }
    }

    partial class Program
    {
        static string[] tokens;
        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 int NextInt()
        {
            return int.Parse(tokens[cur_token++]);
        }

        static long NextLong()
        {
            return long.Parse(tokens[cur_token++]);
        }

        static double NextDouble()
        {
            return double.Parse(tokens[cur_token++]);
        }

        static decimal NextDecimal()
        {
            return decimal.Parse(tokens[cur_token++]);
        }

        static string NextToken()
        {
            return tokens[cur_token++];
        }

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


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

namespace A
{
    class Program
    {
        static bool IsVowel(char c)
        {
            if (c == 'A' || c == 'E' || c == 'O' || c == 'U' || c == 'Y' || c == 'I')
            {
                return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            str = ' ' + str + ' ';
            int jumpSize = 1, pos = 0, next;
            do
            {
                next = pos + 1;
                while (str[next] != ' ' && !IsVowel(str[next]))
                {
                    next++;
                }
                jumpSize = Math.Max(jumpSize, next - pos);
                pos = next;
            } while (str[pos] != ' ');
            Console.WriteLine(jumpSize);
        }
    }
}


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

namespace _331a
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var n = int.Parse(Console.ReadLine());

            int? x1 = null, x2 = null, y1 = null, y2 = null;
            for (int i = 0; i < n; i++)
            {
                var d = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
                var x = d[0];
                var y = d[1];
                if (x1 == null)
                {
                    x1 = x;
                }
                else
                {
                    if (x1.Value != x)
                    {
                        x2 = x;
                    }
                }

                if (y1 == null)
                {
                    y1 = y;
                }
                else
                {
                    if (y1.Value != y)
                    {
                        y2 = y;
                    }
                }
            }

            if (x1 == null || x2 == null || y1 == null || y2 == null)
            {
                Console.WriteLine(-1);
            }
            else
            {
                var x = Math.Abs(x1.Value - x2.Value);
                var y = Math.Abs(y1.Value - y2.Value);
                Console.WriteLine(y * x);
            }
        }
    }
}


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 max = Double.MinValue;
            var maxA = 0;
            var maxB = 0;
            for (var b = 2; b < n; b++) {
                var a = n - b;
                if (a < b) {
                    var gcd = Gcd(a, b);
                    if (gcd == 1) {
                        var curr = (double) a / b;
                        if (max < curr) {
                            max = curr;
                            maxA = a;
                            maxB = b;
                        }
                    }
                }
            }

            sw.WriteLine(maxA + " " + maxB);
        }

        private int Gcd(int a, int b)
        {
            if (b == 0) {
                return a;
            }

            return Gcd(b, a % b);
        }

        ~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;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = int.Parse(Console.ReadLine());

            while (t-- > 0)
            {
                var n = int.Parse(Console.ReadLine());

                if (n % 2 == 0)
                {
                    var a = n / 2;
                    Console.WriteLine(a + " " + a);
                    continue;
                }
                var b = true;
                for (int i = 2; i * i <= n; i++)
                {
                    if (n % i == 0)
                    {
                        Console.WriteLine((n / i) + " " + (n - (n / i)));
                        b = false;
                        break;
                    }
                }

                if (b) { Console.WriteLine("1 "+(n-1)); }

            }
        }
    }
}


using System;
class Program_158A
{
    static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine()), ans = 0;
        for (int i = 2; i < n; i++)
            for (int j = i + 1; j != n; j++)
                if ((Math.Sqrt(i * i + j * j) % 1 == 0) && (Math.Sqrt(i * i + j * j) <= n)) ans++;
        Console.WriteLine(ans);
    }
}


using System;

namespace K
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			long N = long.Parse(Console.ReadLine());
			Console.WriteLine(N - N / 2 - N / 3 - N / 5 - N / 7
				+ N / 6 + N / 10 + N / 14 + N / 15 + N / 21 + N / 35
				- N / 30 - N / 42 - N / 70 - N / 105
				+ N / 210);
		}
	}
}


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

namespace FORexam
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int n = 0;
            string[] number = Console.ReadLine().Split('0');
            for (int i = 0; i < number.Length; i++)
            {
                n *= 10;
                if (number[i] != null)
                    n += number[i].Length;

            }
            Console.WriteLine(n);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static int[] sum = new int[(1 << 15)];
        static int[] min = new int[(1 << 15)];
        static int[] max = new int[(1 << 15)];
        static int[] c = new int[15];
        static void dp(int number) {
            int exp = -1, aux = number;
            while (aux > 0) {
                aux /= 2;
                exp++;
            }
            aux = number - (1 << exp);
            sum[number] = sum[aux] + c[exp];
            max[number] = Math.Max(max[aux], c[exp]);
            min[number] = Math.Min(min[aux], c[exp]);
            if (min[number] == 0) {
                min[number] = c[exp];
            }
        }
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), l = int.Parse(s[1]), r = int.Parse(s[2]), x = int.Parse(s[3]);
            c = Array.ConvertAll(Console.ReadLine().Split(' '), tz => int.Parse(tz));
            int vm = (1 << n), ans = 0;
            for (int i = 1; i < vm; i++) {
                dp(i);
                if (sum[i] >= l && sum[i] <= r && (max[i] - min[i]) >= x) {
                    ans++;
                }
            }
            Console.Write(ans);
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var vladik = true;
            var cnt = 1;
            while (arr[vladik ? 0 : 1] >= cnt)
            {
                arr[vladik ? 0 : 1] -= cnt;
                cnt++;
                vladik = !vladik;
            }

            Console.WriteLine(vladik ? "Vladik" : "Valera");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N, K;
    string S;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        S = sc.Next();

        /*
         * Sの部分列tを取る集合に加える
         * コスト n-|t|
         * 重複不可
         *
         * サイズkの集合つくる最小コスト
         */

        /*
         * t = s 1個
         *
         * |t| = |s|-1 N個
         */

        var hs = new HashSet<string>(StringComparer.Ordinal);
        hs.Add(S);
        var q = new Queue<string>();
        q.Enqueue(S);

        long ans = 0;
        for (int i = 0; i < K; i++)
        {
            if (q.Count <= 0)
            {
                Console.WriteLine("-1");
                return;
            }

            var d = q.Dequeue();
            ans += N - d.Length;
            if (d.Length <= 0) continue;
            char[] tmp = new char[d.Length - 1];
            for (int j = 0; j < d.Length - 1; j++)
            {
                tmp[j] = d[j + 1];
            }

            for (int j = 0; j < d.Length; j++)
            {
                var str = new string(tmp);
                if (hs.Add(str))
                {
                    q.Enqueue(str);
                }
                if (j < d.Length - 1) tmp[j] = d[j];
            }

        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

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;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int K = cin.nextint;
        for (int i = 1; ; i++)
        {
            var S = i.ToString();
            if (K <= S.Length)
            {
                WriteLine(S[K - 1]);
                return;
            }

            K -= S.Length;
        }
    }

}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


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

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 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 bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var n = getInt();
			var weeks = n / 7;
			var minA = weeks * 2;
			var maxA = weeks * 2;
			if (n % 7 == 1)
				maxA++;
			if (n % 7 >= 2)
				maxA += 2;
			if (n % 7 == 6)
				minA++;
			Console.WriteLine("{0} {1}", minA, maxA);
			/*			input.Close();
			output.Close();*/
		}
	}
}


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

namespace _61D2A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if ((s.Length < "127".Length) || ((s.Length == "127".Length) && (string.Compare(s, "127") != 1)))
            {
                Console.WriteLine("byte");
            }
            else if ((s.Length < "32767".Length) || ((s.Length == "32767".Length) && (string.Compare(s, "32767") != 1)))
            {
                Console.WriteLine("short");
            }
            else if ((s.Length < "2147483647".Length) || ((s.Length == "2147483647".Length) && (string.Compare(s, "2147483647") != 1)))
            {
                Console.WriteLine("int");
            }
            else if ((s.Length < "9223372036854775807".Length) || ((s.Length == "9223372036854775807".Length) && (string.Compare(s, "9223372036854775807") != 1)))
            {
                Console.WriteLine("long");
            }
            else
            {
                Console.WriteLine("BigInteger");
            }

           // Console.ReadLine();
        }
    }
}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace _371a
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var s = readLongArray();
            var l1 = s[0];
            var r1 = s[1];
            var l2 = s[2];
            var r2 = s[3];
            var k = s[4];

            if (l2 > r1 || r2 < l1)
            {
                Console.WriteLine(0);
                return;
            }

            var l = Math.Max(l1, l2);
            var r = Math.Min(r1, r2);

            var res = r - l + 1;
            if (l <= k && k <= r)
            {
                res -= 1;
            }

            Console.WriteLine(res);
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

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

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

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


using System;
using System.Numerics;
namespace _304B
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime date1 = DateTime.Parse(Console.ReadLine().Replace(':', '.'));
            DateTime date2 = DateTime.Parse(Console.ReadLine().Replace(':', '.'));
            Console.Write(Math.Abs((date1 - date2).TotalDays));
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int ans = Math.Min(n, m);

            if (ans % 2 == 0)
            {
                Console.WriteLine("Malvika");
            }
            else
            {
                Console.WriteLine("Akshat");
            }

            Console.Read();
        }
    }
}


using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var n = Int32.Parse(str[0]);
            var m = Int32.Parse(str[1]);
            var res = n;
            while (true)
            {
                res += n / m;
                n = (n / m) + n % m;
                if (n < m)
                    break;
            }

            Console.WriteLine(res);
        }
    }
}


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

namespace Codeforces
{
    public class Program
    {
        private const int MAXN = 8000;

        public static void Main(string[] args)
        {
            string n = Console.ReadLine().Trim();
            int count = 0;
            for (int i = 0; i < n.Length; i++)
            {
                if (n[i] == '4')
                {
                    count = count * 2 + 1;
                }
                else
                {
                    count = count * 2 + 2;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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)
        {
            string inputs = Console.ReadLine();
            int[] arr = inputs.Split().Select(n=>Convert.ToInt32(n)).ToArray();
            int x = arr[0];
            int y = arr[1];
            int z = arr[2];
            if(x>y)
            {
                if(x>(z+y))
                {
                    Console.WriteLine("+");
                }
                else
                {
                    Console.WriteLine("?");
                }

            }
            else if (y > x)
            {
                if (y > (z + x))
                {
                    Console.WriteLine("-");
                }
                else
                {
                    Console.WriteLine("?");
                }

            }
            else

            {
                if(x==y&&z==0)
                {
                    Console.WriteLine("0");

                }
                else
                {
                    Console.WriteLine("?");
                }

            }
            Console.ReadLine();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string[] s = Console.ReadLine ().Split (' ');
			long a = long.Parse (s [0]);
			long b = long.Parse (s [1]);

			long A = a, B = b;
			int m = 0, n = 0;
			while (A!=0) {
				m++;
				A/=2;
			}
			while (B!=0) {
				n++;
				B/=2;
			}
			int Q_m = 0, Q_n = 0;
			for (int i = 1; i <=m-2; i++)
				Q_m += i;
			long S1 = (long)Math.Pow (2, m) - 1;
			for (int i = 1; i <=m-1; i++) {
				if (S1 - (long)Math.Pow (2, m - i - 1) < a)
					Q_m++;
				else
					break;
			}
			for (int i = 1; i <=n-2; i++)
				Q_n += i;
			long S2 = (long)Math.Pow (2, n) - 1;
			for (int i = 1; i <=n-1; i++) {
				if (S2 - (long)Math.Pow (2, n - i - 1) <= b)
					Q_n++;
				else
					break;
			}
			Console.WriteLine (Q_n-Q_m);
		}
	}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = data[0];
            var b = data[1];
            Console.WriteLine(Math.Min(a,b) +" " +((Math.Max(a,b)-Math.Min(a,b))/2));
        }
    }
}


using System;

namespace keramer
{
    class program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            if(num <= 10 )
                Console.WriteLine(0);
            else if ( num<=19)
                Console.WriteLine(4);
            else if (num == 20)
                Console.WriteLine(15);
            else if (num == 21)
                Console.WriteLine(4);
            else
                Console.WriteLine(0);
        }
    }
}


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

namespace codeforces
{
    class Program
    {
        const int N = 2000 * 100;

        static int[] a = new int[N];

        static bool check(ref int n, ref int m, ref int day)
        {
            long sum = 0;
            int ia = n - 1;
            int iday = 0;
            int num = 0;
            while (ia >= 0 && a[ia] > num)
            {
                sum += a[ia] - num;
                iday++;
                if (iday >= day)
                {
                    iday -= day;
                    num++;
                }
                ia--;
            }
            return sum >= m;
        }

        static void Main(string[] args)
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);
            t = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; ++i)
            {
                a[i] = int.Parse(t[i]);
            }
            Array.Sort(a, 0, n);

            int l = 0;
            int r = n + 1;
            while (l + 1 < r)
            {
                int mid = (l + r) / 2;
                if (check(ref n, ref m, ref mid))
                {
                    r = mid;
                }
                else
                {
                    l = mid;
                }
            }
            Console.WriteLine(r == n + 1 ? "-1" : r.ToString());
            Console.Read();
        }
    }
}


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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split();
            string res = a[0][0].ToString();
            for (int i = 1; i < a[0].Length; ++i)
            {
                if (a[0][i] < a[1][0]) res += a[0][i];
                else break;
            }
            res += a[1][0];
            Console.WriteLine(res);
        }
    }
}


using System;

namespace problem_solve_with_csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] whk = Array.ConvertAll(Console.ReadLine().Split(), e => long.Parse(e));
            long w = whk[0];
            long h = whk[1];
            long k = whk[2];
            long sum = 0;
            long i=0;
            for (long j = 1; j <= k; j++)
            {
                sum += 2 * ((w - i) + (h - i)) - 4;
                i += 4;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Codeforces
{
    internal class Program
    {
        private const string Test = "B1";

        private static void Solve()
        {
            var input = ReadIntArray();
            var a = input[0];
            var b = input[1];
            var m = input[2];
            var r0 = input[3];
            var used = new int[m];
            var r = r0;
            int i = 0;
            for (; i <= m; i++)
            {
                r = (a * r + b) % m;
                if (used[r] > 0)
                    break;
                used[r] = i+1;
            }
            Console.WriteLine(i + 1 - used[r]);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", Test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

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

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

        private static List<int> ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
            return input;
        }

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

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

        private static int ReadNextInt(string[] input, int index)
        {
            return Int32.Parse(input[index]);
        }

        #endregion
    }
}


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

namespace a2oj
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] part = s.Split('.');
            string[] dec = part[1].Split('e');

            int t = int.Parse(dec[1]);

            for (int i = 0; i < t; i++)
            {
                if (i < dec[0].Length)
                    part[0] += dec[0][i];
                else
                {
                    while(i<t)
                    {
                        part[0] += "0";
                        i++;
                    }
                    break;
                }

            }
            if(t<dec[0].Length)
                part[0]+='.';

            for (int i = t; i < dec[0].Length; i++)
			{
			    part[0] +=dec[0][i];
			}
            if(part[0].Contains('.'))
            {
                string[] str1 = part[0].Split('.');

                str1[0] = str1[0].TrimStart('0');
                str1[1] = str1[1].TrimEnd('0');
                if (str1[0] == "")
                    str1[0] = "0";
                if (str1[1] == "")
                    part[0] = str1[0];
                else
                    part[0] = str1[0] + "." + str1[1];

            }
            else
            {
                part[0] = part[0].TrimStart('0');
                if (part[0] == "")
                    part[0] = "0";
            }

            Console.WriteLine(part[0]);
                //Console.ReadKey();
        }
    }
}


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

namespace OLYMPH
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] number = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int sum = 0;

            if (number[1] / number[0] <= 8)
            {

                for (int i = 0; i < number[0]; i++)
                {
                    if (arr[i] > 8)
                    {
                        number[1] = number[1] - 8;
                        sum += arr[i] - 8;
                    }
                    else
                    {
                        arr[i] += sum;
                        sum = 0;
                        if (arr[i] > 8)
                        {
                            number[1] = number[1] - 8;
                            sum += arr[i] - 8;
                        }
                        else
                            number[1] = number[1] - arr[i];
                    }

                    if (number[1] <= 0)
                    {
                        Console.WriteLine(i + 1);
                        return;
                    }
                }
            }
            Console.WriteLine(-1);

            }

        }
}


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

public class CodeForces87
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = false;
#else
const bool testing = false;
#endif

    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 program(TextReader input)
     {
        //reader.ReadLine();
        //var data = reader.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();

        var n = long.Parse(reader.ReadLine());
        var ns = n.ToString();
        var result = int.MaxValue;
        for (var i = 0; i < Math.Pow(2, 10);i++){
            var s = Convert.ToString(i, 2).PadLeft(10).Substring(0, ns.Length);
            var news = new StringBuilder();
            for (var j = 0; j < s.Length;j++){
                if(s[j] == '1'){
                    news.Append(ns[j]);
                }
            }

            var res = news.ToString();
            if(res.Length > 0 && res[0] != '0'){
                var pos = int.Parse(res);
                if(Math.Sqrt(pos) % 1 == 0){
                    result = Math.Min(result, ns.Length - pos.ToString().Length);
                }
            }
        }
        Console.WriteLine(result == int.MaxValue ? -1 : result);
    }

    public static void Main(string[] args)
    {
        CultureInfo nonInvariantCulture = new CultureInfo("en-US");
        Thread.CurrentThread.CurrentCulture = nonInvariantCulture;
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("3\n2\n4\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("4 3\n2\n3\n4\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("13\n3\n8\n9\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("13 4\n10\n5\n4\n8\n"));
        Console.WriteLine();

    }
}


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

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }

    public int CompareTo(PairVariable other)
    {
        return other.a.CompareTo(this.a);
    }
}

namespace ConsoleApplication254
{

    class Program
    {

        static bool foo(string s1, string s2)
        {
            for (int i = 0; i < s1.Length; i++)
            {
                for (int e = 0; e < s2.Length; e++)
                {
                    if (s1[i] == s2[e])
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int l = 0;
            int r = 0;
            int f = 0;
            bool w = false;
            for (int i = 0; i < n; i++)
            {
                string[] q = Console.ReadLine().Split();
                if (int.Parse(q[0]) == int.Parse(q[1]))
                {
                    f++;
                }
                if ((int.Parse(q[0]) % 2 == 0 && int.Parse(q[1]) % 2 != 0) || (int.Parse(q[1]) % 2 == 0 && int.Parse(q[0]) % 2 != 0))
                {
                    w = true;
                }
                l += int.Parse(q[0]);
                r += int.Parse(q[1]);
            }
            if (l % 2 == 0 && r % 2 == 0)
            {
                Console.WriteLine(0);
            }
            else if (l % 2 != 0 && r % 2 != 0 && n!=1 && f!=n && w)
            {

                    Console.WriteLine(1);

            }
            else
            {
                Console.WriteLine(-1);
            }

        }
    }
}


using System;
using System.Text;

namespace A.Dubstep
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Replace("WUB", " ").Trim());
        }
    }
}


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

namespace Actual_Shit_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0, cntmax = 0, n;
            string text;
            n = int.Parse(Console.ReadLine());
            text = Console.ReadLine();
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == ' ')
                {
                    if (cnt > cntmax)
                        cntmax = cnt;
                    cnt = 0;
                }
                else if (text[i] >= 'A' && text[i] <= 'Z')
                    cnt++;
            }
            if (cnt > cntmax)
                cntmax = cnt;
            Console.WriteLine(cntmax);
        }
    }
}


using System;
class Ball{
    static long findNum(long[] c, long[] req){
        c[0] = c[0] - 2 * req[0];
        c[0] = c[0] - req[1];
        c[1] = c[1] - req[1];
        c[1] = c[1] - 3 * req[2];
        long sum = 0;
        for(int i=0;i<2;i++){
            if(c[i] < 0){
                sum = sum + Math.Abs(c[i]);
            }
        }
        return sum;
    }
    static void Main(string[] args){
        string[] str = Console.ReadLine().Trim().Split(' ');
        long[] c = Array.ConvertAll(str, Int64.Parse);
        str = Console.ReadLine().Trim().Split(' ');
        long[] req = Array.ConvertAll(str, Int64.Parse);
        Console.WriteLine(findNum(c, req));
    }
}


using System;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace ContestV
{
    internal class Program
    {

        private static void Main(string[] args)
        {

            var s = Console.ReadLine().Split(' ');

            int k1 = int.Parse(s[0]),
                k2 = int.Parse(s[1]),
                k3 = int.Parse(s[2]);
            string ans = "YES";
            var ss = Console.ReadLine().Split(' ');

            int m1 = int.Parse(ss[0]),
                m2 = int.Parse(ss[1]),
                m3 = int.Parse(ss[2]);

            int n = Convert.ToInt32(Console.ReadLine());

            int k = (k1 + k2 + k3)/5;
            if ((k1 + k2 + k3)%5 > 0) k++;

            int m = (m1 + m2 + m3)/10;
            if ((m1 + m2 + m3) % 10 > 0) m++;

            if (n < m + k) ans = "NO";

            Console.WriteLine(ans);

        }
    }
}


using System;

namespace wndkj
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string[] a = Console.ReadLine ().Split (' ');
			int b = int.Parse (a [0]);

			double c = double.Parse (a [1]);
			double d = double.Parse (a[2]);
			int e = int.Parse (a [3]);

			//Console.WriteLine(e);
			double q = (Math.Ceiling(c / d) * b) / e;
			Console.WriteLine(Math.Ceiling(q));
		}
	}
}


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

	class contest
	{

		static void Main(string[] args)
		{
		           var num = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            Array.Sort(num);
            long mxTable = num.Min() ;

            var cp = new long[3];
            num.CopyTo(cp, 0);
            long min = num.Min();
            long sum = num.Sum();

            num.CopyTo(cp, 0);

            if (cp[0] > 0 || cp[1] > 0)
            {
                long tmp = 0;

                while (cp[1] > 0 && cp[2] > 1)
                {
                    long red = 0;
                    //if(cp[0]>1) //(cp[0]>1 && cp[0]*2 >= cp[1])
                    //{
                    //     red = Math.Min(cp[1], Math.Min( cp[0]/2  , cp[2] / 2));

                    //}
                    //else red = Math.Min(cp[1],  cp[2] / 2);

                    if (cp[1] >= 4) red = cp[1] / 4;
                    else red = Math.Min(cp[1],cp[2]/2);

                    cp[1] -= red;
                    cp[2] -= red * 2;

                    tmp += red;
                    Array.Sort(cp);
                }

                if (cp[0] == 1 || cp[2]==3) tmp++;
                //if (sum % 2 == 1) tmp++;

                mxTable = Math.Max(mxTable, tmp);
            }

            Console.WriteLine(mxTable);

        }

	}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ok = false;
            List<string> inp = Console.ReadLine().Split(' ').ToList();
            for(int i = 0;i<inp.Count(); i++)
            {
                List<int> ind = new List<int>();
                ind.AddRange(new int[] { 0, 1, 2, 3 });
                ind.Remove(i);
                if (Int32.Parse(inp[i]) == Int32.Parse(inp[ind[0]]) + Int32.Parse(inp[ind[1]]) + Int32.Parse(inp[ind[2]]))
                {
                    ok = true;
                    break;
                }
            }

            for (int i = 0; i < inp.Count(); i++)
            {
                for (int j = 0; i < inp.Count(); i++)
                {
                    if (i == j)
                        continue;
                    List<int> ind = new List<int>();
                    ind.AddRange(new int[] { 0, 1, 2, 3 });
                    ind.Remove(i);
                    ind.Remove(j);
                    if (Int32.Parse(inp[i]) + Int32.Parse(inp[j]) ==  Int32.Parse(inp[ind[0]]) + Int32.Parse(inp[ind[1]]))
                    {
                        ok = true;
                        break;
                    }
                }
            }

            if (ok)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int64;
using N = System.Int64;
namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			//
			//dp[i,a,b] = i 回操作したあと、0 が来るべき箇所にある 1 の個数、1 が来るべき箇所にある 0 の個数
			//dp[i+1,a-1,b-1]+=dp[i,a,b]*a*b/n^2;
			//dp[i+1,a,b]+=dp[i,a,b]*(A*A+B*B + a*(B-b) + b*(A-a))/n^2
			//dp[i+1,a+1,b+1]+=dp[i,a,b]*(A-a)*(B-b)/n^2

			var n = ri; var k = ri;
			var A = Enumerate(n, x => ri);
			var K = n - A.Sum();
			var M = n - K;
			var B = Enumerate(n, x => x < K ? 0 : 1);
			var p = Enumerate(n, x => x).Count(x => A[x] != B[x]) / 2;
			var coef = ModInt.Inverse(n * (n - 1) / 2);
			var mat = new Matrix(n + 1, n + 1);
			//mat[i,j] = j->i
			for (int j = 0; j <= n; j++) {
				if (j != 0) mat[j - 1, j] += j * j * coef.num;
				mat[j, j] += (K * (K - 1) / 2 + M * (M - 1) / 2 + j * (M - j) + j * (K - j)) * coef.num;
				if (j != n) mat[j + 1, j] += (K - j) * (M - j) * coef.num;
			}
			for (int i = 0; i <= n; i++)
				for (int j = 0; j <= n; j++)
					mat[i, j] %= ModInt.Mod;
			var res = Matrix.Pow(mat, k);
			var vec = new Matrix(n + 1, 1); vec[p, 0] = 1;
			var ans = (res * vec)[0, 0];
			Console.WriteLine(ans);
		}
		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		//Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
		var solver = new Program.Solver();
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion

#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
	/// <summary>
	/// 剰余を取る値．
	/// </summary>
	public const long Mod = (int)1e9 + 7;

	/// <summary>
	/// 実際の数値．
	/// </summary>
	public long num;
	/// <summary>
	/// 値が <paramref name="n"/> であるようなインスタンスを構築します．
	/// </summary>
	/// <param name="n">インスタンスが持つ値</param>
	/// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
	public ModInt(long n) { num = n; }
	/// <summary>
	/// このインスタンスの数値を文字列に変換します．
	/// </summary>
	/// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
	public override string ToString() { return num.ToString(); }
	public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
	public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
	public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
	public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

	/// <summary>
	/// 与えられた 2 つの数値からべき剰余を計算します．
	/// </summary>
	/// <param name="v">べき乗の底</param>
	/// <param name="k">べき指数</param>
	/// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
	public static ModInt Pow(long v, long k) {
		long ret = 1;
		for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
			if ((k & 1) == 1) ret = ret * v % Mod;
		return new ModInt(ret);
	}
	/// <summary>
	/// 与えられた数の逆元を計算します．
	/// </summary>
	/// <param name="v">逆元を取る対象となる数</param>
	/// <returns>逆元となるような値</returns>
	/// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
	public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion

#region Matrix
public class Matrix {
	int row, col;
	public N[] mat;
	/// <summary>
	/// <paramref name="r"/> 行 <paramref name="c"/> 列目の要素へのアクセスを提供します。
	/// </summary>
	/// <param name="r">行の番号</param>
	/// <param name="c">列の番号</param>
	public N this[int r, int c] {
		get { return mat[r * col + c]; }
		set { mat[r * col + c] = value; }
	}
	public Matrix(int r, int c) {
		row = r; col = c;
		mat = new N[row * col];
	}
	public static Matrix operator *(Matrix l, Matrix r) {
		System.Diagnostics.Debug.Assert(l.col == r.row);
		var ret = new Matrix(l.row, r.col);
		for (int i = 0; i < l.row; i++)
			for (int k = 0; k < l.col; k++)
				for (int j = 0; j < r.col; j++)
					ret.mat[i * r.col + j] = (ret.mat[i * r.col + j] + l.mat[i * l.col + k] * r.mat[k * r.col + j]) % ModInt.Mod;
		return ret;
	}
	/// <summary>
	/// <paramref name="m"/>^<paramref name="n"/> を O(<paramref name="m"/>^3 log <paramref name="n"/>) で計算します。
	/// </summary>
	public static Matrix Pow(Matrix m, long n) {
		var ret = new Matrix(m.row, m.col);
		for (int i = 0; i < m.row; i++)
			ret.mat[i * m.col + i] = 1;
		for (; n > 0; m *= m, n >>= 1)
			if ((n & 1) == 1)
				ret = ret * m;
		return ret;

	}
	public N[][] Items {
		get {
			var a = new N[row][];
			for (int i = 0; i < row; i++) {
				a[i] = new N[col];
				for (int j = 0; j < col; j++)
					a[i][j] = mat[i * col + j];
			}
			return a;
		}
	}
}
#endregion


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        bool[] us = new bool[N+1];
        int[] perm = new int[N];
        int[] A = new int[M];
        for(int i=0;i<N;i++){
            perm[i] = -1;
        }
        for(int i=0;i<M;i++){
            A[i] = int.Parse(str[i])-1;
        }
        bool b = true;
        for(int i=0;i<M-1;i++){
            int s = A[i];
            int t = A[i+1];
            int d = s < t ? t - s : t - s + N;
            b &= perm[s] == d || (perm[s] == -1 && !us[d]);
            us[d] = true;
            perm[s] = d;
        }
        if(!b){
            sb.Append("-1\n");
        }
        else{
            int p = 1;
            for(int i=0;i<N;i++){
                if(perm[i] == -1){
                    while(us[p]){
                        p++;
                    }
                    perm[i] = p;
                    us[p] = true;
                }
                sb.Append(perm[i]);
                if(i != N-1){
                    sb.Append(" ");
                }
            }
            sb.Append("\n");
        }
    }
}


using System;

public class Solution
{
    static void Main(String[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        int[] d = new int[n];
        input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(input[i]);
        }
        int[] c = new int[n];
        for (int i = 0; i < n; i++)
        {
            if (d[i] == 2)
            {
                int j = n - i - 1;
                if (d[j] == 0)
                {
                    d[i] = 0;
                    c[i] = a;
                }
                else if (d[j] == 1)
                {
                    d[i] = 1;
                    c[i] = b;
                }
                else if (d[j] == 2)
                {
                    if (a > b)
                    {
                        d[i] = 1;
                        d[j] = 1;
                        c[i] = b;
                        c[j] = b;
                    }
                    else
                    {
                        d[i] = 0;
                        d[j] = 0;
                        c[i] = a;
                        c[j] = a;
                    }
                }
            }
            else if (d[i] == 1 && d[n - i - 1] == 0)
            {
                Console.WriteLine(-1);
                return;
            }
        }
        int cost = 0;
        for (int i = 0; i < n; i++)
        {
            cost += c[i];
        }
        Console.WriteLine(cost);
    }
}


using System;
namespace _954A
{
	class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			while (true)
			{
				int pos1 = s.IndexOf("UR");
				int pos2 = s.IndexOf("RU");
				if (pos1 == -1 && pos2 == -1)
					break;
				int pos;
				if (pos1 == -1)
					pos = pos2;
				else if (pos2 == -1)
					pos = pos1;
				else
					pos = Math.Min(pos1, pos2);
				s = s.Substring(0, pos) + "D" + s.Substring(pos + 2);
			}
			Console.WriteLine(s.Length);
		}
	}
}


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

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, x = int.Parse(Console.ReadLine());
            List<int> D = new List<int>();
            string W = Console.ReadLine();
            List<string> Words = new List<string>(W.Split(' '));
            foreach (string w in Words)
                if (w.Length > 0) D.Add(int.Parse(w));
            D.Sort();
            Console.Write(D[D.Count-1] + " ");
            for(i=1; i < D.Count-1; i++)
                Console.Write(D[i] + " ");
            Console.WriteLine(D[0]);

        }
    }
}


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

namespace Lazy_Security_Guard
{
    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();

            int min = int.MaxValue;
            for (int i = 1; i <= n; i++)
            {
                int k = (n + i - 1)/i;
                int p = 2*(i + k);
                min = Math.Min(min, p);
            }

            writer.WriteLine(min);
            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.Linq;
class Program
{
    static void Main(string[] args)
    {
        Problem1154C();
    }

    static void Problem1154C()
    {
        string s = Console.ReadLine();
        var arr = s.Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
        Console.WriteLine(Problem1154C(arr[0], arr[1], arr[2]));
    }
    static int Problem1154C(int a, int b, int c)
    {
        int[] result = new int[7];
        int commonWeeks = new[] { a / 3, b / 2, c / 2 }.Min() - 1;

        for (int i = 0; i < 7; i++)
        {
            result[i] = Problem1154C(i, a - 3 * commonWeeks, b - 2 * commonWeeks, c - 2 * commonWeeks);
        }
        return commonWeeks * 7 + result.Max();
    }
    static int Problem1154C(int i, int a, int b, int c)
    {
        int count = 0;
        for (int j = i; ; j++)
        {
            var r = Problem1154C(j, ref a, ref b, ref c, ref count);
            if (r == true)
                return count;
        }

        throw new Exception();
    }

    static bool Problem1154C(int i, ref int a, ref int b, ref int c, ref int count)
    {
        switch (i % 7 + 1)
        {
            case 1:
            case 4:
            case 7:
                if (a == 0)
                    return true;
                else
                {
                    a--;
                    count++;
                    return false;
                }
            case 2:
            case 6:
                if (b == 0)
                    return true;
                else
                {
                    b--;
                    count++;
                    return false;
                }
            case 3:
            case 5:
                if (c == 0)
                    return true;
                else
                {
                    c--;
                    count++;
                    return false;
                }
        }
        throw new Exception();
    }
}


// Submitted by Silithus @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace CodeForces
{
	class CF624A
	{
		public void Solve(XOI xoi)
		{
			int L, D, V1, V2;
			double ans;

			D = xoi.ReadInt();
			L = xoi.ReadInt();
			V1 = xoi.ReadInt();
			V2 = xoi.ReadInt();

			ans = (double)(L - D) / (double)(V1 + V2);

			xoi.o.WriteLine(ans.ToString("F6", System.Globalization.CultureInfo.InvariantCulture));
		}
	}

	class CodeForcesMain
	{
		static void Main(string[] args)
		{
			(new CF624A()).Solve(new XOI());
		}
	}
}

namespace CCF_XOI
{   // version 2014.06.20
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{   // I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;

            SortedSet<string> ss = new SortedSet<string>();

            for (int i = 0; i <= n; ++i)
            {
                for (char ch = 'a'; ch <= 'z'; ++ch)
                {
                    ss.Add(s.Insert(i, ch.ToString()));
                }

            }

            Console.WriteLine(ss.Count);
            Console.Read();
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    string[] days = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };

    public void Solve()
    {
        int a = Array.IndexOf(days, ReadToken());
        int b = Array.IndexOf(days, ReadToken());
        int x = (b - a + 7) % 7;
        Write(x == 0 || x == 2 || x == 3 ? "YES" : "NO");
    }

    #region Main

    protected static TextReader reader;
    protected 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("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        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)); }
    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
}


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

namespace MUH_and_Sticks
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
            Array.Sort(a);
            int count = 0;
            if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3])
            {
                if (a[4] == a[5])
                    Console.WriteLine("Elephant");
                else
                    Console.WriteLine("Bear");
            }
            else if (a[2] == a[3] && a[3] == a[4] && a[4] == a[5])
            {
                if ((a[0] == a[1]))
                    Console.WriteLine("Elephant");
                else
                    Console.WriteLine("Bear");
            }
            else
            {

                if(a[0] == a[1] && a[1] == a[2] && a[2] == a[3]|| a[1] == a[2] && a[2] == a[3] && a[3] == a[4]|| a[2] == a[3] && a[3] == a[4] && a[4] == a[5])
                    Console.WriteLine("Bear");
                else
                    Console.WriteLine("Alien");
            }
            Console.ReadLine();
        }
    }
}