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

namespace Tasks_010918
{
    public class Program
    {
        public static string LongStringChange (string s)
        {
            string s1 = "";
            if (s.Length < 10)
                Console.WriteLine(s);
            else
            {
                string b = s.Substring(1, s.Length - 2);
                int count = b.Length;

               s1 = string.Concat(s.Replace(b, Convert.ToString(count)));
                Console.WriteLine(s1);

            }
            return s1;
        }

        public static string StringChangedMethod (string x)
        {
            x = x.ToLower();
            string y = "AOEYUI".ToLower();

            int index = 0;
            for (int i = 0; i < x.Length; i++)
            {
                for (int j = 0; j < y.Length; j++)
                {
                    if (x[i] == y[j])
                    {
                        index = i;
                        x = x.Remove(index, 1);
                    }
                    index = 0;
                }
            }

            for (int i = 0; i < x.Length; i++)
            {
                if (i % 2 == 0)
                 x = x.Insert(i, Convert.ToString('.'));
            }

            return x;
        }

        static bool IsAllDigitsDifferent(int n)
        {
            string toString = n.ToString();  // 1988

            Dictionary<char, int> charsOccurence = new Dictionary<char, int>();
            foreach (char item in toString)
            {
                if (!charsOccurence.ContainsKey(item))
                {
                    charsOccurence[item] = 1;
                }
                else return false;
            }
            return true;
        }

        public static int GetNextDistinctInteger(int n)
        {
            for(int i = n + 1; i <= 9012; i++)
            {
                if (IsAllDigitsDifferent(i))
                {
                    return i;
                }
            }
            return 0;
        }

        static int BeatifullYearFunc (int n)
        {
            IList<int> y = new List<int>();
            for (int i = n + 1; i < 9000; i++)
            {
                string v = Convert.ToString(i);
                Dictionary<char, int> by = new Dictionary<char, int>();
                bool isTwiced = false;
                foreach(char x in v)
                {
                    if (!by.ContainsKey(x))
                    {
                        by[x] = 1;
                    }
                    else
                    {
                       by[x]++;
                    }
                    if (by[x] == 2)
                    {
                        isTwiced = true;
                        break;
                    }
                }

                if (isTwiced == false)
                {
                    n = Convert.ToInt32(y[i]);
                    Console.WriteLine(n);
                }

            }

            return n;
        }

        public static string ReturnStrMethod (string str, string subStr)
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (str.ToLower(). Contains(subStr.ToLower()))
                {
                    int n = str.IndexOf(subStr);
                    str = str.Replace(subStr, " ");
                }
            }

            return str;
        }

        public static int CountElephantSteps (int x)
        {
            int res = 0;
            if (x % 5 == 0)
            {
                res = x / 5;
                Console.WriteLine("Количество шагов = {0}", res);
            }
            else
            {
                if (x % 4 == 0)
                {
                    res = x / 4;
                    Console.WriteLine("Количество шагов = {0}", res);
                }
                else
                {

                    if (x % 3 == 0)
                    {
                        res = x / 3;
                        Console.WriteLine("Количество шагов = {0}", res);
                    }
                    else
                    {

                        if (x % 2 == 0)
                        {
                            res = x / 2;
                            Console.WriteLine("Количество шагов = {0}", res);
                        }
                        else
                        {

                            if (x % 1 == 0)
                            {
                                res = x / 1;
                                Console.WriteLine("Количество шагов = {0}", res);
                            }
                        }
                    }
                }
            }
            return res;
        }

        public static int CountResultFunc (int n, int[] points)
        {
            int countResult = 0;
            int max = points[0];
            int min = points[0];
            int indexMin = 0, indexMax = 0;

            for (int i = 0; i < points.Length; i++)
            {
                if (points[i] < min)
                {
                    min = points[i];
                    indexMin = i;
                    countResult++;
                }
                indexMin = 0;
            }
            Console.WriteLine("------------------");
            for (int i = 0; i < points.Length; i++)
            {
                if (points[i] > max)
                {
                    max = points[i];
                    indexMax = i;
                    countResult++;
                }
                indexMax = 0;
            }
            Console.WriteLine("Количество удивительных выступлений = {0}", countResult);
            return countResult;
        }

        static void Main(string[] args)
        {
            #region Taks 1
            //Console.WriteLine("Введите количество строк");
            //int n = Convert.ToInt32(Console.ReadLine());
            //string[] s = new string[n];

            //if (n > 0)
            //{
            //    for (int i = 0; i < n; i++)
            //    {
            //        Console.WriteLine("Введите слово");
            //        s[i] = Console.ReadLine();
            //    }

            //    foreach (string item in s)
            //    {
            //        LongStringChange(item);
            //    }

            //}
            #endregion

            #region Task 2
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();

            //Console.WriteLine(StringChangedMethod(str));

            #endregion

            #region Taks 3
            //Console.WriteLine("Введите количество строк");
            //int n = Convert.ToInt32(Console.ReadLine());
            //string[] num = new string[n];
            //int x = 0;

            //if (n > 0)
            //{
            //    for (int i = 0; i < n; i++)
            //    {
            //        Console.WriteLine("Введите операцию, которую надо выполнить");
            //        num[i] = Console.ReadLine();
            //    }

            //    foreach (string item in num)
            //    {
            //        if (item == "x++" || item == "++x")
            //            x++;
            //        else if (item == "x--" || item == "--x")
            //            x--;
            //    }

            //    Console.WriteLine(x);

            //}
            #endregion

            #region Task 4
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //StringBuilder sb = new StringBuilder(str);

            //for (int i = 0; i < sb.Length; i++)
            //{
            //    sb[0] = Char.ToUpper(sb[0]);
            //}

            //string newString = sb.ToString();
            //Console.WriteLine(newString);
            #endregion

            #region Task 5
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();

            //if (str.Length % 2 == 0)
            //    Console.WriteLine("Chat with her");
            //else
            //    Console.WriteLine("Ignore him");
            #endregion

            #region Task 6
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //StringBuilder sb = new StringBuilder(str);

            //for (int i = 0; i < sb.Length; i++)
            //{
            //    if (Char.IsLower(sb[0]) == true || Char.IsUpper(sb[i]) == true)
            //    {
            //        sb[0] = Char.ToUpper(sb[0]);
            //        sb[i] = Char.ToLower(sb[i]);
            //    }
            //    else
            //    {
            //        sb[i] = sb[i];
            //    }
            //}

            //string newString = sb.ToString();
            //Console.WriteLine(newString);
            #endregion

            #region Task 7
            //Console.WriteLine("Введите целое число");
            //int n = Convert.ToInt32(Console.ReadLine());

            //string s = n.ToString();
            //int count = 0;

            //for (int i = 0; i < s.Length; i++)
            //{
            //    if (s[i] == '4' || s[i] == '7')
            //    {
            //        count++;
            //    }
            //}

            //if (count == 4 || count == 7)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");
            #endregion

            #region Task 8
            //string s = "";
            //string t = "";

            //Console.WriteLine("Введите слово");
            //s = Console.ReadLine();
            //char[] reversed = s.Reverse().ToArray();
            //string str = new string(reversed);

            //Console.WriteLine("Введите слово");
            //t = Console.ReadLine();

            //if (String.Equals(str, t) == true)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");

            #endregion

            #region Task 9
            string input = Console.ReadLine();

            int n = Convert.ToInt32(input);

            int next = GetNextDistinctInteger(n);

            Console.WriteLine(next);
            Console.ReadLine();
            #endregion

            #region Task 10
            /*
            Console.WriteLine("Введите целое число");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(CountElephantSteps(x));
            */
            #endregion

            #region Task 11
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //string f = "WUB";
            //Console.WriteLine(ReturnStrMethod(str, f));
            #endregion

            #region Task 12
            //Console.WriteLine("Введите целое число");
            //int x = Convert.ToInt32(Console.ReadLine());
            //int[] points = new int[x];

            //for (int i = 0; i < x; i++)
            //{
            //    Console.WriteLine("Введите целое число");
            //    points[i] = Convert.ToInt32(Console.ReadLine());
            //}

            //Console.WriteLine("------------------");

            //for (int i = 0; i < points.Length; i++)
            //{
            //    Console.WriteLine(points[i]);
            //}

            //Console.WriteLine("------------------");
            //CountResultFunc(x, points);
            #endregion

            #region Task 13
            //Console.WriteLine("Введите строку");
            //string str = Console.ReadLine();
            //string s = "HQ9+";
            //int n = 0;

            //for (int i = 0; i < str.Length; i++)
            //{
            //    for (int j = 0; j < s.Length; j++)
            //    {
            //        if (str[i] == s[j])
            //            n = 1;
            //    }
            //}

            //if (n > 0)
            //{
            //    Console.WriteLine("YES");
            //} else { Console.WriteLine("NO"); }

            #endregion

            #region Task 14
            //Console.WriteLine("Введите число строк");
            //int n = Convert.ToInt32(Console.ReadLine());

            //Console.WriteLine("Введите число столбцов");
            //int m = Convert.ToInt32(Console.ReadLine());
            //char[,] y = new char[n, m];

            //char[] colors = { 'C', 'M', 'Y', 'W', 'G', 'B' };
            //int res = 0;

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        Console.WriteLine("введите любой символ из {0}", colors);
            //        y[i, j] = Convert.ToChar(Console.ReadLine());
            //        Console.WriteLine();
            //    }
            //}

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        Console.Write(y[i, j] + "\t");
            //    }
            //    Console.WriteLine();
            //}

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        for (int z = 0; z < colors.Length; z++)
            //        {
            //            if ((y[i, j].CompareTo('W') == 0 || y[i, j].CompareTo('B') == 0 || y[i, j].CompareTo('G') == 0) && (y[i, j].CompareTo('Y') == -1 || y[i, j].CompareTo('C') == -1 || y[i, j].CompareTo('M') == -1))
            //                res = 1;
            //            else
            //            {
            //                res = 0;
            //            }
            //        }
            //    }
            //}

            //if (res == 1)
            //    Console.WriteLine("#Black&White");
            //else { Console.WriteLine("#Color"); }

            #endregion

            Console.ReadLine();
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            //var n = Int64.Parse(Console.ReadLine());
            //var a = Array.ConvertAll(Console.ReadLine().Split(' '), Int64.Parse);
            var s = Console.ReadLine();
            var chs = 0;
            var qms = 0;
            var sns = 0;
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case '?':
                        qms++;
                        break;
                    case '*':
                        sns++;
                        break;
                    default:
                        chs++;
                        break;
                }
            }
            var k = Int32.Parse(Console.ReadLine());
            var possible = true;

            if (chs == k)
            {
                sns = 0;
                qms = 0;
            }
            else if (chs < k)
            {
                if (sns > 0)
                {
                    qms = 0;
                    sns = 1;
                }
                else
                {
                    possible = false;
                }
            }
            else //chs > k
            {
                if (chs - k <= sns + qms)
                {
                    qms = Math.Min(chs - k, qms);
                    sns = chs - k - qms;
                }
                else
                {
                    possible = false;
                }
            }

            var ans = new StringBuilder();

            if (possible)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '?' && qms > 0)
                    {
                        qms--;
                        ans.Remove(ans.Length - 1, 1);
                    }
                    else if (s[i] == '*' && sns > 0)
                    {
                        sns--;
                        if (chs < k)
                        {
                            for (int j = 0; j < k - chs; j++)
                            {
                                ans.Append(ans[ans.Length - 1]);
                            }
                        }
                        else
                        {
                            ans.Remove(ans.Length - 1, 1);
                        }
                    }
                    else if (s[i] != '?' && s[i] != '*')
                    {
                        ans.Append(s[i]);
                    }
                }
                for (int i = 0; i < ans.Length; i++)
                {
                    Console.Write(ans[i]);
                }
            }
            else
            {
                Console.WriteLine("Impossible");
            }

        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    static class _4032123
    {
        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);

        class Node
        {
            public int D { get; set; }
            public int F { get; set; }
            public int T { get; set; }
            public long C { get; set; }
        }
        static void Main(String[] args)
        {
            var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
            var bob = new long[n,2];
            bob[n - 1, 0] = data[n - 1];
            bob[n - 1, 1] = -data[n - 1];
            var prev = new int[n];
            prev[n - 1] = 1;
            for (var i = n - 2; i >= 0; i--)
            {
                if(bob[i + 1, 0] > bob[i + 1, 1])
                {
                    prev[i] = 0;
                } else
                {
                    prev[i] = 1;
                }
                bob[i, 0] = data[i] - Math.Max(bob[i + 1, 0],bob[i + 1, 1] );
                bob[i, 1] = Math.Max(bob[i + 1, 0], bob[i + 1, 1]) - data[i];
            }
            long bobSum = 0;
            var max = Math.Max(bob[0, 0], bob[0, 1]);
            writer.WriteLine((data.Sum()/2.0 - max/2.0) + " " + (data.Sum() / 2.0 + max / 2.0));
            writer.Flush();

        }
    }
}


using System;

namespace Task_41A
{
    class Program
    {
        /*
         * code
           edoc
         * */
        static void Main(string[] args)
        {
            //string s = Console.ReadLine();
            //string t = Console.ReadLine();
            //string rvc = ReverseString(s);

            //if (t == rvc)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int sLen = s.Length, tLen = t.Length;
            string ans = (sLen == tLen) ? "YES" : "NO";
            for (int i = 0, j = tLen - 1; i < sLen && j >= 0; i++, j--)
            {
                if (s[i] != t[j])
                {
                    ans = "NO";
                    break;

                }
            }
            Console.WriteLine(ans);

        }

        private static string ReverseString(string s)
        {
            string rvs = "";
            for (int i = s.Length - 1; i >= 0; i--)
            {
                rvs += s[i];
            }
            return rvs;

        }
    }
}


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)
        {
            int numb_balls = Convert.ToInt32(Console.ReadLine());

            int[] input = new int[numb_balls];

            string ins = Console.ReadLine();
            string[] inputs = ins.Split(' ');
            int[] numbers = new int[numb_balls];
            for (int i = 0; i < numb_balls; i++) {
                numbers[i] = Convert.ToInt32(inputs[i]);
            }

            bool good_set = false;

            int[] unique = numbers.Distinct().ToArray();
            Array.Sort(unique);

            numb_balls = unique.Length;

            for (int i = 0; i < numb_balls - 2; i++)
            {
                int first_ball = unique[i];
                int second_ball = unique[i + 1];
                int third_ball = unique[i + 2];
                if (Math.Abs(first_ball - second_ball) == 1 && Math.Abs(second_ball - third_ball) == 1)
                {
                    good_set = true;
                }
            }
            if (good_set)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


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

namespace Pr1
{
    class Program
    {
        static void Main()
        {
            long n=  Convert.ToInt64(Console.ReadLine());
            long k=n,j=0;
            long sum=0;
            while(k!=0)
            {
                k/=10;
                j++;
            }
            for(long i=j-1;i>0;i--)
            {
                k=(long)Math.Pow(10,i)-1;
                sum+=(n-k)*(i+1);
                n=k;
            }
            sum+=n;
            Console.Write(sum);
        }
    }
}


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

namespace c
{
    class Program
    {
        static long gcd(long x,long y)
        {
            return (y==0)?x:gcd(y,x%y);
        }

        static void Main(string[] args)
        {
            string[] token = Console.ReadLine().Split();
            long a = long.Parse(token[0]);
            long b = long.Parse(token[1]);
            long x = long.Parse(token[2]);
            long y = long.Parse(token[3]);
            long g = gcd(x, y);
            x /= g; y /= g;
            long max = Math.Min(a / x, b / y);
            Console.WriteLine("{0} {1}", max * x, max * y);
        }
    }
}


/*
csc -debug D.cs && mono --debug D.exe <<< "

{ max = 100, ops1 = 382, ops2 = 2182 }
{ max = 100 }
Total counts: 3913
Different GCDs: 382
Max number of divisors: 11 (60 72 84 90 96)

{ max = 1000, ops1 = 6069, ops2 = 61945 }
{ max = 1000 }
Total counts: 391617
Different GCDs: 6069
Max number of divisors: 31 (840)

{ max = 10000, ops1 = 83668, ops2 = 1326800 }
{ max = 10000 }
Total counts: 39205029
Different GCDs: 83668
Max number of divisors: 63 (7560 9240)

{ max = 100000, ops1 = 1066750, ops2 = 24091272 }
{ max = 100000 }
Total counts: 3920698493
Different GCDs: 1066750
Max number of divisors: 127 (83160 98280)
*/

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

public class HelloWorld {
    const ulong MOD = 1000000007ul;

    public static void SolveCodeForces() {
        // ShowStats();
        Solve();
    }

    static void Solve() {
        var max = cin.NextInt();

        var Divs = Helpers.CreateArray(max + 1, _ => new List<int>());
        for (var g = 2; g <= max; g++)
            for (var a = g; a <= max; a += g)
                Divs[a].Add(g);

        var Map = Helpers.CreateArray(max + 1, _ => new Dictionary<int, int>());
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            var divs = Divs[g];

            counter[g] = max / g;
            for (var i = divs.Count - 2; i >= 0; i--) {
                var sum = 0;
                for (var j = i + 1; j < divs.Count; j++)
                    if (divs[j] % divs[i] == 0)
                        sum += counter[divs[j]];
                counter[divs[i]] = max / divs[i] - sum;
            }
        }

// for (var g = 2; g <= max; g++) {
//     System.Console.WriteLine(new {g});
//     foreach (var kvp in Map[g])
//         System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
// }

        var maxU = (ulong)max;
        var anssum = 0ul;
        var F = new ulong[max + 1];
        for (var g = 2; g <= max; g++) {
            var ag = 0;
            var sum = 0ul;
            foreach (var kvp in Map[g]) {
                var gcd = kvp.Key;
                var count = kvp.Value;
                if (gcd == g)
                    ag = count;
                else
                    sum = (sum + F[gcd] * (ulong)count) % MOD;
            }
            F[g] = (maxU + sum) * ModInverse(maxU + MOD - (ulong)ag, MOD) % MOD;
            anssum = (anssum + F[g]) % MOD;

// System.Console.WriteLine(new { g, fg=F[g] });
        }

        var ans = (1ul + anssum * ModInverse(maxU, MOD)) % MOD;
        System.Console.WriteLine(ans);
    }

    public static ulong ModInverse(ulong x, ulong mod) { return ModPow(x, mod - 2L, mod); }

    public static ulong ModPow(ulong x, ulong exp, ulong mod) {
        ulong ret = 1ul;
        while (exp > 0) {
            if (exp % 2 == 1) ret = ret * x % mod;
            x = x * x % mod;
            exp /= 2;
        }
        return ret;
    }

    static void ShowStats() {
        foreach (var max in new[] { 100, 1000, 10000, 100000 }) {
            // var MapBrute = GetGcdsCounter_Brute(max);
            var Map = GetGcdsCounter_InnerLoop(max);
            System.Console.WriteLine(new { max });
            // Compare(Map, MapBrute);
            System.Console.WriteLine("Total counts: " + Map.Sum(c => (long)c.Dict.Values.Sum()));
            System.Console.WriteLine("Different GCDs: " + Map.Sum(c => c.Dict.Count));
            var maxcnt = Map.Max(c => c.Dict.Count);
            System.Console.WriteLine("Max number of divisors: {0} ({1})", maxcnt, Map.Select((c, i) => new { c, i }).Where(a => a.c.Dict.Count == maxcnt).Select(a => a.i).Join());
            System.Console.WriteLine();
        }
    }

    static Counter<int>[] GetGcdsCounter_InnerLoop(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());

        var ops1 = 0;
        for (var g = 2; g <= max; g++) {
            for (var a = g; a <= max; a += g) {
                Map[a][g] = 0;
                ops1++;
            }
        }

        var ops2 = 0;
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            counter[g] = max / g;

            var divs = counter.Dict.Keys.ToArray();
            Array.Sort(divs, 0, divs.Length);

            for (var i = divs.Length - 2; i >= 0; i--) {
                var cnt = max / divs[i];
                for (var j = i + 1; j < divs.Length; j++) {
                    if (divs[j] % divs[i] == 0)
                        cnt -= counter[divs[j]];
                }
                counter[divs[i]] = cnt;
            }

            ops2 += divs.Length * divs.Length;
        }

        if (max == 100) {
            for (var g = 1; g <= max; g++) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }

        System.Console.WriteLine(new {max, ops1, ops2});

        return Map;
    }

    static Counter<int>[] GetGcdsCounter_Brute(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());
        for (var g = 1; g <= max; g++) {
            for (var x = 1; x <= max; x++) {
                var gcd = (int)GCD((ulong)g, (ulong)x);
                if (gcd > 1)
                    Map[g][gcd]++;
            }
            if (max == 100) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }
        return Map;
    }

    private static ulong GCD(ulong a, ulong b) {
        while (a != 0 && b != 0) {
            if (a > b)
                a %= b;
            else
                b %= a;
        }
        return a == 0 ? b : a;
    }

    static void Compare(Counter<int>[] A, Counter<int>[] B) {
        for (var i = 0; i < A.Length; i++) {
            var C = A[i].Dict;
            var D = B[i].Dict;
            if (C.Count != D.Count) {
                System.Console.WriteLine(new { i, ccount = C.Count, dcount = D.Count });
                return;
            }
            if (!C.Keys.OrderBy(c => c).SequenceEqual(D.Keys.OrderBy(c => c))) {
                System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                return;
            }
            foreach (var key in C.Keys) {
                if (C[key] != D[key]) {
                    System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                    System.Console.WriteLine(new { key, cval=C[key], dval=D[key] });
                }
            }
        }
        System.Console.WriteLine("compare ok");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public class Counter<T> {
    public Dictionary<T, int> Dict;
    public Counter() { Dict = new Dictionary<T, int>(); }
    public Counter(IEnumerable<T> keys) { Dict = new Dictionary<T, int>(); foreach (var k in keys) Add(k, 1); }
    public int this[T key] {
        get { int res; return Dict.TryGetValue(key, out res) ? res : 0; }
        set { Dict[key] = value; }
    }
    public void Add(T key, int add) { int res; if (Dict.TryGetValue(key, out res)) Dict[key] = res + add; else Dict[key] = add; }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

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

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

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

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

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

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

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

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

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

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


using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;

namespace Program
{

    public class Solver
    {
        public void Solve()
        {
            var t = sc.Double();
            var s = sc.Double();
            var q = sc.Double();
            var add = 1.0 + (q - 1) / q;
            var cnt = 0;
            while (s < t)
            {
                s *= q;
                cnt++;
            }
            IO.Printer.Out.WriteLine(cnt);

        }
        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 < n; ++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(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    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 = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


using System;
using System.Collections.Generic;

namespace A_MikeAndPalindrome
{
	static class Program
	{
		public static string Reverse(this string str)
		{
			var charArray = str.ToCharArray();
			Array.Reverse(charArray);
			return new string(charArray);
		}

		/// <summary>
		/// Source string
		/// </summary>
		public static string s;

		/// <summary>
		/// Halfs of source string. Second part should be reversed
		/// </summary>
		public static List<string> halfs = new List<string>();

		/// <summary>
		/// Count of of diffs in halfs
		/// </summary>
		public static int diffs;

		/// <summary>
		/// Constraints:
		/// s - (1 ≤ |s| ≤ 15)
		/// </summary>
		/// <param name="args"></param>
		public static void Main(string[] args)
		{
			s = Console.ReadLine();
			var len = s.Length;

			if (s.Length % 2 == 1)
			{
				halfs.Add(s.Substring(0, (len - 1) / 2));
				halfs.Add(s.Substring((len - 1) / 2 + 1 > len ? (len - 1) / 2 : (len - 1) / 2 + 1, (len - 1)/2).Reverse());
			}
			else
			{
				halfs.Add(s.Substring(0, (len) / 2));
				halfs.Add(s.Substring(len / 2, len/2).Reverse());
			}

			for (var i = 0; i < halfs[0].Length; i++)
			{
				if (halfs[0][i] != halfs[1][i])
				{
					diffs++;
				}
			}

			Console.WriteLine(s.Length % 2 == 1 ? (diffs > 1 ? "NO" : "YES") : (diffs != 1 ? "NO" : "YES"));
		}
	}
}


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

namespace task
{
    class Program
    {
        private static string[] s;
        static void Main(string[] args)
        {
            s = new string[4];
            for (int i = 0; i < 4; ++i)
            {
                s[i] = Console.ReadLine();
            }
            bool ok = false;
            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 4; ++j)
                {
                    string t;
                    if (i + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j], s[i + 2][j]);
                        ok |= CheckString(t);
                    }
                    if (j + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i][j + 1], s[i][j + 2]);
                        ok |= CheckString(t);
                    }
                    if (i + 2 < 4 && j + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j + 1], s[i + 2][j + 2]);
                        ok |= CheckString(t);
                    }
                    if (i + 2 < 4 && j - 2 >= 0)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j - 1], s[i + 2][j - 2]);
                        ok |= CheckString(t);
                    }
                }
            }
            if (ok)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        private static bool CheckString(string t)
        {
            int cX = 0;
            int cP = 0;
            for (int i = 0; i < t.Length; ++i)
            {
                if (t[i] == 'x')
                    cX++;
                else if (t[i] == '.')
                    cP++;
            }
            return cX == 2 && cP == 1;
        }
    }

}


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

class Program
{

    void solve()
    {
        long l = nextInt();
        long r = nextInt();
        long p = 1;
        long res = 0;
        while (p < 1000000000000L)
        {
            p *= 10;
            long c = p - 1;
            long num;
            if (c / 2 > r)
                num = r;
            else if (c / 2 < l)
                num = l;
            else
                num = c / 2;
            if (num >= p / 10 && num < p)
                res = Math.Max(res, num * (c - num));
        }
        println(res);

    }
    long get(int x)
    {
        long y = 0;
        long p = 1;
        long temp = x;
        while (x > 0)
        {
            y += p * (9 - x % 10);
            x /= 10;
            p *= 10;
        }
        return temp * y;
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();
    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


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

namespace International_Olympiad
{
    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 = int.Parse(reader.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string s = reader.ReadLine().Substring(4);
                long t = long.Parse(s);

                long pow = 10, f = 0;

                for (int k = 1; k < s.Length; k++)
                {
                    f += pow;
                    pow *= 10;
                }

                while (t < 1989 + f)
                {
                    t += pow;
                }

                writer.WriteLine(t);
            }

            writer.Flush();
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using static System.Numerics.BigInteger;
using static Program.IO.Scanner;

using Number = System.Int64;
#region IO
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)) { }
	}
	static public class Scanner {
		public static StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
		public static int ri => sc.Integer();
		public static long rl => sc.Long();
		public static string rs => sc.Scan();
		public static double rd => sc.Double();
	}
	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 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();
		var t = new System.Threading.Thread(solver.Solve, 100000000);
		t.Start();
		t.Join();
		//*/
		//solver.Solve();
		Console.Out.Flush();
	}
}
#endregion

namespace Program {
	public class Solver {
		Random rnd = new Random(0);
		public void Solve() {
			var n = ri;
			var k = rl;
			if (k >= n) {
				Console.WriteLine(0);
				return;
			}
			solve(n, (int)k);
		}
		void solve(int n, int k) {
			var binom = new BinomialCoefficient(n + 50);
			if (k == 0) {
				Console.WriteLine(binom.fact[n]);
				return;
			}
			ModInt ans = 0;
			var m = n - k;
			for (int i = 1; i <= m; i++) {
				var v = binom[m, i];
				v *= ModInt.Pow(i, n);
				if ((m - i) % 2 == 1)
					ans -= v;
				else ans += v;
			}
			Debug.WriteLine(ans);
			ans *= binom[n, m];
			Debug.WriteLine(ans);
			ans *= 2;
			Console.WriteLine(ans);
		}
		static int[] dx = { -1, 0, 1, 0 };
		const long INF = 1L << 60;
		static int[] dy = { 0, 1, 0, -1 };
		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 T[][] Enumerate<T>(int n, int m, Func<int, int, T> f) {
			return Enumerate(n, x => Enumerate(m, y => f(x, y)));
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}
#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
	public const long Mod = 998244353;
	public long num;
	public ModInt(long n) { num = n; }
	public override string ToString() { return num.ToString(); }
	public static ModInt operator +(ModInt l, ModInt r) { return new ModInt(l.num + r.num < Mod ? l.num + r.num : l.num + r.num - Mod); }
	public static ModInt operator -(ModInt l, ModInt r) { return new ModInt(l.num + Mod - r.num < Mod ? l.num + Mod - r.num : l.num - r.num); }
	public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
	public static ModInt operator /(ModInt l, ModInt r) { return l * Inverse(r); }
	public static implicit operator ModInt(long n) { return new ModInt(n); }
	public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }
	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);
	}
	public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
	public static ModInt Modulo(long v) { return new ModInt(((v % Mod) + Mod) % Mod); }
}
#endregion

#region Binomial Coefficient
public class BinomialCoefficient {
	public ModInt[] fact, ifact;
	public BinomialCoefficient(int n) {
		fact = new ModInt[n + 1];
		ifact = new ModInt[n + 1];
		fact[0] = 1;
		for (int i = 1; i <= n; i++)
			fact[i] = fact[i - 1] * i;
		ifact[n] = ModInt.Inverse(fact[n]);
		for (int i = n - 1; i >= 0; i--)
			ifact[i] = ifact[i + 1] * (i + 1);
		ifact[0] = ifact[1];
	}
	public ModInt this[int n, int r] {
		get {
			if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
			return fact[n] * ifact[n - r] * ifact[r];
		}
	}
	public ModInt RepeatedCombination(int n, int k) {
		if (k == 0) return 1;
		return this[n + k - 1, k];
	}
}
#endregion


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            int tc = 1;
            tc = int.Parse(Console.ReadLine());
            while (tc-- > 0)
            {
                solve();
            }
        }

        // write your code in solve function
        static void solve()
        {
            int[] arr1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] arr2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (arr1[0] == 0 && arr1[1] == 0 && arr2[0] == 0 && arr2[1] == 0) {
                Console.WriteLine(0);
            } else if (arr1[0] == 1 && arr1[1] == 1 && arr2[0] == 1 && arr2[1] == 1) {
                Console.WriteLine(2);
            } else {
                Console.WriteLine(1);
            }
        }
    }
}


using System;

namespace Round144ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = long.Parse(Console.ReadLine());

            long start = (long)Math.Sqrt(input) - 81;
            if (start < 1)
                start = 1;

            for (long i = start; i <= start + 162; i++)
            {
                long sum = GetSumOfDigits(i);
                if (i * (i + sum) == input)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine("-1");
        }

        static long GetSumOfDigits(long n)
        {
            long sum = 0;
            while (n != 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
    }
}


using System;
class Program
{
    public static int[] dI = { -1, 1, 0, 0 };
    public static int[] dJ = { 0, 0, 1, -1 };
    public static char[][] grid = new char[4][];
    public static bool valid(int i, int j) { return i >= 0 && j >= 0 && i < 4 && j < 4; }
    public static bool DFS ()
    {
        for (int i = 0; i < 4; i++)
        {

            for (int j = 0; j < 4; j++)
            {
                int toRI = i + dI[2];
                int toRJ = j + dJ[2];
                int toLI = i + dI[3];
                int toLJ = j + dJ[3];
                for (int k = 0; k < 2; k++)
                {
                    int toI = i + dI[k];
                    int toJ = j + dJ[k];
                    if (valid(toI, toJ) && grid[toI][toJ] == grid[i][j] && ((valid(toRI, toRJ) && grid[toRI][toRJ] == grid[i][j]) || (valid(toLI, toLJ) && grid[toLI][toLJ] == grid[i][j])))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static void Main()
    {
        for (int i = 0; i < 4; i++)
        {
            grid[i] = Console.ReadLine().ToCharArray();

        }
        Console.WriteLine(DFS() ? "YES" : "NO");
    }
}


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

public class Program
{
    public void Solve() {
        int n = ReadInt();
        int p = ReadInt();
        int k = ReadInt();
        List < object > pr = new List < object >();
        if (p - k > 1) {
            pr.Add("<<");
        }
        for (int i = Math.Max(p - k , 1); i < p; i++) {
            pr.Add(i);
        }
        pr.Add("(" + p.ToString() + ")");
        for (int i = p + 1; i <= p + k && i <= n; i++) {
            pr.Add(i);
        }
        if (p + k < n) {
            pr.Add(">>");
        }
        Write(pr.ToArray());
    }
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        // reader = new StreamReader("in.txt");
        // writer = Console.Out;
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        try
        {
            new Program().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            throw;
        }
        reader.Close();
        writer.Close();
    }
    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; }
}


using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
namespace Rextester{
    public class Program{

        public static StreamWriter writer;
        private static Stream readStream;
        private static int idx, bufferSize, bytesRead;
        private static byte[] buffer;
        public const char Space = ' ';     // 32
        public const char MinusSign = '-'; // 45
        public const char Zero = '0';      // 48
        public const char HorizontalTab = '\t';  //  9
        public const char VerticalTab = '\v';    // 11
        public const char FormFeed = '\f';       // 12
        public const char CarriageReturn = '\r'; // 13
        public const char LineFeed = '\n';       // 10

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Initialze(){
            readStream = Console.OpenStandardInput();
            //readStream = File.OpenRead(@"input.txt");
            idx = bytesRead = 0;
            bufferSize = 1 << 14;
            buffer = new byte[bufferSize];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static void ReadConsoleInput(){
            idx = 0;
            bytesRead = readStream.Read(buffer, 0, bufferSize);
            if (bytesRead <= 0) buffer[0] = (byte)Space;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static byte ReadByte() {
            if (idx == bytesRead)
                ReadConsoleInput();
            return buffer[idx++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int ReadInt(){
            byte readByte;
            do{
                readByte = ReadByte();
            }
            while (readByte < MinusSign);

            bool negative = false;
            if (readByte == MinusSign){
                negative = true;
                readByte = ReadByte();
            }
            int m = readByte - Zero;
            while (true){
                readByte = ReadByte();
                if (readByte < Zero) break;
                m = m * 10 + (readByte - Zero);
            }
            if (negative) return -m;
            return m;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StringBuilder ReadLine(){
            byte readByte;
            StringBuilder s = new StringBuilder();
            do{
                readByte = ReadByte();
            }
            while (readByte <= CarriageReturn);
            idx--;
            while (true){
                readByte = ReadByte();
                if (readByte < CarriageReturn) break;
                s = s.Append((char)readByte);
            }
            return s;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Dispose(){
            readStream.Close();
            writer.Close();
        }
        public static int Gcd(int a, int b) {
            while (b!=0){
                int temp=b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void RealWork(){
            int a = ReadInt();
            int b = ReadInt();
            int h = ReadInt();
            int move=0;
            while(h!=0){
                if (move % 2 == 0){
                    h = h - Gcd(h, a);
                    move++;
                    if (h == 0)
                        move = 0;
                }
                else{
                    h = h - Gcd(h, b);
                    move++;
                    if (h == 0)
                        move = 1;
                }
            }

            writer.Write(move);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void Main(string[] args){

            //writer = new StreamWriter("output.txt");
            Initialze();
            writer = new StreamWriter(Console.OpenStandardOutput());

            RealWork();
            Dispose();
        }
    }
}


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

namespace A.Bear_and_Big_Brother
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = arr[0];
            int y = arr[1];
            int sum = 0;
            while(true)
            {
                if(x>y)
                {
                    break;
                }

                x *= 3;
                y *= 2;
                sum++;
            }
            Console.WriteLine(sum);
        }
    }
}


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
{
    long Fun(long a, long b, long x)
    {
        if (b > x)
            return 0;
        return (x - b) / a + 1;
    }

    long Fun(long a, long b, long l, long r)
    {
        return Fun(a, b, r) - Fun(a, b, l - 1);
    }

    long Gcd(long a, long b, out long x, out long y)
    {
        if (a == 0)
        {
            x = 0;
            y = 1;
            return b;
        }
	    long x1, y1;
	    long d = Gcd(b % a, a, out x1, out y1);
	    x = y1 - (b / a) * x1;
	    y = x1;
	    return d;
    }

    bool Dio(long a, long b, long c, out long x0, out long y0, out long g)
    {
	    g = Gcd(Math.Abs(a), Math.Abs(b), out x0, out y0);
	    if (c % g != 0)
		    return false;
	    x0 *= c / g;
	    y0 *= c / g;
	    if (a < 0)
            x0 *= -1;
	    if (b < 0)
            y0 *= -1;
	    return true;
    }

    public void Solve()
    {
        long a1 = ReadInt();
        long b1 = ReadInt();
        long a2 = ReadInt();
        long b2 = ReadInt();
        long l = ReadInt();
        long r = ReadInt();

        if (a1 == a2)
        {
            if (Math.Abs(b1 - b2) % a1 != 0)
                Write(0);
            else
                Write(Fun(a1, Math.Max(b1, b2), l, r));
            return;
        }

        long x0, y0, g;
        if (!Dio(a1, -a2, b2 - b1, out x0, out y0, out g))
        {
            Write(0);
            return;
        }

        long d1 = a2 / g;
        long d2 = a1 / g;
        if (x0 < 0)
        {
            long z = ((-x0 - 1) / d1 + 1);
            x0 += z * d1;
            y0 += z * d2;
        }
        if (y0 < 0)
        {
            long z = ((-y0 - 1) / d2 + 1);
            x0 += z * d1;
            y0 += z * d2;
        }

        long t = Math.Min(x0 / d1, y0 / d2);
        x0 -= t * d1;
        y0 -= t * d2;
        Write(Fun(d1 * a1, a1 * x0 + b1, l, r));
    }

    #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 _635A
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = s[0]; var c = s[1]; var n = s[2]; var k = s[3];
            int[,] orchestra = new int[r, c];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                orchestra[line[0]-1, line[1]-1]++;
            }
            int ans = 0;

            for (int i = 0; i < r; i++)
                for (int j = 0; j < c; j++)
                    for (int p = i; p < r; p++)
                        for (int q = j; q < c; q++)
                        {
                            int sum = 0;
                            for (int a = i; a < r; a++)
                                for (int b = j; b < c; b++)
                                {
                                    if (a >= i && a <= p && b >= j && b <= q) sum+=orchestra[a,b];
                                }
                            if (sum >= k) ans++;
                        }
            Console.WriteLine(ans);
        }
    }
}


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

namespace ConsoleApplication1
{
    //1 +
    //2 +
    //3 +
    //4
    class Program
    {
        static public String switcher(char x)
        {
            String s;
            switch (x)
            {
                case '0':
                    s = "O-|-OOOO";
                    break;
                case '1':
                    s = "O-|O-OOO";
                    break;
                case '2':
                    s = "O-|OO-OO";
                    break;
                case '3':
                    s = "O-|OOO-O";
                    break;
                case '4':
                    s = "O-|OOOO-";
                    break;
                case '5':
                    s = "-O|-OOOO";
                    break;
                case '6':
                    s = "-O|O-OOO";
                    break;
                case '7':
                    s = "-O|OO-OO";
                    break;
                case '8':
                    s = "-O|OOO-O";
                    break;
                case '9':
                    s = "-O|OOOO-";
                    break;
                default:
                    s = "null";
                    break;
            }
            return s;
        }

        static void Main(string[] args)
        {
            String n = Console.ReadLine();
            for (int i = n.Length - 1; i >= 0; i--)
            {
                Console.WriteLine(switcher(n[i]));
            }
        }
    }
}


using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using Number = System.Int32;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var mod = sc.Long();
            var sum = 0L;
            var set = new SortedDictionary<long, BigInteger>() { { 0, 0 } };
            for (int i = 1; i <= 100000; i++)
            {
                sum = (sum + i.ToString().Sum(x => x - '0')) % mod;

                BigInteger l;
                if (set.TryGetValue(sum, out l))
                {
                    IO.Printer.Out.WriteLine("{0} {1}", l + 1, i);
                    return;
                }
                set.Add(sum, i);
                //var v = func(i.ToString(), long.MaxValue);
            }
            {
                BigInteger l = 0, r = (BigInteger)1e18;
                for (int i = 0; i < 100; i++)
                {
                    var m = (l + r) / 2;
                    var v = func(m.ToString());
                    if (v < mod) l = m;
                    else r = m;
                }
                for (int _ = 0; _ < 10000; _++)
                {

                    var v = (long)(func(l.ToString()) % mod);
                    Debug.WriteLine(v);
                    BigInteger u;
                    if (set.TryGetValue(v, out u))
                    {
                        var min = BigInteger.Min(u, l) + 1;
                        var max = BigInteger.Max(u, l);
                        IO.Printer.Out.WriteLine("{0} {1}", min, max);
                        return;
                    }
                    set.Add(v, l);
                    l++;
                }
            }
        }
        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 < n; ++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; }
        static BigInteger func(string str)
        {
            var len = str.Length;
            BigInteger ans = 0L;
            BigInteger sum = 0;
            var ten = new BigInteger[len + 1];
            ten[0] = 1;
            for (int i = 1; i < len; i++)
                ten[i] = (ten[i - 1] * 10);
            for (int i = 0; i < len; i++)
            {
                var v = 0L;
                for (int j = i + 1; j < len; j++)
                    v = (v * 10 + str[j] - '0');
                v = (v + 1);

                for (int k = 1; k < 10; k++)
                {
                    if (str[i] - '0' == k)
                    {
                        ans = (ans + k * v);
                    }
                    else if (str[i] - '0' > k)
                    {
                        ans = (ans + k * ten[len - i - 1]);
                    }
                    ans = (ans + sum * k * ten[len - i - 1]);
                }
                sum = (sum * 10 + str[i] - '0');
            }
            return ans;
        }

    }
}
#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    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 = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


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

namespace prD {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif
        static int IsWeCan(int[,] p1, int[,] p2, int n, int m) {
            int[] ddd = new int[10];
            int result = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int[] d = new int[10];
                    int a1 = p1[i, 0];
                    int b1 = p1[i, 1];
                    int a2 = p2[j, 0];
                    int b2 = p2[j, 1];
                    if (a1 == a2) d[a1]++;
                    if (a1 == b2) d[a1]++;
                    if (b1 == a2) d[b1]++;
                    if (b1 == b2) d[b1]++;
                    int s = 0;
                    for (int q = 0; q < 10; q++) {
                        s += d[q];
                    }
                    bool normalPair = s == 1;
                    if (!normalPair)
                        continue;
                    for (int q = 0; q < 10; q++) {
                        if (d[q] > 0)
                            ddd[q] = 1;
                    }
                }
            }
            for (int i = 0; i < 10; i++) {
                result += ddd[i];
            }
            if (result == 1) {
                for (int i = 0; i < 10; i++) {
                    if (ddd[i] == 1)
                        return i;
                }
                throw new Exception();
            }
            else {
                return -1;
            }
        }

        static bool TheyCan(int[,] p1, int[,] p2, int n, int m) {
            bool ans = true;
            for (int i = 0; i < n; i++) {
                int a1 = p1[i, 0];
                int b1 = p1[i, 1];
                int result = 0;
                int[] ddd = new int[10];
                for (int j = 0; j < m; j++) {
                    int[] d = new int[10];
                    int a2 = p2[j, 0];
                    int b2 = p2[j, 1];
                    if(a1 == a2)
                        d[a1] = 1;
                    if(a1 == b2)
                        d[a1] = 1;
                    if(b1 == a2)
                        d[b1] = 1;
                    if(b1 == b2)
                        d[b1] = 1;
                    int s = 0;
                    for(int q = 0; q < 10; q++) {
                        s += d[q];
                    }
                    bool normalPair = s == 1;
                    if (!normalPair)
                        continue;
                    for(int q = 0; q < 10; q++) {
                        if(d[q] > 0)
                            ddd[q] = 1;
                    }
                }
                for(int j = 0; j < 10; j++) {
                    result += ddd[j];
                }
                ans = ans && (result == 1 || result == 0);
            }
            return ans;
        }

        static void Main(string[] args) {
            int n = Next();
            int m = Next();
            int[,] p1 = new int[n,2];
            for (int i = 0; i < n; i++) {
                p1[i, 0] = Next();
                p1[i, 1] = Next();
            }
            int[,] p2 = new int[m, 2];
            for(int i = 0; i < m; i++) {
                p2[i, 0] = Next();
                p2[i, 1] = Next();
            }
            int weCan = IsWeCan(p1, p2, n, m);
            bool theyCan1 = TheyCan(p1, p2, n, m);
            bool theyCan2 = TheyCan(p2, p1, m, n);
            if (weCan != -1) {
                writer.Write(weCan);
            } else if (theyCan1 && theyCan2) {
                writer.Write('0');
            }
            else writer.Write("-1");

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


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

namespace Task
{

    #region MyIo

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

        private string[] tokens;
        private int pointer;

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

        }

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

        public char NextChar()
        {
            try
            {
                return (char)inputStream.Read();
            }
            catch (IOException)
            {
                return '\0';
            }
        }

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

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

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

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

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            T res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

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

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

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

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "yes" : "no");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

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

        void IDisposable.Dispose()
        {
            Close();

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

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

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

            var n = self.Count;

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

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval();

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

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

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

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

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

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

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

                    return tr;
                }
            }
        }

        public P()
        {
        }

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

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

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

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

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

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

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

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

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

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

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

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

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

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

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

        #endregion

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

        private void Solve()
        {
            var n = io.NextLong();

            var x = io.NextLong();
            var y = io.NextLong();

            var c = io.NextLong();

            long s = 0;

            if (c > 1)
            {

                var ub = (long)Math.Sqrt(1+8*c);
                var lb = Math.Max(ub / 4L - 1L, 0L);

                s = ub;

                do
                {

                    var m = (ub + lb) >> 1;

                    var cn = Calc(n, x, y, m);

                    if (cn >= c)
                    {
                        ub--;
                        s = Math.Min(m, s);
                    }
                    else if (cn < c)
                    {
                        lb++;
                    }

                } while (ub > lb);

            }

            io.Print(s);
        }

        private long Pos0(long x)
        {
            return x > 0 ? x : 0;
        }

        private long Pow2(long x)
        {

            return x*x;
        }

        private long Pow2120(long x)
        {
            x = Pos0(x);

            return x * (x + 1L) / 2;
        }

        private long Calc(long n, long x, long y, long s)
        {

            if (s == 0)
                return 1;

            var r = Pos0(s + y - n);
            var b = Pos0(s + x - n);

            var l = Pos0(1 - y + s);
            var t = Pos0(1 - x + s);

            var ix = 1 + n - x;
            var iy = 1 + n - y;

            var bse = s*s + (s + 1)*(s + 1) - Pow2(r) - Pow2(t) - Pow2(b) - Pow2(l);

            bse += Pow2120(l - x);
            bse += Pow2120(r - x);

            bse += Pow2120(l - ix);
            bse += Pow2120(r - ix);

            return bse;
        }
    }

}


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

namespace Cubical_Planet
{
    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 x1 = Next(), y1 = Next(), z1 = Next();
            int x2 = Next(), y2 = Next(), z2 = Next();

            writer.WriteLine(x1 == x2 || y1 == y2 || z1 == z2 ? "YES" : "NO");
            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';
            }
        }
    }
}