using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((B - A) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l <= 0) l += K;
        for (int i = 0; i < 2 * N; i++)
        {
            // Console.WriteLine(l);
            var gcd = MathEx.GCD(N * K, l);
            Min = Math.Min(Min, N * K / gcd);
            Max = Math.Max(Max, N * K / gcd);
            l += K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((-A + B) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l <= 0) l += K;
        for (int i = 0; i <= N; i++)
        {
            if (l != 0)
            {
                // Console.WriteLine(l);
                var gcd = MathEx.GCD(N * K, l);
                Min = Math.Min(Min, N * K / gcd);
                Max = Math.Max(Max, N * K / gcd);
            }

            l += K;
            l %= N * K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((-A + B) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l <= 0) l += K;
        for (int i = 0; i <= N; i++)
        {
            // Console.WriteLine(l);
            var gcd = MathEx.GCD(N * K, l);
            Min = Math.Min(Min, N * K / gcd);
            Max = Math.Max(Max, N * K / gcd);

            l += K;
            l %= N * K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Solution
{
    static void Main(string[] args)
    {
           var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);
        long n = arr[0];
        long k = arr[1];
        arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);
        long s1 = arr[0];
        long s2 = arr[1];

        long d1 = s2 -s1 ;
        d1 = d1>0?d1:d1+k;
        long d2 = k - s2 - s1;
        d2 = d2>0?d2:d2+k;

        long d3 = s1-s2;
        d3 = d3>0?d3:d3+k;
        long d4 = s2+s1;
        d4 = d4>0?d4:d4+k;

        var minGcd = long.MaxValue;
        var maxGcd = long.MinValue;
        for(int i =0; i<n;i++)
        {
            minGcd = Math.Min(GCD.Euclidean(n*k, d1+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d2+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d3+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d4+i*k), minGcd );

            maxGcd = Math.Max(GCD.Euclidean(n*k, d1+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d2+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d3+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d4+i*k), maxGcd );
        }
        Console.Write((n*k) / maxGcd);
        Console.Write(" ");
        Console.WriteLine((n*k) / minGcd);

    }

      public class GCD
    {
		public static long Euclidean(long n1, long n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}
	}

}


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

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

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var n = cin.NextUlong();
        var k = cin.NextUlong();
        var a = cin.NextUlong();
        var b = cin.NextUlong();

        var mod = n * k;
        var S = new ulong[] { a % mod, (mod - a) % mod }.Distinct().ToArray();

        var SL = new HashSet<ulong>();
        for (var i = 0ul; i <= n-1; i++) {
            SL.Add( (i * k +       b) % mod );
            SL.Add( (i * k + mod - b) % mod );
        }

// System.Console.WriteLine(new {S=string.Join(" ", S)});
// System.Console.WriteLine(new {SL=string.Join(" ", SL)});

        var min = ulong.MaxValue;
        var max = 0ul;
        foreach (var s in S)
            foreach (var sl in SL) {
                var l = (sl + mod - s) % mod;

                var cnt = mod / GCD(mod, l);

                min = Math.Min(min, cnt);
                max = Math.Max(max, cnt);
            }

        System.Console.WriteLine("{0} {1}", min, max);
    }

    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 Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

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

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

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

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

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

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

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

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

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

    public int[] IntArray(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.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    Scanner sc = new Scanner();
    //

    public void Solve()
    {
        long n, k, a, b;
        sc.Make(out n, out k, out a, out b);
        long min = long.MaxValue, max = long.MinValue;
        for(var i = 0; i <= n; i++)
        {
            long l = i * k + b, r = i * k + k - b;
            if (l == a) goto S;
            var p = n * k / GCD(n * k, Abs(l - a));
            chmin(ref min, p);chmax(ref max, p);
        S:;
            if (r == a) continue;
            var q = n * k / GCD(n * k, Abs(r - a));
            chmax(ref max, q);chmin(ref min, q);
        }
        WriteLine($"{min} {max}");
    }
    #region GCD
    public static int LCM(int num1, int num2)
        => num1 / GCD(num1, num2) * num2;

    public static long LCM(long num1, long num2)
        => num1 / GCD(num1, num2) * num2;

    public static int GCD(int num1, int num2)
        => num1 < num2 ? GCD(num2, num1) :
           num2 > 0 ? GCD(num2, num1 % num2) : num1;

    public static long GCD(long num1, long num2)
        => num1 < num2 ? GCD(num2, num1) :
           num2 > 0 ? GCD(num2, num1 % num2) : num1;
    #endregion
}

#region Template
public class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

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

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

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

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


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long K = long.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		long A = long.Parse(str2[0]);
		long B = long.Parse(str2[1]);
		long min = 999999999999999;
		long max = 0;
		for(var i=0;i<N;i++){
			long a1 = Math.Abs(i*K+B - A);
			if(a1==0){
				min = 1;
			} else {
				min = Math.Min(min,N*K/Gcd(a1,N*K));
			}
			max = Math.Max(max,N*K/Gcd(a1,N*K));
			long a2 = Math.Abs(i*K+B + A);
			min = Math.Min(min,N*K/Gcd(a2,N*K));
			max = Math.Max(max,N*K/Gcd(a2,N*K));
		}
		Console.WriteLine(min+" "+max);
	}
	public static long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }

	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((-A + B) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l % K <= 0) l += K;
        for (int i = 0; i < 100000; i++)
        {
            // Console.WriteLine(l);
            var gcd = MathEx.GCD(N * K, l);
            Min = Math.Min(Min, N * K / gcd);
            Max = Math.Max(Max, N * K / gcd);
            l += K;
            l %= N + K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((-A + B) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l <= 0) l += K;
        for (int i = 0; i < 1000000; i++)
        {
            // Console.WriteLine(l);
            var gcd = MathEx.GCD(N * K, l);
            Min = Math.Min(Min, N * K / gcd);
            Max = Math.Max(Max, N * K / gcd);
            l += K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private long N, K, A, B;
    private long Min, Max;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        A = sc.NextInt();
        B = sc.NextInt();

        /*
         * n*k都市 1ごとに円周上
         *
         * n軒 kごとにファストフード店
         *
         * sからlkmごとの都市にsに戻るまで行く
         *
         * sから最寄りのファストフード店までa
         * s+lからb
         *
         * 通った都市の最大、最小
         */
        Min = int.MaxValue;
        Max = int.MinValue;
        F((A + B) % K);
        F((A - B) % K);
        F((-A + B) % K);
        F((-A - B) % K);
        /*
         * a,bも右
         * s % k = a
         * (s + l) % k = b
         *
         * (b - a)%k = l % k
         *
         *
         */

        Console.WriteLine($"{Min} {Max}");
    }

    void F(long l)
    {
        while (l <= 0) l += K;
        for (int i = 0; i < 10000000; i++)
        {
            // Console.WriteLine(l);
            var gcd = MathEx.GCD(N * K, l);
            Min = Math.Min(Min, N * K / gcd);
            Max = Math.Max(Max, N * K / gcd);
            l += K;
        }
    }

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

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    using System;
    using System.Collections.Generic;

    #region GCD LCM

    /// <summary>
    /// 様々な数学的関数の静的メソッドを提供します．
    /// </summary>
    public static partial class MathEx
    {
        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static int GCD(int n, int m)
        {
            return (int) GCD((long) n, m);
        }

        /// <summary>
        /// 2 つの整数の最大公約数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最大公約数</returns>
        /// <remarks>ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます．</remarks>
        public static long GCD(long n, long m)
        {
            n = Math.Abs(n);
            m = Math.Abs(m);
            while (n != 0)
            {
                m %= n;
                if (m == 0) return n;
                n %= m;
            }

            return m;
        }

        /// <summary>
        /// 2 つの整数の最小公倍数を求めます．
        /// </summary>
        /// <param name="n">最初の値</param>
        /// <param name="m">2 番目の値</param>
        /// <returns>2 つの整数の最小公倍数</returns>
        /// <remarks>最悪計算量 O(log N) で実行されます．</remarks>
        public static long LCM(long n, long m)
        {
            return (n / GCD(n, m)) * m;
        }
    }

    #endregion

    #region PrimeSieve

    public static partial class MathEx
    {
        /// <summary>
        /// ある値までに素数表を構築します．
        /// </summary>
        /// <param name="max">最大の値</param>
        /// <param name="primes">素数のみを入れた数列が返される</param>
        /// <returns>0 から max までの素数表</returns>
        /// <remarks>エラトステネスの篩に基づき，最悪計算量 O(N loglog N) で実行されます．</remarks>
        public static bool[] Sieve(int max, List<int> primes = null)
        {
            var isPrime = new bool[max + 1];
            for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
            for (int i = 2; i * i <= max; i++)
                if (!isPrime[i]) continue;
                else
                    for (int j = i * i; j <= max; j += i)
                        isPrime[j] = false;
            if (primes != null)
                for (int i = 0; i <= max; i++)
                    if (isPrime[i])
                        primes.Add(i);

            return isPrime;
        }
    }

    #endregion
}

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

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

            var nn = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                nn.Add(Next());
            }

            for (int i = n; i > 0; i--)
            {
                for (int j = 1; j < nn.Count; j++)
                {
                    if (Math.Abs(nn[j] - nn[j - 1]) >= 2)
                        return false;
                }

                int m = 0;
                for (int j = 1; j < nn.Count; j++)
                {
                    if (nn[m] > nn[j])
                        m = j;
                }

                nn.RemoveAt(m);
            }

            return true;
        }

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


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        var a = ReadIntArray();

        for (int i = 0; i + 1 < n; i++)
            if (Math.Abs(a[i] - a[i + 1]) > 1)
            {
                Write("NO");
                return;
            }

        Write("YES");
    }

    #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("stations.in");
        //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 ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = Convert.ToInt32(Console.ReadLine());
            int[] mass = new int[i];
            string[] q = Console.ReadLine().Split(' ');
            bool flag = true;

            for (int j = 0; j < i; j++)
            {
                mass[j] = Convert.ToInt32(q[j]);
            }

            for (int j = 0; j < i - 1; j++)
            {
                if (Math.Abs(mass[j] - mass[j + 1]) > 1)
                {
                    Console.WriteLine("NO");
                    flag = false;
                    break;
                }
            }

            if (flag)
            {
                Console.WriteLine("YES");
            }

        }
    }
}


using System;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			for (var i = 0; i < arr.Length-1; i++)
			{
				if (Math.Abs(arr[i] - arr[i + 1]) >= 2)
				{
					Console.WriteLine("NO");
					return;
				}
			}
			Console.WriteLine("YES");
		}
	}
}


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

namespace Zaddda
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = a[0];
            Array.Sort(a);
            if (a[0] == b)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


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

namespace Zaddda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool c = true;
            for(int i = 1; i < a; ++i)
            {
                if(b[i]-b[i-1] > 1)
                {
                    c = false;
                    break;
                }
            }
            if (c)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = Convert.ToInt32(Console.ReadLine());
            int[] mass = new int[i];
            bool flag = true;

            for (int j = 0; j < i - 1; j++)
            {
                if (Math.Abs(mass[j] - mass[j + 1]) > 1)
                {
                    Console.WriteLine("NO");
                    flag = false;
                }
            }

            if (flag)
            {
                Console.WriteLine("YES");
            }
        }
    }
}


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = Convert.ToInt32(Console.ReadLine());
            int[] mass = new int[i];
            string[] q = Console.ReadLine().Split(' ');
            bool flag = true;

            for (int j = 0; j < i; j++)
            {
                mass[j] = Convert.ToInt32(q[j]);
            }

            for (int j = 0; j < i - 1; j++)
            {
                if (Math.Abs(mass[j] - mass[j + 1]) > 1)
                {
                    Console.WriteLine("NO");
                    flag = false;
                }
            }

            if (flag)
            {
                Console.WriteLine("YES");
            }
        }
    }
}


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

namespace Zaddda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool c = true;
            for(int i = 1; i < a; ++i)
            {
                if(b[i]-b[i-1] != 1)
                {
                    c = false;
                    break;
                }
            }
            if (c)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            long n = ReadLong() - 1;

            long ans = 0;
            for (int i = 0; i < 60; i++)
            {
                long a = (1L << i);
                long b = (1L << (i + 1));
                ans += a * ((n + b - a) / b);
            }

            Writer.WriteLine(ans);
        }

        public static void Solve()
        {
            SolveCase();

            /*var sw = Stopwatch.StartNew();

            int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
                Writer.Flush();
                Console.WriteLine($"Task {i + 1} completed");
            }

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);*/
        }

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

            public int X;

            public int Y;

            public double Length => Math.Sqrt(X * X + Y * Y);

            protected bool Equals(Point other)
            {
                return X == other.X && Y == other.Y;
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                {
                    return false;
                }
                if (ReferenceEquals(this, obj))
                {
                    return true;
                }
                /*if (obj.GetType() != this.GetType())
                {
                    return false;
                }*/
                return Equals((Point) obj);
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return (X * 397) ^ Y;
                }
            }

            public int Dist2(Point p)
            {
                return (p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y);
            }

            public static Point operator +(Point a, Point b)
            {
                return new Point(a.X + b.X, a.Y + b.Y);
            }

            public static Point operator -(Point a, Point b)
            {
                return new Point(a.X - b.X, a.Y - b.Y);
            }

            public override string ToString()
            {
                return $"{nameof(X)}: {X}, {nameof(Y)}: {Y}";
            }
        }

        public static class Standard
        {
            public static long Power(long x, long p, long mod)
            {
                long result = 1;
                while (p > 0)
                {
                    if ((p & 1) == 0)
                    {
                        x = (x * x) % mod;
                        p >>= 1;
                    }
                    else
                    {
                        result = (result * x) % mod;
                        p--;
                    }
                }
                return result;
            }

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

            public static List<int> GetPrimes(int n)
            {
                bool[] isPrime = Enumerable.Repeat(true, n + 1).ToArray();
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i <= n; i++)
                {
                    if (isPrime[i])
                    {
                        for (int j = i + i; j <= n; j += i)
                        {
                            isPrime[j] = false;
                        }
                    }
                }
                List<int> primes = new List<int>();
                for (int i = 0; i <= n; i++)
                {
                    if (isPrime[i])
                    {
                        primes.Add(i);
                    }
                }
                return primes;
            }

            public static CompressionResult<T> Compress<T>(IEnumerable<T> values)
            {
                int d = 0;
                var dictionary = new Dictionary<T, int>();
                foreach (T value in values.OrderByWithShuffle(x => x))
                {
                    if (!dictionary.ContainsKey(value))
                    {
                        // todo: increase before or after?
                        d++;
                        dictionary[value] = d;
                    }
                }
                return new CompressionResult<T>(dictionary, d);
            }

            public class CompressionResult<T>
            {
                public CompressionResult(Dictionary<T, int> dictionary, int maxValue)
                {
                    Dictionary = dictionary;
                    MaxValue = maxValue;
                }

                public Dictionary<T, int> Dictionary { get; }

                public int MaxValue { get; }
            }
        }

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

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

            Solve();

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

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

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

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

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

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

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

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

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

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

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

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

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

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

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

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

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

        #endregion
    }
}


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

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new System.IO.StreamReader(@"..\..\..\in"));
            Console.SetOut(new System.IO.StreamWriter(@"..\..\..\out"));
            for (int testN = 0; testN < 3; testN++)
            {
#endif
                var n = NextLong();
                var a = new long[64];
                var i2s = new long[64];
                a[0] = 0;
                a[1] = 1;
                a[2] = 4;
                i2s[0] = 1;
                i2s[1] = 2;
                i2s[2] = 4;
                long i2 = 4;
                for (int i = 3; i < 64; i++)
                {
                    a[i] = a[i - 1] * 2 - i2;
                    i2 *= 2;
                    i2s[i] = i2;
                    a[i] += i2;
                }
                long res = 0;
                int x = 0;
                n--;
                while (n > 0)
                {
                    if ((n & 1) == 1)
                    {
                        res += a[x] + i2s[x];
                    }
                    n >>= 1;
                    x++;
                }

                Console.WriteLine(res);
                //Console.WriteLine(string.Format(NumberFormatInfo.InvariantInfo, "{0:F4}", res));
#if !ONLINE_JUDGE
                Console.ReadLine();
            }
            Console.In.Close();
            Console.Out.Close();
#endif
        }

        private static char[] _defaultSplitter = new char[] { ' ', '\t' };

        private static char[] ReadChars(int n)
        {
            char[] buffer = new char[n];
            Console.In.ReadBlock(buffer, 0, n);
            return buffer;
        }

        private static string[] ReadAll()
        {
            return Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords()
        {
            return ReadWords(_defaultSplitter);
        }

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

        private static int[] ReadInts(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        private static int[] ReadInts()
        {
            return ReadInts(_defaultSplitter);
        }

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

        private static long[] ReadLongs(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        private static long[] ReadLongs()
        {
            return ReadLongs(_defaultSplitter);
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), NumberFormatInfo.InvariantInfo);
        }

        private static int _pos = 0;
        private static string[] _inputLine = new string[0];

        private static void CheckInputLine()
        {
            if (_pos >= _inputLine.Length)
            {
                _inputLine = ReadWords();
                _pos = 0;
            }
        }

        private static string NextWord()
        {
            CheckInputLine();
            return _inputLine[_pos++];
        }

        private static int NextInt()
        {
            CheckInputLine();
            return int.Parse(_inputLine[_pos++]);
        }

        private static long NextLong()
        {
            CheckInputLine();
            return long.Parse(_inputLine[_pos++]);
        }
    }
}


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

namespace C.Kicker
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] D = new int[8];
            for (int i = 0; i < 8; i+=2)
            {
                string str = Console.ReadLine();
                int j;
                for (j = 0; ; j++)
                {
                    if (str[j] == ' ') break;

                }
                D[i] = int.Parse(str.Substring(0,j));
                for (;; j++)
                {
                    if (str[j] != ' ') break;
                }
                D[i + 1] = int.Parse(str.Substring(j));
            }
            int R11 = check(D[0], D[3], D[4], D[7]), R12 = check(D[0], D[3], D[6], D[5]);
            if (R11 == 1 && R12 == 1) Console.WriteLine("Team 1"); else {
                int R21 = check(D[2], D[1], D[4], D[7]), R22 = check(D[2], D[1], D[6], D[5]);
                if (R21 == 1 && R22 == 1) Console.WriteLine("Team 1");
                else if ((R11 == 2 || R12 == 2) && (R21 == 2 || R22 == 2)) Console.WriteLine("Team 2");
                else Console.WriteLine("Draw");
            }

        }
        public static int check(int team1_1, int team1_2, int team2_1,int team2_2)
        {
            if (team1_1 > team2_2 && team1_2 > team2_1)  return 1;
            if (team1_1 < team2_2 && team1_2 < team2_1) return 2;
            return 0;
        }
    }
}


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

namespace CSharpParser
{
    public class Solution : SolutionBase
    {
        protected override void Solve()
        {
            var a = new int[4];
            var b = new int[4];
            for (var i = 0; i < 4; i++)
            {
                Next(out a[i]);
                Next(out b[i]);
            }
            if ((a[0] > b[2] && b[1] > a[3]) && (a[0] > b[3] && b[1] > a[2]))
                PrintLine("Team 1");
            else if ((a[1] > b[2] && b[0] > a[3]) && (a[1] > b[3] && b[0] > a[2]))
                PrintLine("Team 1");
            else if (((a[0] < b[2] && b[1] < a[3]) || (a[0] < b[3] && b[1] < a[2])) && ((a[1] < b[2] && b[0] < a[3]) || (a[1] < b[3] && b[0] < a[2])))
                PrintLine("Team 2");
            else PrintLine("Draw");
        }
    }

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

        public static T Max<T>(params T[] a)
        {
            var ans = a[0];
            var comp = Comparer<T>.Default;
            for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) >= 0 ? ans : a[i];
            return ans;
        }

        public static T Min<T>(params T[] a)
        {
            var ans = a[0];
            var comp = Comparer<T>.Default;
            for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) <= 0 ? ans : a[i];
            return ans;
        }

        public static void RandomShuffle<T>(T[] a, int index, int length)
        {
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Length) throw new ArgumentException();
            var rnd = new Random(DateTime.Now.Millisecond);
            for (var i = index + 1; i < last; i++) Swap(ref a[i], ref a[rnd.Next(index, i + 1)]);
        }

        public static void RandomShuffle<T>(T[] a)
        {
            RandomShuffle(a, 0, a.Length);
        }

        public static bool NextPermutation<T>(T[] a, int index, int length, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Length) throw new ArgumentException();
            for (var i = last - 1; i > index; i--)
                if (compare(a[i], a[i - 1]) > 0)
                {
                    var j = i + 1;
                    for (; j < last; j++) if (compare(a[j], a[i - 1]) <= 0) break;
                    Swap(ref a[i - 1], ref a[j - 1]);
                    Array.Reverse(a, i, last - i);
                    return true;
                }
            Array.Reverse(a, index, length);
            return false;
        }

        public static bool NextPermutation<T>(T[] a, Comparison<T> compare = null)
        {
            return NextPermutation(a, 0, a.Length, compare);
        }

        public static bool PrevPermutation<T>(T[] a, int index, int length, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Length) throw new ArgumentException();
            for (var i = last - 1; i > index; i--)
                if (compare(a[i], a[i - 1]) < 0)
                {
                    var j = i + 1;
                    for (; j < last; j++) if (compare(a[j], a[i - 1]) >= 0) break;
                    Swap(ref a[i - 1], ref a[j - 1]);
                    Array.Reverse(a, i, last - i);
                    return true;
                }
            Array.Reverse(a, index, length);
            return false;
        }

        public static bool PrevPermutation<T>(T[] a, Comparison<T> compare = null)
        {
            return PrevPermutation(a, 0, a.Length, compare);
        }

        public static int LowerBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            if (index + length > a.Count) throw new ArgumentException();
            var ans = index;
            var last = index + length;
            var p2 = 1;
            while (p2 <= length) p2 *= 2;
            for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) < 0) ans += p2;
            return ans;
        }

        public static int LowerBound<T>(IList<T> a, T value, Comparison<T> compare = null)
        {
            return LowerBound(a, 0, a.Count, value, compare);
        }

        public static int UpperBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            if (index + length > a.Count) throw new ArgumentException();
            var ans = index;
            var last = index + length;
            var p2 = 1;
            while (p2 <= length) p2 *= 2;
            for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) <= 0) ans += p2;
            return ans;
        }

        public static int UpperBound<T>(IList<T> a, T value, Comparison<T> compare = null)
        {
            return UpperBound(a, 0, a.Count, value, compare);
        }
    }

    public class InStream : IDisposable
    {
        protected readonly TextReader InputStream;
        private string[] _tokens;
        private int _pointer;

        public InStream(TextReader inputStream)
        {
            InputStream = inputStream;
        }

        public InStream(string str)
        {
            InputStream = new StringReader(str);
        }

        public static InStream Freopen(string str)
        {
            return new InStream(new StreamReader(str));
        }

        public string NextLine()
        {
            try
            {
                return InputStream.ReadLine();
            }
            catch (Exception)
            {
                return null;
            }
        }

        private string NextString()
        {
            try
            {
                while (_tokens == null || _pointer >= _tokens.Length)
                {
                    _tokens = NextLine().Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
                    _pointer = 0;
                }
                return _tokens[_pointer++];
            }
            catch (Exception)
            {
                return null;
            }
        }

        public bool Next<T>(out T ans)
        {
            var str = NextString();
            if (str == null)
            {
                ans = default(T);
                return false;
            }
            ans = (T) Convert.ChangeType(str, typeof (T));
            return true;
        }

        public void Dispose()
        {
            InputStream.Close();
        }
    }

    public class OutStream : IDisposable
    {
        protected readonly TextWriter OutputStream;

        public OutStream(TextWriter outputStream)
        {
            OutputStream = outputStream;
        }

        public OutStream(StringBuilder strB)
        {
            OutputStream = new StringWriter(strB);
        }

        public static OutStream Freopen(string str)
        {
            return new OutStream(new StreamWriter(str));
        }

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

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

        public void PrintLine()
        {
            OutputStream.WriteLine();
        }

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

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

        public void Dispose()
        {
            OutputStream.Close();
        }
    }

    public abstract class SolutionBase : IDisposable
    {
        private readonly InStream _in;
        private readonly OutStream _out;

        protected SolutionBase()
        {
            //System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            _in = new InStream(Console.In);
            _out = new OutStream(Console.Out);
        }

        protected string NextLine()
        {
            return _in.NextLine();
        }

        protected bool Next<T>(out T ans)
        {
            return _in.Next(out ans);
        }

        protected T[] NextArray<T>(int length)
        {
            var array = new T[length];
            for (var i = 0; i < length; i++)
                if (!_in.Next(out array[i]))
                    return null;
            return array;
        }

        protected void PrintArray<T>(IList<T> a, string between = " ", string after = "\n", bool printCount = false)
        {
            if (printCount)
                _out.PrintLine(a.Count);
            for (var i = 0; i < a.Count; i++)
                _out.Print("{0}{1}", a[i], i == a.Count - 1 ? after : between);
        }

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

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

        public void PrintLine()
        {
            _out.PrintLine();
        }

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

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

        public void Dispose()
        {
            _out.Dispose();
        }

        protected abstract void Solve();

        public static void Main()
        {
            using (var p = new Solution()) p.Solve();
        }
    }
}


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

public class Solver
{
    public object Solve()
    {
        int[][] a = ReadIntMatrix(4);

        if ((a[0][0] < a[2][1] && a[1][1] < a[3][0] || a[0][0] < a[3][1] && a[1][1] < a[2][0]) &&
            (a[1][0] < a[2][1] && a[0][1] < a[3][0] || a[1][0] < a[3][1] && a[0][1] < a[2][0]))
            return "Team 2";

        if (a[0][0] > a[2][1] && a[1][1] > a[3][0] && a[0][0] > a[3][1] && a[1][1] > a[2][0] ||
            a[1][0] > a[2][1] && a[0][1] > a[3][0] && a[1][0] > a[3][1] && a[0][1] > a[2][0])
            return "Team 1";

        return "Draw";
    }

    #region I/O
    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = Console.In;
#endif
        writer = Console.Out;
        Solver solver = new Solver();

        try
        {
            object result = solver.Solve();
            if (result != null)
            {
                writer.WriteLine(result);
                //Console.Error.WriteLine(result);
            }
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex);
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read helpers

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

    public static string ReadToken()
    {
        if (currentLineTokens.Count == 0)
        {
            currentLineTokens = new Queue<string>(reader.ReadLine().Trim().Split(' '));
        }
        return currentLineTokens.Dequeue();
    }

    public static string[] ReadTokens(bool fromCurrentLine = false)
    {
        string[] split;
        if (fromCurrentLine)
        {
            if (currentLineTokens.Count == 0)
                return new string[0];
            split = currentLineTokens.ToArray();
            currentLineTokens.Clear();
        }
        else
        {
            split = reader.ReadLine().Trim().Split(' ');
        }
        return split;
    }

    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(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray(bool fromCurrentLine = false)
    {
        string[] tokens = ReadTokens(fromCurrentLine);
        return tokens.Select(double.Parse).ToArray();
    }

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

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

    #endregion
}


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

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

        private static readonly StreamWriter writer =
            new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var tt = new int[4,2];
            for (int i = 0; i < 4; i++)
            {
                string[] ss = reader.ReadLine().Split(' ');
                int a = int.Parse(ss[0]);
                int d = int.Parse(ss[1]);
                tt[i, 0] = a;
                tt[i, 1] = d;
            }

            bool fwin = false;
            int swin = 0;

            for (int i = 0; i < 2; i++)
            {
                int a1 = tt[i, 0];
                int b1 = tt[1 - i, 1];
                int s1 = 0, s2 = 0;
                for (int j = 2; j < 4; j++)
                {
                    int a2 = tt[j, 0];
                    int b2 = tt[5 - j, 1];

                    if (a2 > b1 && b2 > a1)
                        s2++;
                    if (a2 < b1 && b2 < a1)
                        s1++;
                }
                if (s1 == 2)
                    fwin = true;
                if (s2 > 0)
                    swin++;
            }

            if (fwin)
                writer.WriteLine("Team 1");
            else if (swin == 2)
                writer.WriteLine("Team 2");
            else
            {
                writer.WriteLine("Draw");
            }
            writer.Flush();
        }
    }
}


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

namespace RCC2014
{
	class QR_C
	{
		private int beat(int a_atk, int a_def, int b_atk, int b_def)
		{
			if (a_atk > b_def && a_def > b_atk) return 1;
			if (b_atk > a_def && b_def > a_atk) return -1;
			return 0;
		}

		public void Solve(XOI xoi)
		{
			int i, j, res, ans;
			int[,] team;
			string[] ans_words = { "Team 2", "Draw", "Team 1" };

			team = new int[4, 2];
			for (i = 0; i < 4; i++)
				for (j = 0; j < 2; j++)
					team[i, j] = xoi.ReadInt();

			for (i = 0, ans = -1999; i <= 1; i++)
			{
				for (j = 2, res = 1999; j <= 3; j++)
					res = Math.Min(res, beat(team[i, 1], team[1 - i, 0], team[j, 1], team[5 - j, 0]));
				ans = Math.Max(ans, res);
			}

			xoi.o.WriteLine(ans_words[ans + 1]);
		}
	}

	class RCC2014_QR
	{
		static void Main(string[] args)
		{
			XOI xoi = new XOI();
			(new QR_C()).Solve(xoi);
		}
	}
}

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

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

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

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

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

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

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

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

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

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


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

namespace Contest
{
    class Program
    {
        static void Main()
        {
            var s=" ";
            string[] all;
            int[,] a=new int[4,2];
            for (int i = 0; i < 4; i++)
            {
                s=Console.ReadLine();
                all = s.Split(' ');
                a[i, 0] = Convert.ToInt32(all[0]);
                a[i, 1] = Convert.ToInt32(all[1]);
            }
            String win1 = "Team 1";
String win2 = "Team 2";
String draw = "Draw";

int powProtect1 = 0;
int powAttack1 = 0;
int powProtect2 = 0;
int powAttack2 = 0;
int powProtect11 = 0;
int powAttack11 = 0;
int powProtect21 = 0;
int powAttack21 = 0;
powAttack1 = a[1, 1];
powProtect1 = a[0, 0];
powAttack11 = a[0, 1];
powProtect11 = a[1, 0];

      powAttack2=a[3,1];
    powProtect2=a[2,0];
    powAttack21 = a[2, 1];
    powProtect21 = a[3, 0];
    if ((((powProtect1 < powAttack2) && (powAttack1 < powProtect2)) || ((powProtect1 < powAttack21) && (powAttack1 < powProtect21))) && (((powProtect11 < powAttack2) && (powAttack11 < powProtect2)) || ((powProtect11 < powAttack21) && (powAttack11 < powProtect21))))
    {

Console.WriteLine(win2);
}
    else if (((powProtect11 > powAttack2) && (powAttack11 > powProtect2) && (powProtect11 > powAttack21) && (powAttack11 > powProtect21)) || ((powProtect1 > powAttack2) && (powAttack1 > powProtect2) && (powProtect1 > powAttack21) && (powAttack1 > powProtect21)))
{  Console.WriteLine(win1);
}else{
Console.WriteLine(draw);
}

        }
    }
}


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

namespace Contest
{
class Program
{
static void Main(string[] args)
{
var s=" ";
string[] all;
int[,] a=new int[4,2];
for (int i = 0; i < 4; i++)
{
s=Console.ReadLine();
all = s.Split(' ');
a[i, 0] = Convert.ToInt32(all[0]);
a[i, 1] = Convert.ToInt32(all[1]);
}
String win1 = "Team 1";
String win2 = "Team 2";
String draw = "Draw";

int powProtect1 = 0;
int powAttack1 = 0;
int powProtect2 = 0;
int powAttack2 = 0;
int powProtect11 = 0;
int powAttack11 = 0;
int powProtect21 = 0;
int powAttack21 = 0;
powAttack1 = a[1, 1];
powProtect1 = a[0, 0];
powAttack11 = a[0, 1];
powProtect11 = a[1, 0];

powAttack2=a[3,1];
powProtect2=a[2,0];
powAttack21 = a[2, 1];
powProtect21 = a[3, 0];
if ((((powProtect1 < powAttack2) && (powAttack1 < powProtect2)) || ((powProtect1 < powAttack21) && (powAttack1 < powProtect21))) && (((powProtect11 < powAttack2) && (powAttack11 < powProtect2)) || ((powProtect11 < powAttack21) && (powAttack11 < powProtect21))))
{

Console.WriteLine(win2);
}
else if (((powProtect11 > powAttack2) && (powAttack11 > powProtect2) && (powProtect11 > powAttack21) && (powAttack11 > powProtect21)) || ((powProtect1 > powAttack2) && (powAttack1 > powProtect2) && (powProtect1 > powAttack21) && (powAttack1 > powProtect21)))
{ Console.WriteLine(win1);
}else{
Console.WriteLine(draw);
}

}
}
}


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

namespace Algorithm
{
    class Solver
    {
        Player[] a = new Player[4];

        public void Run()
        {
            for (int i = 0; i < 4; i++)
            {
                string[] tokens = cin.ReadLine().Split();
                int x = int.Parse(tokens[0]);
                int y = int.Parse(tokens[1]);
                a[i] = new Player(x, y);
            }

            if (can_win(a[0].Defence, a[1].Attak, a[2].Defence, a[3].Attak) &&
                can_win(a[0].Defence, a[1].Attak, a[3].Defence, a[2].Attak))
            {
                cout.WriteLine("Team 1");
                return;
            }
            if (can_win(a[1].Defence, a[0].Attak, a[2].Defence, a[3].Attak) &&
                can_win(a[1].Defence, a[0].Attak, a[3].Defence, a[2].Attak))
            {
                cout.WriteLine("Team 1");
                return;
            }

            int cnt = 0;
            if (can_win(a[2].Defence, a[3].Attak, a[0].Defence, a[1].Attak) ||
               can_win(a[3].Defence, a[2].Attak, a[0].Defence, a[1].Attak)) cnt++;
            if (can_win(a[2].Defence, a[3].Attak, a[1].Defence, a[0].Attak) ||
                can_win(a[3].Defence, a[2].Attak, a[1].Defence, a[0].Attak)) cnt++;

            if (cnt == 2)
                cout.WriteLine("Team 2");
            else
                cout.WriteLine("Draw");
        }

        bool can_win(int a, int b, int c, int d)
        {
            if (a > d && b > c) return true;
            return false;
        }

        void Swap(ref int a, ref int b)
        {
            int tmp = a;
            a = b;
            b = tmp;
        }

        public StreamReader cin = null;
        public StreamWriter cout = null;
    }

    class Player
    {
        public Player() { }
        public Player(int _a, int _d)
        {
            this.Attak = _a;
            this.Defence = _d;
        }
        public int Attak;
        public int Defence;
    }

    class Program
    {
        public static void Main(string[] args)
        {
            Solver task = new Solver();
#if DEBUG
            task.cin = new StreamReader("input.txt");
            task.cout = new StreamWriter("output.txt");
#else
            task.cin = new StreamReader(Console.OpenStandardInput());
            task.cout = new StreamWriter(Console.OpenStandardOutput());
#endif
            task.cout.AutoFlush = true;
            task.Run();
        }
    }
}


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

namespace Contest
{
    class Program
    {
        static void Main()
        {
            var s=" ";
            string[] all;
            int[,] a=new int[4,2];
            for (int i = 0; i < 4; i++)
            {
                s=Console.ReadLine();
                all = s.Split(' ');
                a[i, 0] = Convert.ToInt32(all[0]);
                a[i, 1] = Convert.ToInt32(all[1]);
            }
            String win1 = "Team 1";
String win2 = "Team 2";
String draw = "Draw";

int powProtect1 = 0;
int powAttack1 = 0;
int powProtect2 = 0;
int powAttack2 = 0;

int max1=a[0,0]+a[1,1];
if (max1>=a[0,1]+a[1,0])
{powAttack1=a[1,1];
    powProtect1=a[0,0];
}
else
{powAttack1=a[0,1];
    powProtect1=a[1,0];

}
            max1=a[2,0]+a[3,1];
            int powAttack21=0;
            int powProtect21 = 0;
if (max1>a[2,1]+a[3,0])
{powAttack2=a[3,1];
    powProtect2=a[2,0];
    powAttack21 = a[2, 1];
    powProtect21 = a[3, 0];
}
else
    if (max1 < a[2, 1] + a[3, 0])
    {
        powAttack2 = a[2, 1];
        powProtect2 = a[3, 0];
        powAttack21 = a[3, 1];
        powProtect21 = a[2, 0];

    }
    else
    {
        powAttack2 = a[3, 1];
        powProtect2 = a[2, 0];
        powAttack21 = a[2, 1];
        powProtect21 = a[3, 0];
    }

if((powProtect1 > powProtect2) && (powAttack1 > powAttack2)){
Console.WriteLine(win1);
}else if(((powProtect1 < powProtect2) && (powAttack1 < powAttack2))||((powProtect1 < powProtect21) && (powAttack1 < powAttack21))){
Console.WriteLine(win2);
}else{
Console.WriteLine(draw);
}

        }
    }
}


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

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

        private static readonly StreamWriter writer =
            new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var tt = new int[4,2];
            for (int i = 0; i < 4; i++)
            {
                string[] ss = reader.ReadLine().Split(' ');
                int a = int.Parse(ss[0]);
                int d = int.Parse(ss[1]);
                tt[i, 0] = a;
                tt[i, 1] = d;
            }

            bool fwin = false;
            int swin = 0;

            for (int i = 0; i < 2; i++)
            {
                int a1 = tt[i, 0];
                int b1 = tt[1 - i, 1];
                int s1 = 0, s2 = 0;
                for (int j = 2; j < 4; j++)
                {
                    int a2 = tt[j, 0];
                    int b2 = tt[5 - j, 1];

                    if (a2 > b1 && b2 > a1)
                        s2++;
                    if (a2 < b1 && b2 < a1)
                        s1++;
                }
                if (s1 == 2)
                    fwin = true;
                if (s2 > 1)
                    swin++;
            }

            if (fwin)
                writer.WriteLine("Team 1");
            else if (swin == 2)
                writer.WriteLine("Team 2");
            else
            {
                writer.WriteLine("Draw");
            }
            writer.Flush();
        }
    }
}