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

namespace Temp
{
    public class PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
        {
            this.X = x;
            this.Y = y;
        }

        public PointInt(PointInt head)
            : this(head.X, head.Y)
        {
        }

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

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

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }

        public bool Equals(PointInt other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return other.X == this.X && other.Y == this.Y;
        }

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

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

    public class Point2DReal
    {
        public double X;

        public double Y;

        public Point2DReal(double x, double y)
        {
            this.X = x;
            this.Y = y;
        }

        public Point2DReal(Point2DReal head)
            : this(head.X, head.Y)
        {
        }

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

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

        public static Point2DReal operator *(Point2DReal a, double k)
        {
            return new Point2DReal(k * a.X, k * a.Y);
        }

        public static Point2DReal operator *(double k, Point2DReal a)
        {
            return new Point2DReal(k * a.X, k * a.Y);
        }

        public double Dist(Point2DReal p)
        {
            return Math.Sqrt((p.X - X)*(p.X - X) + (p.Y - Y)*(p.Y - Y));
        }

        public bool IsInsideRectangle(double l, double b, double r, double t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    internal class LineInt
    {
        public LineInt(PointInt a, PointInt b)
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }

        public int Sign(PointInt p)
        {
            return Math.Sign(A * p.X + B * p.Y + C);
        }
    }

    internal static class Geometry
    {
        public static long VectInt(PointInt a, PointInt b)
        {
            return a.X * b.Y - a.Y * b.X;
        }

        public static long VectInt(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }
    }

    internal class MatrixInt
    {
        private readonly long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0);
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size,size];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            var size = matrix.GetLength(0);
            m_Matrix = new long[size,size];
            Array.Copy(matrix, m_Matrix, size * size);
            Mod = mod;

            if (mod != 0)
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        m_Matrix[i, j] %= mod;
                    }
                }
            }
        }

        public static MatrixInt IdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size,size];

            for (int i = 0; i < size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n,n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n,n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public void Print()
        {
            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    Console.Write("{0} ", m_Matrix[i, j]);
                }
                Console.WriteLine();
            }
        }
    }

    public static class Permutations
    {
        private static readonly Random m_Random;

        static Permutations()
        {
            m_Random = new Random();
        }

        public static int[] GetRandomPermutation(int n)
        {
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = i;
            }

            for (int i = n - 1; i > 0; i--)
            {
                int j = m_Random.Next(i + 1);
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }

            return p;
        }

        /*public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }*/

        /*public static T[] ShuffleSort<T>(this T[] array)
        {
            var result = array.Shuffle();
            Array.Sort(result);
            return result;
        }*/

        public static void Shuffle<T>(T[] array)
        {
            var n = array.Count();
            for (int i = n - 1; i > 0; i--)
            {
                int j = m_Random.Next(i + 1);
                T tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
            }
        }

        public static void ShuffleSort<T>(T[] array)
        {
            Shuffle(array);
            Array.Sort(array);
        }

        public static int[] Next(int[] p)
        {
            int n = p.Length;
            var next = new int[n];
            Array.Copy(p, next, n);

            int k = -1;
            for (int i = n - 1; i > 0; i--)
            {
                if (next[i - 1] < next[i])
                {
                    k = i - 1;
                    break;
                }
            }
            if (k == -1)
            {
                return null;
            }
            for (int i = n - 1; i >= 0; i--)
            {
                if (next[i] > next[k])
                {
                    var tmp = next[i];
                    next[i] = next[k];
                    next[k] = tmp;
                    break;
                }
            }
            for (int i = 1; i <= (n - k - 1) / 2; i++)
            {
                var tmp = next[k + i];
                next[k + i] = next[n - i];
                next[n - i] = tmp;
            }

            return next;
        }
    }

    internal static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = MatrixInt.IdentityMatrix(a.Size, a.Mod);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

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

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 1 }, { 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[1, 1];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long n, long mod)
        {
            long[] result = new long[n];
            result[1] = 1;
            for (int i = 2; i < n; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }

        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }

        public static int SumOfDigits(long x, long baseMod = 10)
        {
            int res = 0;
            while (x > 0)
            {
                res += (int)(x % baseMod);
                x = x / baseMod;
            }
            return res;
        }
    }

    internal static class Reader
    {
        public static void Read<T>(out T v1)
        {
            var values = new T[1];
            Read(values);
            v1 = values[0];
        }

        public static void Read<T>(out T v1, out T v2)
        {
            var values = new T[2];
            Read(values);
            v1 = values[0];
            v2 = values[1];
        }

        public static void Read<T>(out T v1, out T v2, out T v3)
        {
            var values = new T[3];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
        }

        public static void Read<T>(out T v1, out T v2, out T v3, out T v4)
        {
            var values = new T[4];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
            v4 = values[3];
        }

        public static void Read<T>(out T v1, out T v2, out T v3, out T v4, out T v5)
        {
            var values = new T[5];
            Read(values);
            v1 = values[0];
            v2 = values[1];
            v3 = values[2];
            v4 = values[3];
            v5 = values[4];
        }

        public static void Read<T>(T[] values)
        {
            Read(values, values.Length);
        }

        public static void Read<T>(T[] values, int count)
        {
// ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
// ReSharper restore PossibleNullReferenceException

            count = Math.Min(count, list.Length);

            var converter = TypeDescriptor.GetConverter(typeof(T));

            for (int i = 0; i < count; i++)
            {
                values[i] = (T)converter.ConvertFromString(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
            // ReSharper disable AssignNullToNotNullAttribute
            return Console.ReadLine().Select(x => int.Parse(x.ToString(CultureInfo.InvariantCulture))).ToArray();
            // ReSharper restore AssignNullToNotNullAttribute
        }

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

    public interface IGraph
    {
        bool IsOriented { get; set; }

        int Vertices { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);

        void AddNotOrientedEdge(int u, int v);
    }

    public class ListGraph : IGraph
    {
        private readonly List<int>[] m_Edges;

        public int Vertices { get; set; }

        public bool IsOriented { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public ListGraph(int vertices, bool isOriented = false)
        {
            this.Vertices = vertices;
            this.IsOriented = isOriented;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            if (!IsOriented)
            {
                this.AddOrientedEdge(v, u);
            }
        }

        public void AddNotOrientedEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    internal class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1,m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i - 1, j - 1];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r + 1, t + 1] - m_Sum[r + 1, b] - m_Sum[l, t + 1] + m_Sum[l, b];
        }
    }

    internal class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private readonly Func<T, T, T> m_Operation;

        private readonly T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(
                GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    internal class Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }

        protected bool Equals(Pair<TFirst, TSecond> other)
        {
            return EqualityComparer<TFirst>.Default.Equals(this.First, other.First) && EqualityComparer<TSecond>.Default.Equals(this.Second, other.Second);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != this.GetType())
            {
                return false;
            }
            return Equals((Pair<TFirst, TSecond>)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (EqualityComparer<TFirst>.Default.GetHashCode(this.First) * 397) ^ EqualityComparer<TSecond>.Default.GetHashCode(this.Second);
            }
        }
    }

    internal class FenwickTreeInt64
    {
        public FenwickTreeInt64(int size)
        {
            this.m_Size = size;
            m_Tree = new long[size];
        }

        public FenwickTreeInt64(int size, IList<long> tree)
            : this(size)
        {
            for (int i = 0; i < size; i++)
            {
                Inc(i, tree[i]);
            }
        }

        public long Sum(int r)
        {
            long res = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1)
            {
                res += m_Tree[r];
            }
            return res;
        }

        public long Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public void Inc(int i, long x)
        {
            for (; i < m_Size; i = i | (i + 1))
            {
                m_Tree[i] += x;
            }
        }

        public void Set(int i, long x)
        {
            Inc(i, x - Sum(i, i));
        }

        private readonly int m_Size;

        private readonly long[] m_Tree;
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get
            {
                return this.ContainsKey(key) ? base[key] : 0;
            }
            set
            {
                this.Add(key, value);
            }
        }
    }

    public class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable<T>)))
                {
                    m_Comparison = (a, b) => ((IComparable<T>)a).CompareTo(b);
                }
                else
                {
                    throw new ApplicationException("Add comparer");
                }
            }
            else
            {
                m_Comparison = comparison;
            }
        }

        public int Count { get; private set; }

        public void Enqueue(T item)
        {
            m_List.Add(item);
            m_Indexes.Add(item, this.Count);
            this.Count++;
            Up(this.Count);
        }

        public T Peek()
        {
            return m_List[0];
        }

        public T Dequeue()
        {
            if (this.Count > 0)
            {
                var result = m_List[0];

                Swap(0, this.Count - 1);
                m_Indexes.Remove(m_List[this.Count - 1]);
                m_List.RemoveAt(this.Count - 1);
                this.Count--;
                this.Down(1);

                return result;
            }
            throw new ApplicationException("Couldn't get element from empty queue");
        }

        public void Update(T item)
        {
            int index = m_Indexes[item];
            this.Up(index + 1);
        }

        private readonly List<T> m_List = new List<T>();

        private readonly Dictionary<T, int> m_Indexes = new Dictionary<T, int>();

        private readonly Comparison<T> m_Comparison;

        private void Up(int index)
        {
            while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)
            {
                this.Swap(index - 1, index / 2 - 1);

                index = index / 2;
            }
        }

        private void Down(int index)
        {
            while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0
                   || 2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)
            {
                if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)
                {
                    this.Swap(index - 1, 2 * index - 1);
                    index = 2 * index;
                }
                else
                {
                    this.Swap(index - 1, 2 * index);
                    index = 2 * index + 1;
                }
            }
        }

        private void Swap(int i, int j)
        {
            var tmp = m_List[i];
            m_List[i] = m_List[j];
            m_List[j] = tmp;

            m_Indexes[m_List[i]] = i;
            m_Indexes[m_List[j]] = j;
        }
    }

    public class DisjointSetUnion<T>
    {
        public DisjointSetUnion()
        {
            m_Parent = new Dictionary<T, T>();
            m_Rank = new Dictionary<T, int>();
        }

        public DisjointSetUnion(DisjointSetUnion<T> set)
        {
            m_Parent = new Dictionary<T, T>(set.m_Parent);
            m_Rank = new Dictionary<T, int>(set.m_Rank);
        }

        private readonly Dictionary<T, T> m_Parent;
        private readonly Dictionary<T, int> m_Rank;

        public int GetRank(T x)
        {
            return m_Rank[x];
        }

        public void MakeSet(T x)
        {
            m_Parent[x] = x;
            this.m_Rank[x] = 0;
        }

        public void UnionSets(T x, T y)
        {
            x = this.FindSet(x);
            y = this.FindSet(y);
            if (!x.Equals(y))
            {
                if (m_Rank[x] < m_Rank[y])
                {
                    T t = x;
                    x = y;
                    y = t;
                }
                m_Parent[y] = x;
                if (m_Rank[x] == m_Rank[y])
                {
                    m_Rank[x]++;
                }
            }
        }

        public T FindSet(T x)
        {
            if (x.Equals(m_Parent[x]))
            {
                return x;
            }
            return m_Parent[x] = this.FindSet(m_Parent[x]);
        }
    }

    internal class HamiltonianPathFinder
    {
        public static void Run()
        {
            int n, m;
            Reader.Read(out n, out m);
            List<int>[] a = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                int x, y;
                Reader.Read(out x, out y);
                a[x].Add(y);
                a[y].Add(x);
            }

            var rnd = new Random();

            bool[] v = new bool[n];
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = -1;
            }
            int first = rnd.Next(n);
            int cur = first;
            v[cur] = true;

            int count = 1;

            while (true)
            {
                var unb = a[cur].Where(u => !v[u]).ToList();
                int d = unb.Count;
                if (d > 0)
                {
                    int next = unb[rnd.Next(d)];
                    v[next] = true;
                    p[cur] = next;
                    cur = next;
                    count++;
                }
                else
                {
                    if (count  == n && a[cur].Contains(first))
                    {
                        p[cur] = first;
                        break;
                    }

                    d = a[cur].Count;
                    int pivot;
                    do
                    {
                        pivot = a[cur][rnd.Next(d)];
                    }
                    while (p[pivot] == cur);

                    int next = p[pivot];

                    int x = next;
                    int y = -1;
                    while (true)
                    {
                        int tmp = p[x];
                        p[x] = y;
                        y = x;
                        x = tmp;
                        if (y == cur)
                        {
                            break;
                        }
                    }
                    p[pivot] = cur;
                    cur = next;
                }
            }

            cur = first;
            do
            {
                Console.Write("{0} ", cur);
                cur = p[cur];
            }
            while (cur != first);
        }

        public static void WriteTest(int n)
        {
            Console.WriteLine("{0} {1}", 2 * n, 2 * (n - 1) + n);
            for (int i = 0; i < n - 1; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 2);
                Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 3);
                //Console.WriteLine("{0} {1}", 2 * i + 1, 2 * i + 2);
                //Console.WriteLine("{0} {1}", 2 * i, 2 * i + 3);
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("{0} {1}", 2 * i, 2 * i + 1);
            }
        }
    }

    internal class Backtrack<T> where T : class
    {
        public Backtrack(Func<T, IEnumerable<T>> generator)
        {
            this.m_Generator = generator;
        }

        public Dictionary<T, T> Generate(T startState)
        {
            var result = new Dictionary<T, T>();
            result.Add(startState, null);

            var queue = new Queue<T>();
            queue.Enqueue(startState);

            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                var next = m_Generator(current);
                foreach (var state in next)
                {
                    if (!result.ContainsKey(state))
                    {
                        result[state] = current;
                        queue.Enqueue(state);
                    }
                }
            }

            return result;
        }

        private Func<T, IEnumerable<T>> m_Generator;
    }

    public static class Utility
    {
        public static readonly int[] sx = new[] { 1, 0, -1, 0 };
        public static readonly int[] sy = new[] { 0, 1, 0, -1 };

        public static PointInt[] GenerateNeighbors(long x, long y)
        {
            var result = new PointInt[4];
            for (int i = 0; i < 4; i++)
            {
                result[i] = new PointInt(x + sx[i], y + sy[i]);
            }
            return result;
        }

        public static PointInt[] GenerateNeighbors(this PointInt p)
        {
            return GenerateNeighbors(p.X, p.Y);
        }

        public static List<PointInt> GenerateNeighborsWithBounds(long x, long y, int n, int m)
        {
            var result = new List<PointInt>(4);
            for (int i = 0; i < 4; i++)
            {
                var nx = x + sx[i];
                var ny = y + sy[i];
                if (0 <= nx && nx < n && 0 <= ny && ny < m)
                {
                    result.Add(new PointInt(nx, ny));
                }
            }
            return result;
        }

        public static List<PointInt> GenerateNeighborsWithBounds(this PointInt p, int n, int m)
        {
            return GenerateNeighborsWithBounds(p.X, p.Y, n, m);
        }
    }

    internal class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = new StreamReader("input.txt"); //File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = new StreamWriter("output.txt"); //File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

        private static void CloseFiles()
        {
            m_OutStream.Flush();

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

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

           // OpenFiles();

            var mainThread = new Thread(() => new Solution().Solve(), 50 * 1024 * 1024);
            mainThread.Start();
            mainThread.Join();

          //  CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            int n = 10;
            int[] a = new int[n];
            int[] b = new int[n];
            var s = Reader.ReadLine();
            foreach (var ch in s)
            {
                if (ch == '9')
                {
                    a[6]++;
                }
                else if (ch == '5')
                {
                    a[2]++;
                }
                else
                {
                    a[ch - '0']++;
                }
            }
            s = Reader.ReadLine();
            foreach (var ch in s)
            {
                if (ch == '9')
                {
                    b[6]++;
                }
                else if (ch == '5')
                {
                    b[2]++;
                }
                else
                {
                    b[ch - '0']++;
                }
            }
            var ans = int.MaxValue;
            for (int i = 0; i < n; i++)
            {
                if (a[i] > 0 && b[i] / a[i] < ans)
                {
                    ans = b[i] / a[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Collections.Generic;

namespace cf328b
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			char[] nums = Console.ReadLine().ToCharArray();;
			char[] digits = Console.ReadLine().ToCharArray();
			List<char> sn = new List<char>();

			List<char> sd = new List<char>();

			foreach (var num in nums) {
				if (num == '2' || num == '5')
					sn.Add('2');
				else
				if (num == '6' || num == '9')
					sn.Add('6');
				else
					sn.Add(num);
			}

			foreach (var num in digits) {
				if (num == '2' || num == '5')
					sd.Add('2');
				else
				if (num == '6' || num == '9')
					sd.Add('6');
				else
					sd.Add(num);
			}

			sn.Sort();
			sd.Sort();

			bool failed = false;
			int res = 0;
			do
			{
				foreach (var c in sn) {
					int i = sd.BinarySearch(c);
					if (i >= 0)
					{
						sd[i] = 'z';
						sd.Sort();
					}
					else failed = true;
				}
				if (!failed)
					res++;
			}while (!failed);

			Console.WriteLine(res);
		}
	}
}


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

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

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            string s = reader.ReadLine();
            string d = reader.ReadLine();

            var cnts = new int[10];
            foreach (char c in d)
            {
                cnts[c - '0']++;
            }
            var ss = new int[10];
            foreach (char c in s)
            {
                ss[c - '0']++;
            }
            cnts[2] += cnts[5];
            cnts[6] += cnts[9];
            ss[2] += ss[5];
            ss[6] += ss[9];
            ss[5] = 0;
            ss[9] = 0;
            int min = d.Length;
            for (int i = 0; i < 10; i++)
            {
                if (ss[i] > 0)
                {
                    min = Math.Min(min, cnts[i]/ss[i]);
                }
            }
            return min;
        }
    }
}


using System;

namespace AllProblems
{
    class _328B_SheldonAndIcePieces
    {
        public static void Run()
        {
            var t = ReadArray(Console.ReadLine().Trim());
            var s = ReadArray(Console.ReadLine().Trim());

            var min = int.MaxValue;
            for (var i = 0; i < 10; i++)
            {
                if(t[i] == 0) continue;
                if (s[i] == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
                var q = s[i]/t[i];
                if (q < min) min = q;
            }
            Console.WriteLine(min);
            Console.ReadLine();
        }

        static int[] ReadArray(string t)
        {
            var n = new int[10];
            foreach (var s in t)
            {
                switch (s)
                {
                    case '5':
                        n[2]++;
                        break;
                    case '9':
                        n[6]++;
                        break;
                    default:
                        n[s - 48]++;
                        break;
                }
            }

            return n;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            _328B_SheldonAndIcePieces.Run();
        }
    }
}


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

namespace CodeForces
{
    class R191_Test8_B
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();

            int[] a = new int[10];
            int[] b = new int[10];
            int[] c = new int[10];

            for (int i = 0; i < t.Length; i++)
                a[t[i]-'0']++;

            for (int i = 0; i < s.Length; i++)
                b[s[i] - '0']++;

            int n25 = b[2] + b[5];
            int n69 = b[6] + b[9];

            int max = 0;
            for (int i = 0; i <= n25; i++)
            {
                int j = n25 - i;
                for (int k = 0; k <= n69; k++)
                {
                    int m = n69 - k;
                    for (int d = 0; d < 10; d++)
                        c[d] = b[d];
                    c[2] = i; c[5] = j; c[6] = k; c[9] = m;
                    int min = 999;
                    for (int l = 0; l <= 9; l++)
                    {
                        if (a[l] > 0)
                            min = Math.Min(min, c[l] / a[l]);
                    }
                    max = Math.Max(max, min);
                }
            }

            Console.WriteLine(max);
        }
    }
}


using System;
using System.Collections.Generic;

namespace cf328b
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			char[] nums = Console.ReadLine().ToCharArray();;
			char[] digits = Console.ReadLine().ToCharArray();
			List<char> sn = new List<char>();

			List<char> sd = new List<char>();

			foreach (var num in nums) {
				if (num == '2' || num == '5')
					sn.Add('2');

				if (num == '6' || num == '9')
					sn.Add('6');
			}

			foreach (var num in digits) {
				if (num == '2' || num == '5')
					sd.Add('2');

				if (num == '6' || num == '9')
					sd.Add('6');
			}

			sn.Sort();
			sd.Sort();

			bool failed = false;
			int res = 0;
			do
			{
				foreach (var c in sn) {
					int i = sd.BinarySearch(c);
					if (i >= 0)
					{
						sd[i] = 'z';
						sd.Sort();
					}
					else failed = true;
				}
				if (!failed)
					res++;
			}while (!failed);

			Console.WriteLine(res);
		}
	}
}


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

namespace Graph
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            string str = Console.ReadLine();

            int res = 0;
            bool done = false;
            int n = str.Length;
            for (int i = 0; i < n; i++)
            {
                res = i;
                //Console.WriteLine(i + " " + str + " " + done + " " + n);
                if (!done)
                {
                    for (int j = 0; j < num.Length; j++)
                    {
                        if (num[j] == '9' || num[j] == '6')
                        {
                            if (str.IndexOf('9') != -1)
                            {
                                str = str.Remove(str.IndexOf('9'), 1);
                            }
                            else
                            {
                                if (str.IndexOf('6') != -1)
                                {
                                    str = str.Remove(str.IndexOf('6'), 1);
                                }
                                else
                                {
                                   // Console.WriteLine("Нет девятки и шестерки");
                                    done = true;
                                    Console.WriteLine(res);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (num[j] == '5' || num[j] == '2')
                            {
                                if (str.IndexOf('5') != -1)
                                {
                                    str = str.Remove(str.IndexOf('5'), 1);
                                }
                                else
                                {
                                    if (str.IndexOf('2') != -1)
                                    {
                                        str = str.Remove(str.IndexOf('2'), 1);
                                    }
                                    else
                                    {
                                        //Console.WriteLine("Нет двойки и пятерки");
                                        done = true;
                                        Console.WriteLine(res);
                                        return;
                                    }
                                }
                            }
                            else {
                                if (str.IndexOf(num[j]) != -1)
                                {
                                    str = str.Remove(str.IndexOf(num[j]), 1);
                                }
                                else {
                                    //Console.WriteLine("Нет " + num[j]);
                                    done = true;
                                    Console.WriteLine(res);
                                    return;
                                    //break;
                                }

                            }
                        }
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}


using System;

class Program
{

    static void Main()
    {
        Int64 n = Convert.ToInt64(Console.ReadLine());
        Int64[] a = new Int64[n];
        Int64[] f = new Int64[n];
        Int64 fcnt = 0;

        string str = Console.ReadLine();
        string[] words = str.Split(' ');

        for (Int64 i = 0; i < n; i++)
            a[i] = Convert.ToInt64(words[i]);

        for(Int64 i = 0, now = n-1; i < n; i++)
        {
            now += 7;
            now %= n;
            f[now] = i+1;
            if (now == n-1)
                break;
            fcnt++;
        }
        fcnt++;

        {
            Int64 l = 0;
            Int64 r = Convert.ToInt64(5e4 * 10e9);
            while(l+1 != r)
            {
                Int64 mid = (l + r) / 2;
                bool ok = true;
                for(Int64 i = 0; i < n; i++)
                {
                    Int64 cost = mid / n;
                    if ((i + 1) <= mid % n)
                        cost++;
                    Int64 disc = mid / (fcnt * 7);
                    if(7*f[i] <= mid % (7*fcnt))
                        disc++;
                    if(f[i] == 0)
                        disc = 0;
                    cost -= disc;
                    if (cost >= a[i])
                        ok = false;
                }

                if (ok)
                    l = mid;
                else
                    r = mid;
            }

            Console.WriteLine(((r-1) % n + 1).ToString());
        }

    }
}


using System;

class Program
{

    static void Main()
    {
        Int64 n = Convert.ToInt64(Console.ReadLine());
        Int64[] a = new Int64[n];
        Int64[] f = new Int64[n];
        Int64 fcnt = 0;

        string str = Console.ReadLine();
        string[] words = str.Split(' ');

        for (Int64 i = 0; i < n; i++)
            a[i] = Convert.ToInt64(words[i]);

        for(Int64 i = 0, now = n-1; i < n; i++)
        {
            now += 7;
            now %= n;
            f[now] = i;
            if (now == n-1)
                break;
            fcnt++;
        }

        {
            Int64 l = 0;
            Int64 r = Convert.ToInt64(5e4 * 10e9);
            while(l+1 != r)
            {
                Int64 mid = (l + r) / 2;
                bool ok = true;
                for(Int64 i = 0; i < n; i++)
                {
                    Int64 cost = mid / n;
                    if ((i + 1) <= mid % n)
                        cost++;
                    Int64 disc = mid / (7 * fcnt);
                    if(7*(f[i]+1) <= mid % (7*fcnt))
                        disc++;
                    cost -= disc;
                    if (cost >= a[i])
                        ok = false;
                }

                if (ok)
                    l = mid;
                else
                    r = mid;
            }

            Console.WriteLine(((r-1) % n + 1).ToString());
        }

    }
}


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

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

        private static void Main(string[] args)
        {
            int n = int.Parse(reader.ReadLine());

            var nn = new int[n][];
            int[][] t = Enumerable.Range(0, n).Select(e => nn[e] = new int[n]).ToArray();
            int[] t1 = Enumerable.Range(0, n).Select(e =>
                                                         {
                                                             string[] ss = reader.ReadLine().Split(' ');
                                                             int[] t3 = Enumerable.Range(0, n).Select(j => nn[e][j] = int.Parse(ss[j])).ToArray();
                                                             return 0;
                                                         }).ToArray();

            int[] t2 = Enumerable.Range(0, n).Select(k =>
                                                         {
                                                             int[] t4 = Enumerable.Range(0, n).Select(i =>
                                                                                {
                                                                                int[] t5 =
                                                                                Enumerable.Range(0, n).Select(j =>
                                                                                {
                                                                                nn
                                                                                [
                                                                                i
                                                                                ]
                                                                                [
                                                                                j
                                                                                ]
                                                                                =
                                                                                Math
                                                                                .
                                                                                Min
                                                                                (
                                                                                nn
                                                                                [
                                                                                i
                                                                                ]
                                                                                [
                                                                                j
                                                                                ],
                                                                                nn
                                                                                [
                                                                                i
                                                                                ]
                                                                                [
                                                                                k
                                                                                ] +
                                                                                nn
                                                                                [
                                                                                k
                                                                                ]
                                                                                [
                                                                                j
                                                                                ]);
                                                                                return
                                                                                0;
                                                                                })
                                                                                .ToArray();
                                                                                return 0;
                                                                                }).ToArray();
                                                             return 0;
                                                         }).ToArray();

            writer.WriteLine(Enumerable.Range(0, n).Select(i => nn[i].Max()).Max());
            writer.Flush();
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int n;
    int[][] a;
    void Fun(int i, int j, int k)
    {
        try
        {
            throw (i == n ? new ArgumentNullException() : new Exception());
        }
        catch (ArgumentNullException)
        {
            Fun(0, j + 1, k);
            return;
        }
        catch
        {
        }

        try
        {
            throw (j == n ? new ArgumentNullException() : new Exception());
        }
        catch (ArgumentNullException)
        {
            Fun(i, 0, k + 1);
            return;
        }
        catch
        {
        }

        try
        {
            throw (k == n ? new ArgumentNullException() : new Exception());
        }
        catch (ArgumentNullException)
        {
            return;
        }
        catch
        {
        }

        a[i][j] = Math.Min(a[i][j], a[i][k] + a[k][j]);
        Fun(i + 1, j, k);
    }

    void Solve()
    {
        //var reader = new StreamReader("..\\..\\input.txt");
        var reader = new StreamReader(Console.OpenStandardInput());

        n = int.Parse(reader.ReadLine());
        a = Enumerable.Range(0, n).Select(x => reader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray()).ToArray();

        Fun(0, 0, 0);
        Console.WriteLine(a.Max(aa => aa.Max()));
    }

    static void Main()
    {
        new Solver().Solve();
    }

}


using System;
using System.IO;
using System.Linq;
class E { static void Main() { new K(); } }
class K
{
	int F() { return int.Parse(Console.ReadLine()); }
	int[] G() { return Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray(); }
	public K()
	{
		var N = F();
		var loop = Enumerable.Range(0, N);
		var a = new int[N][];
		loop.Select(i =>
		{
			var I = G();
			a[i] = new int[N];
			loop.Select(j =>
			{
				a[i][j] = I[j]; return 0;
			}).ToArray(); return 0;
		}).ToArray();
		loop.Select(i =>
		{
			loop.Select(j =>
			{
				loop.Select(k =>
				{
					a[i][j] = Math.Min(a[i][j], a[i][k] + a[k][j]); return 0;
				}).ToArray();
				return 0;
			}).ToArray();
			return 0;
		}).ToArray();
		Console.WriteLine(a.Select(b => b.Max()).Max());
	}
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    bool Fun(int n, int m, int h, List<int> a)
    {
        int x = 0;
        while (x < n)
        {
            int y = x + 1;
            while (a[y] + m > h)
                y++;
            if (y == x + 1)
            {
                x++;
                continue;
            }

            bool f = true;
            int c = m - 1;
            for (int i = x + 1; i < y; i++)
            {
                if (a[i] + c > h)
                {
                    if (!f || a[i] > h)
                        return false;
                    c = Math.Min(c, h - a[i]);
                }

                if (c == 0)
                    f = false;
                if (f)
                    c--;
                else
                    c++;
            }

            x = y;
        }

        return true;
    }

    public void Solve()
    {
        for (int tt = ReadInt(); tt > 0; tt--)
        {
            int n = ReadInt() + 1;
            int m = ReadInt();
            int h = ReadInt();

            var a = new List<int> { int.MinValue };
            a.AddRange(ReadIntArray());
            a.Add(int.MinValue);

            Write(Fun(n, m, h, a) ? "Yes" : "No");
        }
    }

    #region Main

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

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}


//using MetadataExtractor;
//using MetadataExtractor.Formats.Exif;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

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

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        /*public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }*/

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

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

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static string Reverse(this string str)
        {
            if (str == null) return null;

            return new string(str.ToArray().Reverse().ToArray());
        }
        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target < a[mid])
                return FindRightMostLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindRightMostLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int target)
        {
            return FindRightMostLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {

            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static string GetSha1(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            using (BufferedStream bs = new BufferedStream(fs))
            {
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    byte[] hash = sha1.ComputeHash(bs);
                    StringBuilder formatted = new StringBuilder(2 * hash.Length);
                    foreach (byte b in hash)
                    {
                        formatted.AppendFormat("{0:X2}", b);
                    }

                    return formatted.ToString();
                }
            }
        }

        static bool canFit(int a1, int b1, int a2, int b2)
        {
            int[] r1 = { a1, b1 };
            int[] r2 = { a2, b2 };

            Array.Sort(r1);
            Array.Sort(r2);

            bool ans = (r1[0] <= r2[0]) && (r1[1] <= r2[1]);

            return ans;

        }

        class Pair
        {
            public int first { get; set; }
            public int second { get; set; }
        }

        class Coord
        {
            public int x;
            public int y;
            public double d;
        }

        public static double dist(int x1, int y1, int x2, int y2)
        {
            int dx = x2 - x1;
            int dy = y2 - y1;

            return Math.Sqrt(dx * dx + dy * dy);

        }
        static void Main(string[] args)
        {
            //Console.Out.Flush();

            int tt = ReadIntLine();

            while (tt-- > 0)
            {
                int n = 0, k = 0, l = 0;
                ReadInts(ref n, ref k, ref l);

                var d = ReadIntArrayLine();

                var safe = new int[d.Length];
                //var safe2 = new int[d.Length];

                bool bad = false;
                for (int i = 0; i < n; i++)
                {
                    safe[i] = Math.Min(l - d[i], k);
                    if (safe[i]<0)
                    {
                        bad = true;
                        break;
                    }
                }

                if (bad)
                {
                    PrintLn("NO");
                    continue;
                }

                int gs = -safe[n-1];
                int ge = -gs;
                bool pos = true;

                for (int i = n-2; i >=0; i--)
                {
                    if (safe[i]==k)
                    {
                        gs = -k;
                        ge = k;
                    }
                    else
                    {
                        gs--;
                        ge--;

                        if (gs.IsInRange(-safe[i],safe[i]) || ge.IsInRange(-safe[i], safe[i])
                            || (-safe[i]).IsInRange(gs,ge) || safe[i].IsInRange(gs,ge))
                        {
                            gs = Math.Max(gs, -safe[i]);
                            ge = Math.Min(ge, safe[i]);
                        }
                        else
                        {
                            pos = false;
                            break;
                        }
                    }

                }

                if (pos)
                    PrintLn("Yes");
                else
                    PrintLn("NO");

            } //while tt

        } //main
          //ReadInts(ref a, ref b);
          //int n = ReadIntLine();
          //int[] a = ReadIntArrayLine();
          // li.Sort((a, b) => b.CompareTo(a)); DESC

    }

}


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

using E = System.Linq.Enumerable;

internal partial class Solver {
    public void Run() {
        var t = ni();
        while (t-- > 0) {
            var n = ni();
            var k = ni();
            var l = ni();
            var d = ni(n);
            bool ans = true;
            bool increasing = false;
            int currentP = k + 1;
            foreach (var x in d) {
                // x + p <= l
                var maxP = l - x;
                if (maxP < 0) {
                    ans = false;
                    break;
                }
                if (maxP >= k) { // safe
                    currentP = k + 1;
                    increasing = false;
                } else {
                    // maxP < k
                    if (increasing) currentP++; else currentP--;
                    if (increasing) {
                        if (currentP > maxP) {
                            ans = false;
                            break;
                        }
                    } else {
                        currentP = Math.Min(currentP, maxP);
                        if (currentP == 0) increasing = true;
                    }
                }
            }
            cout.WriteLine(ans ? "Yes" : "No");
        }
    }

}

// PREWRITEN CODE BEGINS FROM HERE

static public class StringExtensions {
    static public string JoinToString<T>(this IEnumerable<T> source, string separator = " ") {
        return string.Join(separator, source);
    }
}

internal partial class Solver : Scanner {
    public static void Main() {
#if LOCAL
        byte[] inputBuffer = new byte[1000000];
        var inputStream = Console.OpenStandardInput(inputBuffer.Length);
        using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) {
            Console.SetIn(reader);
            new Solver(Console.In, Console.Out).Run();
        }
#else
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver(Console.In, Console.Out).Run();
        Console.Out.Flush();
#endif
    }

#pragma warning disable IDE0052
    private readonly TextReader cin;
    private readonly TextWriter cout;
    private readonly TextWriter cerr;
#pragma warning restore IDE0052

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        cin = reader;
        cout = writer;
        cerr = Console.Error;
    }

    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

#pragma warning disable IDE1006
#pragma warning disable IDE0051
    private int ni() { return NextInt(); }
    private int[] ni(int n) { return NextIntArray(n); }
    private long nl() { return NextLong(); }
    private long[] nl(int n) { return NextLongArray(n); }
    private double nd() { return NextDouble(); }
    private double[] nd(int n) { return NextDoubleArray(n); }
    private string ns() { return Next(); }
    private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}

#if DEBUG
internal static class LinqPadExtension {
    public static string TextDump<T>(this T obj) {
        if (obj is IEnumerable) return (obj as IEnumerable).Cast<object>().JoinToString().Dump();
        else return obj.ToString().Dump();
    }
    public static T Dump<T>(this T obj) {
        return LINQPad.Extensions.Dump(obj);
    }
}
#endif

public class Scanner {
    private readonly TextReader Reader;
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

    private readonly char[] buffer = new char[2 * 1024];
    private int cursor = 0, length = 0;
    private string Token;
    private readonly StringBuilder sb = new StringBuilder(1024);

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        Reader = reader;
    }

    public int NextInt() { return checked((int)NextLong()); }
    public long NextLong() {
        var s = Next();
        long r = 0;
        int i = 0;
        bool negative = false;
        if (s[i] == '-') {
            negative = true;
            i++;
        }
        for (; i < s.Length; i++) {
            r = r * 10 + (s[i] - '0');
#if DEBUG
            if (!char.IsDigit(s[i])) throw new FormatException();
#endif
        }
        return negative ? -r : r;
    }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        string[] array = new string[size];
        for (int i = 0; i < size; i++) {
            array[i] = Next();
        }

        return array;
    }
    public int[] NextIntArray(int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextInt();
        }

        return array;
    }

    public long[] NextLongArray(int size) {
        long[] array = new long[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextLong();
        }

        return array;
    }

    public double[] NextDoubleArray(int size) {
        double[] array = new double[size];
        for (int i = 0; i < size; i++) {
            array[i] = NextDouble();
        }

        return array;
    }

    public string Next() {
        if (Token == null) {
            if (!StockToken()) {
                throw new Exception();
            }
        }
        var token = Token;
        Token = null;
        return token;
    }

    public bool HasNext() {
        if (Token != null) {
            return true;
        }

        return StockToken();
    }

    private bool StockToken() {
        while (true) {
            sb.Clear();
            while (true) {
                if (cursor >= length) {
                    cursor = 0;
                    if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {
                        break;
                    }
                }
                var c = buffer[cursor++];
                if (33 <= c && c <= 126) {
                    sb.Append(c);
                } else {
                    if (sb.Length > 0) break;
                }
            }

            if (sb.Length > 0) {
                Token = sb.ToString();
                return true;
            }

            return false;
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 0; i < t; i++)
        {
            Solve();
        }
    }
    static void Solve()
    {
        var nkl = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nkl[0];
        var k = nkl[1]; //period
        var l = nkl[2]; //drawn limit
        var d = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //0   1          k-1  k  k+1
        //k, k-1, k-2, .. 1,  0,  1, ... k - 1
        long cur = 0;
        //ヤバい時にいられる場所まで駆け抜けられるか
        for (int i = 0; i < d.Length; i++)
        {
            if (d[i] + k <= l) cur = 0;
            else
            {
                cur++;
                var limit = l - d[i];
                if (limit + k < cur)
                {
                    Console.WriteLine("No");
                    return;
                }
                //wait until
                var firstPossible = k - limit;
                cur = Max(firstPossible, cur);
            }
        }
        Console.WriteLine("Yes");
    }
}


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

namespace codeforces
{
    public class Program
    {
        private const int MOD = 1000 * 1000 * 1000 + 7;
        private const int KMax = 40;

        private static int[,] C = new int[KMax + 1, KMax + 1];

        private static int Add(int x, int y)
        {
            x += y;
            if (x >= MOD)
            {
                x -= MOD;
            }
            return x;
        }

        private static int Mult(int x, int y)
        {
            return (int)(1L * x * y % MOD);
        }

        private static void MatrixMult(int[,] a, int[,] b, int[,] c, int n)
        {
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    c[i, j] = 0;
                    for (int k = 0; k < n; ++k)
                    {
                        c[i, j] = Add(c[i, j], Mult(a[i, k], b[k, j]));
                    }
                }
            }
        }

        private static void MatrixCopy(int[,] a, int[,] b, int n)
        {
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    b[i, j] = a[i, j];
                }
            }
        }

        private static void MatrixBinPow(int[,] a, int[,] result, int size, long n)
        {
            for (int i = 0; i < size; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    result[i, j] = i == j ? 1 : 0;
                }
            }
            var tmp = new int[size, size];

            while (n > 0)
            {
                if (n % 2 == 1)
                {
                    MatrixMult(result, a, tmp, size);
                    MatrixCopy(tmp, result, size);
                }

                MatrixMult(a, a, tmp, size);
                MatrixCopy(tmp, a, size);
                n /= 2;
            }
        }

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

            for (int i = 0; i <= KMax; ++i)
            {
                C[i, 0] = C[i, i] = 1;
                for (int j = 1; j < i; ++j)
                {
                    C[i, j] = Add(C[i - 1, j - 1], C[i - 1, j]);
                }
            }

            long n = Convert.ToInt64(values[0]);
            int k = Convert.ToInt32(values[1]);
            int size = 2 * k + 3;
            var A = new int[size, size];
            for (int i = 0; i < k; ++i)
            {
                int p = k - i;
                for (int j = 0; j < i; ++j)
                {
                    A[i, j] = 0;
                }
                for (int j = i; j < k + 1; ++j)
                {
                    A[i, j] = C[p, j - i];
                }
                for (int j = k + 1; j < k + i + 1; ++j)
                {
                    A[i, j] = 0;
                }
                for (int j = k + 1 + i, t = 0; j < 2 * k + 2; ++j, ++t)
                {
                    A[i, j] = 0;
                    for (int c = 0; c <= t; ++c)
                    {
                        A[i, j] = Add(A[i, j], Mult(C[p, c], C[p - c, t - c]));
                    }
                }
                A[i, size - 1] = 0;
            }
            for (int j = 0; j < size; ++j)
            {
                A[k, j] = j == k || j == (2 * k + 1) ? 1 : 0;
            }
            for (int i = k + 1; i < 2 * k + 2; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    A[i, j] = 0;
                }
                A[i, i - k - 1] = 1;
            }
            for (int j = 0; j < size; ++j)
            {
                A[size - 1, j] = 0;
            }
            A[size - 1, 0] = A[size - 1, size - 1] = 1;

            /*for (int i = 0; i < size; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    Console.Write(A[i, j]);
                    Console.Write(" ");
                }
                Console.WriteLine();
            }*/

            var result = new int[size, size];
            MatrixBinPow(A, result, size, n - 1);

            /*for (int i = 0; i < size; ++i)
            {
                for (int j = 0; j < size; ++j)
                {
                    Console.Write(result[i, j]);
                    Console.Write(" ");
                }
                Console.WriteLine();
            }*/

            int ans = 0;
            int tp = 2;

            for (int i = k; i >= 0; --i)
            {
                ans = Add(ans, Mult(result[size - 1, i], tp));
                tp = Mult(tp, 2);
            }
            for (int i = k + 1; i < size; ++i)
            {
                ans = Add(ans, result[size - 1, i]);
            }
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Linq;
using CompLib.Util;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.Text;
using CompLib.Mathematics;

public class Program
{
    int N;
    List<int>[] Div;

    int[] Sieve;

    int[] S;

    public void Solve()
    {

        var sc = new Scanner();
        N = sc.NextInt();
        Div = new List<int>[N + 1];
        for (int i = 1; i <= N; i++)
        {
            Div[i] = new List<int>();
        }

        for (int i = 1; i <= N; i++)
        {
            for (int j = i; j <= N; j += i)
            {
                Div[j].Add(i);
            }
        }

        S = new int[N + 1];
        S[1] = 0;
        for (int i = 2; i <= N; i++)
        {
            S[i] = i - 1;
            foreach (int d in Div[i])
            {
                if (i == d) continue;
                // Console.WriteLine($"{S[i / d]}");
                S[i] -= S[d];
            }
        }

        //for (int i = 1; i < 20; i++)
        //{
        //    Console.WriteLine($"{i} {F2(i)} {S[i]}");
        //}

        ModInt ans = 0;
        for (int c = 1; c + 2 <= N; c++)
        {
            int sumAB = N - c;
            foreach (int gcdAB in Div[sumAB])
            {
                int d = sumAB / gcdAB;

                // a + b = d
                // gcd(a,b) = 1

                ans += S[d] * MathEx.LCM(c, gcdAB);
            }
        }

        Console.WriteLine(ans);

    }
    ModInt F2(int n)
    {
        int cnt = 0;
        for (int a = 1; a + 1 <= n; a++)
        {
            cnt += MathEx.GCD(a, n - a) == 1 ? 1 : 0;
        }
        return cnt;
    }

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

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

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

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

            return isPrime;
        }
    }
    #endregion
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        public const long Mod = (int)1e9 + 7;
        // public const long Mod = 998244353;

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

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

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

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

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

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

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

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

            return _line[_index++];
        }

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

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

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

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