using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using CodeforcesRound678Div2.Questions;
using ModInt = CodeforcesRound678Div2.Questions.StaticModInt<CodeforcesRound678Div2.Questions.Mod1000000007>;

namespace CodeforcesRound678Div2.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
        public override void Solve(IOManager io)
        {
            var n = io.ReadInt();
            var x = io.ReadInt();
            var pos = io.ReadInt();

            var more = n - x;
            var less = x - 1;

            var left = 0;
            var right = n;
            ModInt result = ModInt.One;

            while (left < right)
            {
                var middle = (left + right) / 2;

                if (middle > pos)
                {
                    if (more > 0)
                    {
                        result *= ModInt.Raw(more);
                        more--;
                    }
                    else
                    {
                        result = ModInt.Zero;
                    }
                    right = middle;
                }
                else if (middle < pos)
                {
                    if (less > 0)
                    {
                        result *= ModInt.Raw(less);
                        less--;
                    }
                    else
                    {
                        result = ModInt.Zero;
                    }
                    left = middle + 1;
                }
                else
                {
                    left = middle + 1;
                }
            }

            for (int i = 1; i <= more + less; i++)
            {
                result *= ModInt.Raw(i);
            }

            io.WriteLine(result);
        }
    }

    ///
    /// コンパイル時に決定する mod を表します。
    ///
    /// <example>
    ///
    /// public readonly struct Mod1000000009 : IStaticMod
    /// {
    ///     public uint Mod => 1000000009;
    ///     public bool IsPrime => true;
    /// }
    ///
    /// </example>
    public interface IStaticMod
    {
        ///
        /// mod を取得します。
        ///
        uint Mod { get; }

        ///
        /// mod が素数であるか識別します。
        ///
        bool IsPrime { get; }
    }

    public readonly struct Mod1000000007 : IStaticMod
    {
        public uint Mod => 1000000007;
        public bool IsPrime => true;
    }

    public readonly struct Mod998244353 : IStaticMod
    {
        public uint Mod => 998244353;
        public bool IsPrime => true;
    }

    ///
    /// 実行時に決定する mod の ID を表します。
    ///
    /// <example>
    ///
    /// public readonly struct ModID123 : IDynamicModID { }
    ///
    /// </example>
    public interface IDynamicModID { }

    public readonly struct ModID0 : IDynamicModID { }
    public readonly struct ModID1 : IDynamicModID { }
    public readonly struct ModID2 : IDynamicModID { }

    ///
    /// 四則演算時に自動で mod を取る整数型。mod の値はコンパイル時に決定している必要があります。
    ///
    /// <typeparam name="T">定数 mod を表す構造体</typeparam>
    /// <example>
    ///
    /// using ModInt = AtCoder.StaticModInt<AtCoder.Mod1000000007>;
    ///
    /// void SomeMethod()
    /// {
    ///     var m = new ModInt(1);
    ///     m -= 2;
    ///     Console.WriteLine(m);   // 1000000006
    /// }
    ///
    /// </example>
    public readonly struct StaticModInt<T> : IEquatable<StaticModInt<T>> where T : struct, IStaticMod
    {
        private readonly uint _v;

        ///
        /// 格納されている値を返します。
        ///
        public int Value => (int)_v;

        ///
        /// mod を返します。
        ///
        public static int Mod => (int)default(T).Mod;

        public static StaticModInt<T> Zero => new StaticModInt<T>();
        public static StaticModInt<T> One => new StaticModInt<T>(1u);

        ///
        /// <paramref name="v"/> に対して mod を取らずに StaticModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>定数倍高速化のための関数です。 <paramref name="v"/> に 0 未満または mod 以上の値を入れた場合の挙動は未定義です。</para>
        /// <para>制約: 0≤|<paramref name="v"/>|<mod</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> Raw(int v)
        {
            var u = unchecked((uint)v);
            Debug.Assert(u < Mod);
            return new StaticModInt<T>(u);
        }

        ///
        /// StaticModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <paramref name="v"/>が 0 未満、もしくは mod 以上の場合、自動で mod を取ります。
        /// </remarks>
        public StaticModInt(long v) : this(Round(v)) { }

        private StaticModInt(uint v) => _v = v;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static uint Round(long v)
        {
            var x = v % default(T).Mod;
            if (x < 0)
            {
                x += default(T).Mod;
            }
            return (uint)x;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator ++(StaticModInt<T> value)
        {
            var v = value._v + 1;
            if (v == default(T).Mod)
            {
                v = 0;
            }
            return new StaticModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator --(StaticModInt<T> value)
        {
            var v = value._v;
            if (v == 0)
            {
                v = default(T).Mod;
            }
            return new StaticModInt<T>(v - 1);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator +(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            var v = lhs._v + rhs._v;
            if (v >= default(T).Mod)
            {
                v -= default(T).Mod;
            }
            return new StaticModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator -(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            unchecked
            {
                var v = lhs._v - rhs._v;
                if (v >= default(T).Mod)
                {
                    v += default(T).Mod;
                }
                return new StaticModInt<T>(v);
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static StaticModInt<T> operator *(StaticModInt<T> lhs, StaticModInt<T> rhs)
        {
            return new StaticModInt<T>((uint)((ulong)lhs._v * rhs._v % default(T).Mod));
        }

        ///
        /// 除算を行います。
        ///
        /// <remarks>
        /// <para>- 制約: <paramref name="rhs"/> に乗法の逆元が存在する。（gcd(<paramref name="rhs"/>, mod) = 1）</para>
        /// <para>- 計算量: O(log(mod))</para>
        /// </remarks>
        public static StaticModInt<T> operator /(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs * rhs.Inverse();

        public static StaticModInt<T> operator +(StaticModInt<T> value) => value;
        public static StaticModInt<T> operator -(StaticModInt<T> value) => new StaticModInt<T>() - value;
        public static bool operator ==(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs._v == rhs._v;
        public static bool operator !=(StaticModInt<T> lhs, StaticModInt<T> rhs) => lhs._v != rhs._v;
        public static implicit operator StaticModInt<T>(int value) => new StaticModInt<T>(value);
        public static implicit operator StaticModInt<T>(long value) => new StaticModInt<T>(value);

        ///
        /// 自身を x として、x^<paramref name="n"/> を返します。
        ///
        /// <remarks>
        /// <para>制約: 0≤|<paramref name="n"/>|</para>
        /// <para>計算量: O(log(<paramref name="n"/>))</para>
        /// </remarks>
        public StaticModInt<T> Pow(long n)
        {
            Debug.Assert(0 <= n);
            var x = this;
            var r = Raw(1);

            while (n > 0)
            {
                if ((n & 1) > 0)
                {
                    r *= x;
                }
                x *= x;
                n >>= 1;
            }

            return r;
        }

        ///
        /// 自身を x として、 xy≡1 なる y を返します。
        ///
        /// <remarks>
        /// <para>制約: gcd(x, mod) = 1</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public StaticModInt<T> Inverse()
        {
            if (default(T).IsPrime)
            {
                Debug.Assert(_v > 0);
                return Pow(default(T).Mod - 2);
            }
            else
            {
                var (g, x) = InternalMath.InvGCD(_v, default(T).Mod);
                Debug.Assert(g == 1);
                return new StaticModInt<T>(x);
            }
        }

        public override string ToString() => _v.ToString();
        public override bool Equals(object obj) => obj is StaticModInt<T> && Equals((StaticModInt<T>)obj);
        public bool Equals(StaticModInt<T> other) => Value == other.Value;
        public override int GetHashCode() => _v.GetHashCode();
    }

    ///
    /// 四則演算時に自動で mod を取る整数型。実行時に mod が決まる場合でも使用可能です。
    ///
    /// <remarks>
    /// 使用前に DynamicModInt<<typeparamref name="T"/>>.Mod に mod の値を設定する必要があります。
    /// </remarks>
    /// <typeparam name="T">mod の ID を表す構造体</typeparam>
    /// <example>
    ///
    /// using AtCoder.ModInt = AtCoder.DynamicModInt<AtCoder.ModID0>;
    ///
    /// void SomeMethod()
    /// {
    ///     ModInt.Mod = 1000000009;
    ///     var m = new ModInt(1);
    ///     m -= 2;
    ///     Console.WriteLine(m);   // 1000000008
    /// }
    ///
    /// </example>
    public readonly struct DynamicModInt<T> : IEquatable<DynamicModInt<T>> where T : struct, IDynamicModID
    {
        private readonly uint _v;
        private static Barrett bt;

        ///
        /// 格納されている値を返します。
        ///
        public int Value => (int)_v;

        ///
        /// mod を返します。
        ///
        public static int Mod
        {
            get => (int)bt.Mod;
            set
            {
                Debug.Assert(1 <= value);
                bt = new Barrett((uint)value);
            }
        }

        ///
        /// <paramref name="v"/> に対して mod を取らずに DynamicModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>定数倍高速化のための関数です。 <paramref name="v"/> に 0 未満または mod 以上の値を入れた場合の挙動は未定義です。</para>
        /// <para>制約: 0≤|<paramref name="v"/>|<mod</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> Raw(int v)
        {
            var u = unchecked((uint)v);
            Debug.Assert(bt != null, $"使用前に {nameof(DynamicModInt<T>)}<{nameof(T)}>.{nameof(Mod)} プロパティに mod の値を設定してください。");
            Debug.Assert(u < Mod);
            return new DynamicModInt<T>(u);
        }

        ///
        /// DynamicModInt<<typeparamref name="T"/>> 型のインスタンスを生成します。
        ///
        /// <remarks>
        /// <para>- 使用前に DynamicModInt<<typeparamref name="T"/>>.Mod に mod の値を設定する必要があります。</para>
        /// <para>- <paramref name="v"/> が 0 未満、もしくは mod 以上の場合、自動で mod を取ります。</para>
        /// </remarks>
        public DynamicModInt(long v) : this(Round(v)) { }

        private DynamicModInt(uint v) => _v = v;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static uint Round(long v)
        {
            Debug.Assert(bt != null, $"使用前に {nameof(DynamicModInt<T>)}<{nameof(T)}>.{nameof(Mod)} プロパティに mod の値を設定してください。");
            var x = v % bt.Mod;
            if (x < 0)
            {
                x += bt.Mod;
            }
            return (uint)x;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator ++(DynamicModInt<T> value)
        {
            var v = value._v + 1;
            if (v == bt.Mod)
            {
                v = 0;
            }
            return new DynamicModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator --(DynamicModInt<T> value)
        {
            var v = value._v;
            if (v == 0)
            {
                v = bt.Mod;
            }
            return new DynamicModInt<T>(v - 1);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator +(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            var v = lhs._v + rhs._v;
            if (v >= bt.Mod)
            {
                v -= bt.Mod;
            }
            return new DynamicModInt<T>(v);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator -(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            unchecked
            {
                var v = lhs._v - rhs._v;
                if (v >= bt.Mod)
                {
                    v += bt.Mod;
                }
                return new DynamicModInt<T>(v);
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static DynamicModInt<T> operator *(DynamicModInt<T> lhs, DynamicModInt<T> rhs)
        {
            uint z = bt.Mul(lhs._v, rhs._v);
            return new DynamicModInt<T>(z);
        }

        ///
        /// 除算を行います。
        ///
        /// <remarks>
        /// <para>- 制約: <paramref name="rhs"/> に乗法の逆元が存在する。（gcd(<paramref name="rhs"/>, mod) = 1）</para>
        /// <para>- 計算量: O(log(mod))</para>
        /// </remarks>
        public static DynamicModInt<T> operator /(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs * rhs.Inverse();

        public static DynamicModInt<T> operator +(DynamicModInt<T> value) => value;
        public static DynamicModInt<T> operator -(DynamicModInt<T> value) => new DynamicModInt<T>() - value;
        public static bool operator ==(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs._v == rhs._v;
        public static bool operator !=(DynamicModInt<T> lhs, DynamicModInt<T> rhs) => lhs._v != rhs._v;
        public static implicit operator DynamicModInt<T>(int value) => new DynamicModInt<T>(value);
        public static implicit operator DynamicModInt<T>(long value) => new DynamicModInt<T>(value);

        ///
        /// 自身を x として、x^<paramref name="n"/> を返します。
        ///
        /// <remarks>
        /// <para>制約: 0≤|<paramref name="n"/>|</para>
        /// <para>計算量: O(log(<paramref name="n"/>))</para>
        /// </remarks>
        public DynamicModInt<T> Pow(long n)
        {
            Debug.Assert(0 <= n);
            var x = this;
            var r = Raw(1);

            while (n > 0)
            {
                if ((n & 1) > 0)
                {
                    r *= x;
                }
                x *= x;
                n >>= 1;
            }

            return r;
        }

        ///
        /// 自身を x として、 xy≡1 なる y を返します。
        ///
        /// <remarks>
        /// <para>制約: gcd(x, mod) = 1</para>
        /// </remarks>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public DynamicModInt<T> Inverse()
        {
            var (g, x) = InternalMath.InvGCD(_v, bt.Mod);
            Debug.Assert(g == 1);
            return new DynamicModInt<T>(x);
        }

        public override string ToString() => _v.ToString();
        public override bool Equals(object obj) => obj is DynamicModInt<T> && Equals((DynamicModInt<T>)obj);
        public bool Equals(DynamicModInt<T> other) => Value == other.Value;
        public override int GetHashCode() => _v.GetHashCode();
    }

    ///
    /// Fast moduler by barrett reduction
    /// <seealso href="https://en.wikipedia.org/wiki/Barrett_reduction"/>
    ///
    public class Barrett
    {
        public uint Mod { get; private set; }
        private ulong IM;
        public Barrett(uint m)
        {
            Mod = m;
            IM = unchecked((ulong)-1) / m + 1;
        }

        ///
        /// <paramref name="a"/> * <paramref name="b"/> mod m
        ///
        public uint Mul(uint a, uint b)
        {
            ulong z = a;
            z *= b;
            if (!Bmi2.X64.IsSupported) return (uint)(z % Mod);
            var x = Bmi2.X64.MultiplyNoFlags(z, IM);
            var v = unchecked((uint)(z - x * Mod));
            if (Mod <= v) v += Mod;
            return v;
        }
    }

    public static class InternalMath
    {
        ///
        /// g=gcd(a,b),xa=g(mod b) となるような 0≤x<b/g の(g, x)
        ///
        /// <remarks>
        /// <para>制約: 1≤<paramref name="b"/></para>
        /// </remarks>
        public static (long, long) InvGCD(long a, long b)
        {
            a = SafeMod(a, b);
            if (a == 0) return (b, 0);

            long s = b, t = a;
            long m0 = 0, m1 = 1;

            long u;
            while (true)
            {
                if (t == 0)
                {
                    if (m0 < 0) m0 += b / s;
                    return (s, m0);
                }
                u = s / t;
                s -= t * u;
                m0 -= m1 * u;

                if (s == 0)
                {
                    if (m1 < 0) m1 += b / t;
                    return (t, m1);
                }
                u = t / s;
                t -= s * u;
                m1 -= m0 * u;
            }
        }

        public static long SafeMod(long x, long m)
        {
            x %= m;
            if (x < 0) x += m;
            return x;
        }
    }

    public class ModCombination<T> where T : struct, IStaticMod
    {
        readonly StaticModInt<T>[] _factorials;
        readonly StaticModInt<T>[] _invFactorials;

        public ModCombination(int max = 1000000)
        {
            if (max >= default(T).Mod)
            {
                ThrowArgumentOutOfRangeException();
            }

            _factorials = new StaticModInt<T>[max + 1];
            _invFactorials = new StaticModInt<T>[max + 1];

            _factorials[0] = _factorials[1] = StaticModInt<T>.Raw(1);
            _invFactorials[0] = _invFactorials[1] = StaticModInt<T>.Raw(1);

            for (int i = 2; i < _factorials.Length; i++)
            {
                _factorials[i] = _factorials[i - 1] * StaticModInt<T>.Raw(i);
            }

            _invFactorials[^1] = _factorials[^1].Inverse();

            for (int i = _invFactorials.Length - 2; i >= 0; i--)
            {
                _invFactorials[i] = _invFactorials[i + 1] * StaticModInt<T>.Raw(i + 1);
            }
        }

        public StaticModInt<T> Factorial(int n) => _factorials[n];

        public StaticModInt<T> Permutation(int n, int k) => _factorials[n] * _invFactorials[n - k];

        public StaticModInt<T> Combination(int n, int k) => _factorials[n] * _invFactorials[k] * _invFactorials[n - k];

        public StaticModInt<T> CombinationWithRepetition(int n, int k) => Combination(n + k - 1, k);

        public void ThrowArgumentOutOfRangeException() => throw new ArgumentOutOfRangeException();
    }
}

namespace CodeforcesRound678Div2
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();
            using var io = new IOManager(Console.OpenStandardInput(), Console.OpenStandardOutput());
            question.Solve(io);
        }
    }
}

#region Base Class

namespace CodeforcesRound678Div2.Questions
{
    public interface IAtCoderQuestion
    {
        string Solve(string input);
        void Solve(IOManager io);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var inputStream = new MemoryStream(Encoding.UTF8.GetBytes(input));
            var outputStream = new MemoryStream();
            using var manager = new IOManager(inputStream, outputStream);

            Solve(manager);
            manager.Flush();

            outputStream.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(outputStream);
            return reader.ReadToEnd();
        }

        public abstract void Solve(IOManager io);
    }
}

#endregion

#region Utils

namespace CodeforcesRound678Div2
{
    public class IOManager : IDisposable
    {
        private readonly BinaryReader _reader;
        private readonly StreamWriter _writer;
        private bool _disposedValue;
        private byte[] _buffer = new byte[1024];
        private int _length;
        private int _cursor;
        private bool _eof;

        const char ValidFirstChar = '!';
        const char ValidLastChar = '~';

        public IOManager(Stream input, Stream output)
        {
            _reader = new BinaryReader(input);
            _writer = new StreamWriter(output) { AutoFlush = false };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private char ReadAscii()
        {
            if (_cursor == _length)
            {
                _cursor = 0;
                _length = _reader.Read(_buffer);

                if (_length == 0)
                {
                    if (!_eof)
                    {
                        _eof = true;
                        return char.MinValue;
                    }
                    else
                    {
                        ThrowEndOfStreamException();
                    }
                }
            }

            return (char)_buffer[_cursor++];
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public char ReadChar()
        {
            char c;
            while (!IsValidChar(c = ReadAscii())) { }
            return c;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public string ReadString()
        {
            var builder = new StringBuilder();
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                builder.Append(c);
            } while (IsValidChar(c = ReadAscii()));

            return builder.ToString();
        }

        public int ReadInt() => (int)ReadLong();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public long ReadLong()
        {
            long result = 0;
            bool isPositive = true;
            char c;

            while (!IsNumericChar(c = ReadAscii())) { }

            if (c == '-')
            {
                isPositive = false;
                c = ReadAscii();
            }

            do
            {
                result *= 10;
                result += c - '0';
            } while (IsNumericChar(c = ReadAscii()));

            return isPositive ? result : -result;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private Span<char> ReadChunk(Span<char> span)
        {
            var i = 0;
            char c;
            while (!IsValidChar(c = ReadAscii())) { }

            do
            {
                span[i++] = c;
            } while (IsValidChar(c = ReadAscii()));

            return span.Slice(0, i);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public double ReadDouble() => double.Parse(ReadChunk(stackalloc char[32]));

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public decimal ReadDecimal() => decimal.Parse(ReadChunk(stackalloc char[32]));

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

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

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

        public decimal[] ReadDecimalArray(int n)
        {
            var a = new decimal[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = ReadDecimal();
            }
            return a;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void WriteLine<T>(T value) => _writer.WriteLine(value.ToString());

        public void WriteLine<T>(IEnumerable<T> values, char separator)
        {
            var e = values.GetEnumerator();
            if (e.MoveNext())
            {
                _writer.Write(e.Current.ToString());

                while (e.MoveNext())
                {
                    _writer.Write(separator);
                    _writer.Write(e.Current.ToString());
                }
            }

            _writer.WriteLine();
        }

        public void WriteLine<T>(Span<T> values, char separator) => WriteLine((ReadOnlySpan<T>)values, separator);

        public void WriteLine<T>(ReadOnlySpan<T> values, char separator)
        {
            for (int i = 0; i < values.Length - 1; i++)
            {
                _writer.Write(values[i]);
                _writer.Write(separator);
            }

            if (values.Length > 0)
            {
                _writer.Write(values[^1]);
            }

            _writer.WriteLine();
        }

        public void Flush() => _writer.Flush();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsValidChar(char c) => ValidFirstChar <= c && c <= ValidLastChar;

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsNumericChar(char c) => ('0' <= c && c <= '9') || c == '-';

        private void ThrowEndOfStreamException() => throw new EndOfStreamException();

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _reader.Dispose();
                    _writer.Flush();
                    _writer.Dispose();
                }

                _disposedValue = true;
            }
        }

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

    public static class UtilExtensions
    {
        public static bool ChangeMax<T>(ref this T value, T other) where T : struct, IComparable<T>
        {
            if (value.CompareTo(other) < 0)
            {
                value = other;
                return true;
            }
            return false;
        }

        public static bool ChangeMin<T>(ref this T value, T other) where T : struct, IComparable<T>
        {
            if (value.CompareTo(other) > 0)
            {
                value = other;
                return true;
            }
            return false;
        }

        public static void SwapIfLargerThan<T>(ref this T a, ref T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) > 0)
            {
                (a, b) = (b, a);
            }
        }

        public static void SwapIfSmallerThan<T>(ref this T a, ref T b) where T : struct, IComparable<T>
        {
            if (a.CompareTo(b) < 0)
            {
                (a, b) = (b, a);
            }
        }

        public static void Sort<T>(this T[] array) where T : IComparable<T> => Array.Sort(array);
        public static void Sort<T>(this T[] array, Comparison<T> comparison) => Array.Sort(array, comparison);
    }

    public static class CollectionExtensions
    {
        private class ArrayWrapper<T>
        {
#pragma warning disable CS0649
            public T[] Array;
#pragma warning restore CS0649
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static Span<T> AsSpan<T>(this List<T> list)
        {
            return Unsafe.As<ArrayWrapper<T>>(list).Array.AsSpan(0, list.Count);
        }

        public static void Fill<T>(this T[] array, T value) => array.AsSpan().Fill(value);
        public static void Fill<T>(this T[,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0], array.Length).Fill(value);
        public static void Fill<T>(this T[,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0], array.Length).Fill(value);
        public static void Fill<T>(this T[,,,] array, T value) => MemoryMarshal.CreateSpan(ref array[0, 0, 0, 0], array.Length).Fill(value);
    }
}

#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;

namespace OJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = ReadLine();
            char[] a = s.ToCharArray();
            int k;
            char c='a';
            k = s.Length;
            int count = 0;
            char[] b = new char[26];
            for (int i = 0; i < 26; i++)
            {
                b[i] = c;
                c++;
            }
            for (int i = 0; i < k; i++)
            {
                for (int j = 0; j < 26; j++)
                {
                    if(b[j]==a[i])
                    {
                        count++;
                        b[j] = '0';
                    }
                }
            }

            if (count % 2 == 0)
                WriteLine("CHAT WITH HER!");
            else
                WriteLine("IGNORE HIM!");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Diagnostics;
using static System.Math;
using static System.Console;

namespace Codeforces
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int t = Int(ReadLine());
            List<string> res = new List<string>();

            for (int i = 0; i < t; i++)
            {
                // int len = Int(ReadLine());
                //List<long> n = GetLongs(ReadLine());
                long n = Long(ReadLine());

                Solve(n, res);

            }

            foreach (string s in res) WriteLine(s);

            //foreach (string s in list) Console.WriteLine(s);
            //string[] nums = Console.ReadLine().Split(' ');

            //for (int i = 0; i < n; i++)
            //{
            //    list.Add(Int(nums[i]));
            //}

            // Solve(word);
            //Console.WriteLine(res);
            ReadLine();
        }

        private static void Solve(long n, List<string> res)
        {

            double cubes = F(n);
            double sqrs = Sqrt(n);
            double six = Sqrt(cubes);

            long re = (long)(Floor(cubes) + Floor(sqrs) - Floor(six));

            res.Add(re.ToString());
        }

        private static string Divisors(long num, int div, string s)
        {
            if (num < 2) return s;
            if (num % div == 0)
            {
                return Divisors(num / div, 2, s + " " + div.ToString());
            }
            return Divisors(num, div + 1, s);
        }

            private static string ReverseString(string x)
        {
            if (x.Length <= 1) return x;
            return ReverseString(x.Substring(1)) + x[0];
        }
        private static double F(long x)
        {
            double sm = Pow(10, -10);
             double h = Pow(x, (double)1 / 3);
            double rh = Round(h);
            return Abs(rh - h) <= sm ? rh: h;

        }
        /* --------------------------------------------------------------------------------------------------------------*/
        /* --------------------------------------------------------------------------------------------------------------*/
        /* --------------------------------------------------------------------------------------------------------------*/
        /* --------------------------------------------------------------------------------------------------------------*/
        private static int BinarySearch(int t, List<int> nums, int l, int r)
        {
            int mid = (l + r) / 2;
            if(r<l) return 0;
            if(l == mid && l == r) return mid+1;
            if (t >= nums[mid] && t < nums[mid+1]) return mid + 1;
            else if(t < nums[mid] && t >= nums[mid>0?mid - 1:r]) return mid;
            else if (t < nums[mid]) return BinarySearch(t, nums, l, mid-1);
            else return BinarySearch(t, nums, mid+1, r);
        }

        static List<int> Lis(string list)
        {
            List<int> l = new List<int>();

            string[] a = list.Split(' ');
            foreach (var item in a)

            {
                l.Add(Int(item));
            }
            return l;
        }
        static List<int> GetInts(string str)
        {
            string[] arr = str.Split(' ');
            List<int> list = new List<int>();
            for (int i = 0; i < arr.Length; i++)
            {
                list.Add(Int(arr[i]));
            }
            return list;
        }

        static List<long> GetLongs(string str)
        {
            string[] arr = str.Split(' ');
            List<long> list = new List<long>();
            for (int i = 0; i < arr.Length; i++)
            {
                list.Add(Long(arr[i]));
            }
            return list;
        }
        static long Long(string a)
        {
            return Int64.Parse(a);
        }

        static int Int(string a)
        {
            return Int32.Parse(a);
        }
    }
    public class P
    {
        public int x { get; set; }
        public int y { get; set; }
        public P(int a, int b)
        {
            x = a;
            y = b;
        }
    }
}


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

namespace ConsoleApplication1
{
    class Program
    {
        static int[] ReadInt(int size)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] res = new int[size];
            for (int i=0; i<input.Length; i++)
            {
                res[i] = Convert.ToInt32(input[i]);
            }
            return res;
        }

        static int ReadInt()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            return n;
        }

        static String ReadString()
        {
            return Console.ReadLine();
        }

        static int Max(int a, int b)
        {
            return (a > b ? a : b);
        }

        static void Main(string[] args)
        {
            String input = ReadString();
            String[] value = input.Split('+');
            Array.Sort(value);
            String res = "";
            foreach (String temp in value)
            {
                res += temp + "+";
            }
            res = res.Remove(res.Length - 1, 1);
            Console.WriteLine(res);
        }
    }
}


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

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

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

    struct Node
    {
        public int Index { get; set; }
        public double A { get; set; }
        public double T { get; set; }
    }

    static void program(TextReader input)
     {
        var n = double.Parse(reader.ReadLine().TrimEnd());
        var data = reader.ReadLine().TrimEnd();

        var possible = false;
        for(var i = 0; i < data.Length; i++)
        {
            if(data[i] == '1')
            {
                continue;
            } else
            {
                var prev = i > 0 ? data[i - 1] : '0';
                var next = i == n-1 ? '0' : data[i + 1];
                if (prev == '0' && next == '0')
                {
                    possible = true;
                }
            }
        }

        Console.WriteLine(!data.Contains("11") && !possible ? "Yes": "No");
    }

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

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

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

    }
}


using System;

namespace VaniaAndLight
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y, z, a, b, c;
            string[] arrayXYZ = Console.ReadLine().Split(new char[] { ' '}, StringSplitOptions.RemoveEmptyEntries);
            string[] arrayABC = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            x = int.Parse(arrayXYZ[0]);
            y = int.Parse(arrayXYZ[1]);
            z = int.Parse(arrayXYZ[2]);
            a = int.Parse(arrayABC[0]);
            b = int.Parse(arrayABC[1]);
            c = int.Parse(arrayABC[2]);

            if (x > a)
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                a -= x;
            }

            if (y > (a + b))
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                if (y - a > 0)
                {
                    y -= a;
                    a = 0;
                    b -= y;
                }
                else
                {
                    a -= y;
                }
            }

            if (z > (a + b + c))
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                Console.WriteLine("YES");
            }
        }

        static int rank(int key, int[] a)
        {
            int lo = 0;
            int hi = a.Length;

            while (lo <= hi)
            {
                int mid = lo + (hi - lo) / 2;
                if (key < a[mid])
                {
                    hi = mid - 1;
                }
                else if (key > a[mid])
                {
                    lo = mid + 1;
                }
                else
                {
                    return mid;
                }
            }
            return -1;
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    if (a[1] - a[0] == a[2] - a[1] && a[2]-a[1] == a[3] - a[2]){
      Console.Write(a[3] + a[2] - a[1]); return;
    }
    if (a[2]*a[0] == a[1]*a[1] && a[2]*a[2] == a[3]*a[1]) {
       var d = a[3]*a[3];
       if (d % a[2] == 0) {
       Console.Write(d/a[2]); return; }
    }
    Console.Write(42);
  }
}


using System;
using System.Linq;

class Program {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var x = Console.ReadLine().Split(' ').Select(int.Parse).Sum();
    var res = Enumerable.Range(1, 5).Count(i => (i + x) % (n+1) != 1);
    Console.WriteLine(res);
  }
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int res = 0;
            int count = 0;
            List<char> temp = new List<char>();
            for(int i = 0; i < s.Length; i++)
            {
                if(char.IsLower(s[i]))
                {
                    if (temp.Contains(s[i]))
                        continue;
                    else
                    {
                        temp.Add(s[i]);
                        count++;
                        if (count > res)
                            res = count;
                    }
                }
                else if(char.IsUpper(s[i]))
                {
                    count = 0;
                    temp.Clear();
                }
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int k = inp0[1];
            int[] a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> a = new List<int>(a1);
            int j = k-1;
            bool f = true;
            Array.Sort(b);
            for (int i = 0; i < n-1; i++)
            {
                if (a[i]>=a[i+1]&&a[i+1]!=0)
                {
                    f = false;
                    break;
                }
            }
            if (f)
            {

                for (int i = 0; i < n; i++)
                {
                    if (a[i] == 0)
                    {

                        a[i] = b[j];
                        j--;

                    }
                }

                for (int i = 0; i < n - 1; i++)
                {
                    if (a[i] >= a[i + 1])
                    {
                        f = false;
                        break;
                    }
                }
            }

            if (!f)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

namespace Contest
{
    class Program
    {

        static void Main()
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int n = a[0], p = a[1];
            for(int i=1; ; i++)
            {
                int k = n - i * p;
                if (k <= 0) { Console.WriteLine(-1); return; }
                if (check(k) <= i&&i<=k) { Console.WriteLine(i); return; }

            }

        }

        private static int check(int k)
        {
            int t = 0;
            while (k > 0)
            {
                if (k % 2 == 1) t++;
                k /= 2;
            }
            return t;
        }
    }
}


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

namespace ZODACHA
{
    class Program
    {
        class Sotr
        {
            public int number = 0;
            public int dolg = -1;
        }

        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');

            int n = Convert.ToInt32(line[0]);
            int m = Convert.ToInt32(line[1]);

            Console.WriteLine(n + m);
        }
    }
}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            long[] values = Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray();
            long target = values[0] * 6;
            var current = values[1] * values[2];
            var max = Math.Max(values[1], values[2]);
            if (current >= target)
            {
                Console.WriteLine(current);
                Console.WriteLine(values[1] + " " + values[2]);
                return;
            }

            var start = Math.Min(values[1], values[2]);
            var end = Math.Max(values[1], values[2]);
            bool isAFirst = values[1] < values[2];
            long minFound = long.MaxValue;
            long a=0, b=0;
            var root = (long)Math.Sqrt(target);
            for (long i = start; end <= target / i&&i<=root; i++)
            {
                long other = target / i + (target % i == 0 ? 0 : 1);
                var currentArea = i * other;
                if (currentArea < minFound)
                {
                    a = i;
                    b = other;
                    minFound = currentArea;
                }
                if (minFound == target)
                {
                    break;
                }

            }
            Console.WriteLine(minFound);
            if (isAFirst)
            {
                Console.WriteLine(a + " " + b);
            }
            else
            {
                Console.WriteLine(b + " " + a);
            }

        }
    }
}


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

public class Solver
{
    public object Solve()
    {
        int n = ReadInt();
        int m = ReadInt();

        int[] id = new int[m];
        int?[] status = new int?[n];

        int cand = -1;
        for (int i = 0; i < m; i++)
        {
            bool action = ReadToken() == "+";
            id[i] = ReadInt() - 1;
            if (status[id[i]] == null)
            {
                status[id[i]] = action ? 1 : 2;
                if (!action)
                    cand = id[i];
            }
        }
        if (cand == -1)
            cand = id[0];

        var set = new SortedSet<int>(Enumerable.Range(1, n).Where(i => status[i - 1] == null));
        bool[] on = Enumerable.Range(0, n).Select(i => status[i] == 2).ToArray();
        int onCount = status.Count(s => s == 2);
        int step;
        for (step = 0; step < m; step++)
        {
            if (id[step] == cand)
            {
                if (on[cand] && onCount > 1)
                    break;
            }
            else if (!on[cand])
                    break;
            on[id[step]] = !on[id[step]];
            if (on[id[step]])
                onCount++;
            else
                onCount--;
        }
        if (step == m)
            set.Add(cand + 1);

        writer.WriteLine(set.Count);
        WriteArray(set);

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

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

    #endregion

    #region Read/Write

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

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

    public static string ReadToken()
    {
        if (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 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.IO;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			try
			{
				Main main = new Main();
				main.ReadData();
				main.Process();
				main.WriteAnswer();
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}
		}
	}

	class Main
	{
		private int _y;
		private long _result;

		public void Process()
		{
			int day = 0;
			const int remCommon = 365 % 7;
			const int remHigh = 366 % 7;
			bool is_high = isHigh(_y);

			while (true)
			{
				_y++;
				if (isHigh(_y))
				{
					day = (day + remHigh) % 7;
				}
				else
				{
					day = (day + remCommon) % 7;
				}
				if (day == 0 && is_high == isHigh(_y))
				{
					break;
				}
			}
			_result = _y;
		}

		private bool isHigh(int year)
		{
			if (year%400 == 0 || (year%4 == 0 && year%100 != 0))
			{
				return true;
			}
			return false;
		}

		public void ReadData()
		{
			TextReader textReader = Console.In;
			//TextReader textReader = new StreamReader("input.txt");
			using (TextReader reader = textReader)
			{
				string readLine = reader.ReadLine();
				//string[] strings1 = readLine.Split(' ');

				_y = int.Parse(readLine);
			}
		}

		public void WriteAnswer()
		{
			using (TextWriter writer = Console.Out)
			{
				writer.WriteLine(_result);
			}
		}
	}
}


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

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

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

            return d.ToArray();
        }

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

            return result;
        }

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

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

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

            return lst;
        }

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

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

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

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

                return;
            }

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        static Stopwatch sw = Stopwatch.StartNew();

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

        struct Pos
        {
            public int X, Y;

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

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

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

        }

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

            long temp = 0;
            long count = 0;

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

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

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

            }

            Console.WriteLine(count);
        }
    }
}


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

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

            int a;
            int b;
            int c;

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

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

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


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

namespace Task
{

    #region MyIo

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

        private string[] tokens;
        private int pointer;

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

        }

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

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

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

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

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

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

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

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

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

            outputStream.WriteLine();
        }

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

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

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

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

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

        void IDisposable.Dispose()
        {
            Close();

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

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

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

            var n = self.Count;

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

            return self;
        }

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

            return self;
        }
    }

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

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

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

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

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

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

                    return tr;
                }
            }
        }

        public P()
        {
        }

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

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

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

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

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

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

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

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

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

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

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

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

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

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

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

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

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

            isb.Fill(-1);

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

            var res = 0;

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

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

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

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

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

            io.PrintLine(res);
        }
    }

}


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

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

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

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

            writer.Flush();
        }

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


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

public class CasketOfStar
{

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

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

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

        }

    }

}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] mas = new int[17];// = { 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 };
            mas[0]  = 0; //

            mas[1]  = 1; //+
            mas[2]  = 0; //+
            mas[3]  = 0; //+
            mas[4]  = 1; //+
            mas[5]  = 0; //+
            mas[6]  = 1; //+
            mas[7]  = 0; //+
            mas[8]  = 1; //+
            mas[9]  = 1; //+
            mas[10] = 1; //+
            mas[11] = 0; //+
            mas[12] = 0; //
            mas[13] = 1; //+
            mas[14] = 0; //
            mas[15] = 1; //+
            mas[16] = 0; //+

            int k = int.Parse(Console.ReadLine());
            Console.Write(mas[k]);
        }
    }
}


using System;
using System.Linq;

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

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

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


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

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

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

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

  #region Service classes

  public class Tokenizer
  {
    private readonly TextReader reader;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  #endregion
}


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

namespace Codeforces305_C
{

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

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

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

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

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

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

				io.Write(-1);
			}
		}

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

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

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

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

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

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

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

}


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

namespace CP_CS
{

    class Task
    {

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

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

        #region -- Main --

        private static TextReader reader;
        private static TextWriter writer;

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

        #endregion
        #region -- Read / Write --

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

*/

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

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

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
		string s;

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

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

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

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

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


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

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

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

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

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

            return x - 1;
        }
    }
}


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

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

			var gcd = Gcd(t, result);

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

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

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

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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


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

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

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