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

namespace ConsoleApplication1.CodeForces
{
    public class LowerBoundSortedSet<T> : SortedSet<T>
    {

        private ComparerDecorator<T> _comparerDecorator;

        private class ComparerDecorator<T> : IComparer<T>
        {

            private IComparer<T> _comparer;

            public T LowerBound { get; private set; }
            public T UpperBound { get; private set; }

            private bool _reset = true;

            public void Reset()
            {
                _reset = true;
            }

            public ComparerDecorator(IComparer<T> comparer)
            {
                _comparer = comparer;
            }

            public int Compare(T x, T y)
            {
                int num = _comparer.Compare(x, y);
                if (_reset)
                {
                    LowerBound = y;
                    UpperBound = y;
                }
                if (num >= 0)
                {
                    LowerBound = y;
                    _reset = false;
                }
                if (num <= 0)
                {
                    UpperBound = y;
                    _reset = false;
                }
                return num;
            }
        }

        public LowerBoundSortedSet()
            : this(Comparer<T>.Default) { }

        public LowerBoundSortedSet(IComparer<T> comparer)
            : base(new ComparerDecorator<T>(comparer))
        {
            _comparerDecorator = (ComparerDecorator<T>)this.Comparer;
        }

        public T FindLowerBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.LowerBound;
        }

        public T FindUpperBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.UpperBound;
        }
    }
    public abstract class Heap<T> : IEnumerable<T>
    {
        private const int InitialCapacity = 0;
        private const int GrowFactor = 2;
        private const int MinGrow = 1;

        private int _capacity = InitialCapacity;
        private T[] _heap = new T[InitialCapacity];
        private int _tail = 0;

        public int Count { get { return _tail; } }
        public int Capacity { get { return _capacity; } }

        protected Comparer<T> Comparer { get; private set; }
        protected abstract bool Dominates(T x, T y);

        protected Heap() : this(Comparer<T>.Default)
        {
        }

        protected Heap(Comparer<T> comparer) : this(Enumerable.Empty<T>(), comparer)
        {
        }

        protected Heap(IEnumerable<T> collection)
            : this(collection, Comparer<T>.Default)
        {
        }

        protected Heap(IEnumerable<T> collection, Comparer<T> comparer)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (comparer == null) throw new ArgumentNullException("comparer");

            Comparer = comparer;

            foreach (var item in collection)
            {
                if (Count == Capacity)
                    Grow();

                _heap[_tail++] = item;
            }

            for (int i = Parent(_tail - 1); i >= 0; i--)
                BubbleDown(i);
        }

        public void Add(T item)
        {
            if (Count == Capacity)
                Grow();

            _heap[_tail++] = item;
            BubbleUp(_tail - 1);
        }

        private void BubbleUp(int i)
        {
            if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))
                return; //correct domination (or root)

            Swap(i, Parent(i));
            BubbleUp(Parent(i));
        }

        public T GetMin()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            return _heap[0];
        }

        public T ExtractDominating()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            T ret = _heap[0];
            _tail--;
            Swap(_tail, 0);
            BubbleDown(0);
            return ret;
        }

        private void BubbleDown(int i)
        {
            int dominatingNode = Dominating(i);
            if (dominatingNode == i) return;
            Swap(i, dominatingNode);
            BubbleDown(dominatingNode);
        }

        private int Dominating(int i)
        {
            int dominatingNode = i;
            dominatingNode = GetDominating(YoungChild(i), dominatingNode);
            dominatingNode = GetDominating(OldChild(i), dominatingNode);

            return dominatingNode;
        }

        private int GetDominating(int newNode, int dominatingNode)
        {
            if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))
                return newNode;
            else
                return dominatingNode;
        }

        private void Swap(int i, int j)
        {
            T tmp = _heap[i];
            _heap[i] = _heap[j];
            _heap[j] = tmp;
        }

        private static int Parent(int i)
        {
            return (i + 1) / 2 - 1;
        }

        private static int YoungChild(int i)
        {
            return (i + 1) * 2 - 1;
        }

        private static int OldChild(int i)
        {
            return YoungChild(i) + 1;
        }

        private void Grow()
        {
            int newCapacity = _capacity * GrowFactor + MinGrow;
            var newHeap = new T[newCapacity];
            Array.Copy(_heap, newHeap, _capacity);
            _heap = newHeap;
            _capacity = newCapacity;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _heap.Take(Count).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public class MaxHeap<T> : Heap<T>
    {
        public MaxHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MaxHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) >= 0;
        }
    }

    public class MinHeap<T> : Heap<T>
    {
        public MinHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MinHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MinHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        public MinHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

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

        class Node
        {
            public int Number { get; set; }
            public int Depth { get; set; }

        }
        static long Distance(long x1, long y1, long x2, long y2)
        {
            return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
        }
        static void Main(String[] args)
        {
            //var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
            var x1 = data[0];
            var y1 = data[1];
            var x2 = data[2];
            var y2 = data[3];
            var x3 = data[4];
            var y3 = data[5];
            var d1 = Distance(x1, y1, x2, y2);
            var d2 = Distance(x2, y2, x3, y3);
            if (d1 == d2 && (y1-y2)* (x2 - x3) != (y2 - y3) * (x1 - x2))
            {
                writer.WriteLine("Yes");
            } else
            {
                writer.WriteLine("No");
            }

            writer.Flush();

        }
    }
}


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

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var x1 = sr.NextInt64();
            var y1 = sr.NextInt64();
            var x2 = sr.NextInt64();
            var y2 = sr.NextInt64();
            var x3 = sr.NextInt64();
            var y3 = sr.NextInt64();
            if (Cross(x1, y1, x2, y2, x3, y3) == 0) {
                sw.WriteLine("No");
                return;
            }
            sw.WriteLine("Yes");
        }

        private long Cross(long x1, long y1, long x2, long y2, long x, long y)
        {
            return (x1 - x) * (y2 - y) - (x2 - x) * (y1 - y);
        }

        ~Task()
        {
            Dispose(false);
        }

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

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

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

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    public class LowerBoundSortedSet<T> : SortedSet<T>
    {

        private ComparerDecorator<T> _comparerDecorator;

        private class ComparerDecorator<T> : IComparer<T>
        {

            private IComparer<T> _comparer;

            public T LowerBound { get; private set; }
            public T UpperBound { get; private set; }

            private bool _reset = true;

            public void Reset()
            {
                _reset = true;
            }

            public ComparerDecorator(IComparer<T> comparer)
            {
                _comparer = comparer;
            }

            public int Compare(T x, T y)
            {
                int num = _comparer.Compare(x, y);
                if (_reset)
                {
                    LowerBound = y;
                    UpperBound = y;
                }
                if (num >= 0)
                {
                    LowerBound = y;
                    _reset = false;
                }
                if (num <= 0)
                {
                    UpperBound = y;
                    _reset = false;
                }
                return num;
            }
        }

        public LowerBoundSortedSet()
            : this(Comparer<T>.Default) { }

        public LowerBoundSortedSet(IComparer<T> comparer)
            : base(new ComparerDecorator<T>(comparer))
        {
            _comparerDecorator = (ComparerDecorator<T>)this.Comparer;
        }

        public T FindLowerBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.LowerBound;
        }

        public T FindUpperBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.UpperBound;
        }
    }
    public abstract class Heap<T> : IEnumerable<T>
    {
        private const int InitialCapacity = 0;
        private const int GrowFactor = 2;
        private const int MinGrow = 1;

        private int _capacity = InitialCapacity;
        private T[] _heap = new T[InitialCapacity];
        private int _tail = 0;

        public int Count { get { return _tail; } }
        public int Capacity { get { return _capacity; } }

        protected Comparer<T> Comparer { get; private set; }
        protected abstract bool Dominates(T x, T y);

        protected Heap() : this(Comparer<T>.Default)
        {
        }

        protected Heap(Comparer<T> comparer) : this(Enumerable.Empty<T>(), comparer)
        {
        }

        protected Heap(IEnumerable<T> collection)
            : this(collection, Comparer<T>.Default)
        {
        }

        protected Heap(IEnumerable<T> collection, Comparer<T> comparer)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (comparer == null) throw new ArgumentNullException("comparer");

            Comparer = comparer;

            foreach (var item in collection)
            {
                if (Count == Capacity)
                    Grow();

                _heap[_tail++] = item;
            }

            for (int i = Parent(_tail - 1); i >= 0; i--)
                BubbleDown(i);
        }

        public void Add(T item)
        {
            if (Count == Capacity)
                Grow();

            _heap[_tail++] = item;
            BubbleUp(_tail - 1);
        }

        private void BubbleUp(int i)
        {
            if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))
                return; //correct domination (or root)

            Swap(i, Parent(i));
            BubbleUp(Parent(i));
        }

        public T GetMin()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            return _heap[0];
        }

        public T ExtractDominating()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            T ret = _heap[0];
            _tail--;
            Swap(_tail, 0);
            BubbleDown(0);
            return ret;
        }

        private void BubbleDown(int i)
        {
            int dominatingNode = Dominating(i);
            if (dominatingNode == i) return;
            Swap(i, dominatingNode);
            BubbleDown(dominatingNode);
        }

        private int Dominating(int i)
        {
            int dominatingNode = i;
            dominatingNode = GetDominating(YoungChild(i), dominatingNode);
            dominatingNode = GetDominating(OldChild(i), dominatingNode);

            return dominatingNode;
        }

        private int GetDominating(int newNode, int dominatingNode)
        {
            if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))
                return newNode;
            else
                return dominatingNode;
        }

        private void Swap(int i, int j)
        {
            T tmp = _heap[i];
            _heap[i] = _heap[j];
            _heap[j] = tmp;
        }

        private static int Parent(int i)
        {
            return (i + 1) / 2 - 1;
        }

        private static int YoungChild(int i)
        {
            return (i + 1) * 2 - 1;
        }

        private static int OldChild(int i)
        {
            return YoungChild(i) + 1;
        }

        private void Grow()
        {
            int newCapacity = _capacity * GrowFactor + MinGrow;
            var newHeap = new T[newCapacity];
            Array.Copy(_heap, newHeap, _capacity);
            _heap = newHeap;
            _capacity = newCapacity;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _heap.Take(Count).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public class MaxHeap<T> : Heap<T>
    {
        public MaxHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MaxHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) >= 0;
        }
    }

    public class MinHeap<T> : Heap<T>
    {
        public MinHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MinHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MinHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        public MinHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

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

        class Node
        {
            public int Number { get; set; }
            public int Depth { get; set; }

        }
        static double Distance(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        static void Main(String[] args)
        {
            //var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(double.Parse).ToList();
            var x1 = data[0];
            var y1 = data[1];
            var x2 = data[2];
            var y2 = data[3];
            var x3 = data[4];
            var y3 = data[5];
            if (Distance(x1,y1,x2,y2) == Distance(x2,y2,x3,y3))
            {
                writer.WriteLine("Yes");
            } else
            {
                writer.WriteLine("No");
            }

            writer.Flush();

        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    public class LowerBoundSortedSet<T> : SortedSet<T>
    {

        private ComparerDecorator<T> _comparerDecorator;

        private class ComparerDecorator<T> : IComparer<T>
        {

            private IComparer<T> _comparer;

            public T LowerBound { get; private set; }
            public T UpperBound { get; private set; }

            private bool _reset = true;

            public void Reset()
            {
                _reset = true;
            }

            public ComparerDecorator(IComparer<T> comparer)
            {
                _comparer = comparer;
            }

            public int Compare(T x, T y)
            {
                int num = _comparer.Compare(x, y);
                if (_reset)
                {
                    LowerBound = y;
                    UpperBound = y;
                }
                if (num >= 0)
                {
                    LowerBound = y;
                    _reset = false;
                }
                if (num <= 0)
                {
                    UpperBound = y;
                    _reset = false;
                }
                return num;
            }
        }

        public LowerBoundSortedSet()
            : this(Comparer<T>.Default) { }

        public LowerBoundSortedSet(IComparer<T> comparer)
            : base(new ComparerDecorator<T>(comparer))
        {
            _comparerDecorator = (ComparerDecorator<T>)this.Comparer;
        }

        public T FindLowerBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.LowerBound;
        }

        public T FindUpperBound(T key)
        {
            _comparerDecorator.Reset();
            this.Contains<T>(key);
            return _comparerDecorator.UpperBound;
        }
    }
    public abstract class Heap<T> : IEnumerable<T>
    {
        private const int InitialCapacity = 0;
        private const int GrowFactor = 2;
        private const int MinGrow = 1;

        private int _capacity = InitialCapacity;
        private T[] _heap = new T[InitialCapacity];
        private int _tail = 0;

        public int Count { get { return _tail; } }
        public int Capacity { get { return _capacity; } }

        protected Comparer<T> Comparer { get; private set; }
        protected abstract bool Dominates(T x, T y);

        protected Heap() : this(Comparer<T>.Default)
        {
        }

        protected Heap(Comparer<T> comparer) : this(Enumerable.Empty<T>(), comparer)
        {
        }

        protected Heap(IEnumerable<T> collection)
            : this(collection, Comparer<T>.Default)
        {
        }

        protected Heap(IEnumerable<T> collection, Comparer<T> comparer)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (comparer == null) throw new ArgumentNullException("comparer");

            Comparer = comparer;

            foreach (var item in collection)
            {
                if (Count == Capacity)
                    Grow();

                _heap[_tail++] = item;
            }

            for (int i = Parent(_tail - 1); i >= 0; i--)
                BubbleDown(i);
        }

        public void Add(T item)
        {
            if (Count == Capacity)
                Grow();

            _heap[_tail++] = item;
            BubbleUp(_tail - 1);
        }

        private void BubbleUp(int i)
        {
            if (i == 0 || Dominates(_heap[Parent(i)], _heap[i]))
                return; //correct domination (or root)

            Swap(i, Parent(i));
            BubbleUp(Parent(i));
        }

        public T GetMin()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            return _heap[0];
        }

        public T ExtractDominating()
        {
            if (Count == 0) throw new InvalidOperationException("Heap is empty");
            T ret = _heap[0];
            _tail--;
            Swap(_tail, 0);
            BubbleDown(0);
            return ret;
        }

        private void BubbleDown(int i)
        {
            int dominatingNode = Dominating(i);
            if (dominatingNode == i) return;
            Swap(i, dominatingNode);
            BubbleDown(dominatingNode);
        }

        private int Dominating(int i)
        {
            int dominatingNode = i;
            dominatingNode = GetDominating(YoungChild(i), dominatingNode);
            dominatingNode = GetDominating(OldChild(i), dominatingNode);

            return dominatingNode;
        }

        private int GetDominating(int newNode, int dominatingNode)
        {
            if (newNode < _tail && !Dominates(_heap[dominatingNode], _heap[newNode]))
                return newNode;
            else
                return dominatingNode;
        }

        private void Swap(int i, int j)
        {
            T tmp = _heap[i];
            _heap[i] = _heap[j];
            _heap[j] = tmp;
        }

        private static int Parent(int i)
        {
            return (i + 1) / 2 - 1;
        }

        private static int YoungChild(int i)
        {
            return (i + 1) * 2 - 1;
        }

        private static int OldChild(int i)
        {
            return YoungChild(i) + 1;
        }

        private void Grow()
        {
            int newCapacity = _capacity * GrowFactor + MinGrow;
            var newHeap = new T[newCapacity];
            Array.Copy(_heap, newHeap, _capacity);
            _heap = newHeap;
            _capacity = newCapacity;
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _heap.Take(Count).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    public class MaxHeap<T> : Heap<T>
    {
        public MaxHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MaxHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

        public MaxHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        protected override bool Dominates(T x, T y)
        {
            return Comparer.Compare(x, y) >= 0;
        }
    }

    public class MinHeap<T> : Heap<T>
    {
        public MinHeap()
            : this(Comparer<T>.Default)
        {
        }

        public MinHeap(Comparer<T> comparer)
            : base(comparer)
        {
        }

        public MinHeap(IEnumerable<T> collection) : base(collection)
        {
        }

        public MinHeap(IEnumerable<T> collection, Comparer<T> comparer)
            : base(collection, comparer)
        {
        }

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

        class Node
        {
            public int Number { get; set; }
            public int Depth { get; set; }

        }
        static double Distance(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        static void Main(String[] args)
        {
            //var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(double.Parse).ToList();
            var x1 = data[0];
            var y1 = data[1];
            var x2 = data[2];
            var y2 = data[3];
            var x3 = data[4];
            var y3 = data[5];
            if (Distance(x1,y1,x2,y2) == Distance(x2,y2,x3,y3) && (y1-y2)* (x1 - x3) != (y1 - y3) * (x1 - x2))
            {
                writer.WriteLine("Yes");
            } else
            {
                writer.WriteLine("No");
            }

            writer.Flush();

        }
    }
}


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

namespace Codeforces
{
#if _ONLINE_JUDGE_
	[OnlineJudge.Task("Codeforces 178D1")]
#endif
	class Task178D1
	{
		private InputTokenizer input = new InputTokenizer();
		private TextWriter output = Console.Out;

		int[,] tmpl;
		long[] partialSum;
		long s;
		long[] a;
		long[,] matrix;
		int n;

		private void Solve()
		{
			input.Line().Read(out n)
					 .Line().Read(n * n, out a);

			switch (n) {
				case 1:
					tmpl = new int[,] {
						{ 0, 0, g(new int[] { 0 }) },
					};
					break;

				case 2:
					tmpl = new int[,] {
						{ 0, 0, g(new int[] { }) },
						{ 0, 1, g(new int[] { 0 }) },
						{ 1, 0, g(new int[] { 2, 8 }) },
						{ 1, 1, g(new int[] { 1, 3, 5 }) }
					};
					break;

				case 3:
					tmpl = new int[,] {
						{ 0, 0, g(new int[] { }) },
						{ 0, 1, g(new int[] { }) },
						{ 0, 2, g(new int[] { 0 }) },
						{ 1, 0, g(new int[] { }) },
						{ 2, 0, g(new int[] { 3 }) },
						{ 1, 1, g(new int[] { 13 }) },
						{ 1, 2, g(new int[] { 1 }) },
						{ 2, 1, g(new int[] { 4 }) },
						{ 2, 2, g(new int[] { 2, 5, 8 }) }
					};
					break;

				case 4:
					tmpl = new int[,] {
						{ 0, 0, g(new int[] { }) },
						{ 0, 1, g(new int[] { }) },
						{ 0, 2, g(new int[] { }) },
						{ 0, 3, g(new int[] { 0 }) },

						{ 1, 0, g(new int[] { }) },
						{ 2, 0, g(new int[] { }) },
						{ 3, 0, g(new int[] { 4 }) },

						{ 1, 1, g(new int[] { }) },
						{ 1, 2, g(new int[] { }) },
						{ 2, 1, g(new int[] { 18 }) },

						{ 1, 3, g(new int[] { 1 }) },

						{ 3, 1, g(new int[] { 5 }) },

						{ 2, 2, g(new int[] { }) },
						{ 2, 3, g(new int[] { 2 }) },
						{ 3, 2, g(new int[] { 6 }) },
						{ 3, 3, g(new int[] { 3, 7, 11 }) }
					};
					break;
			}

			Array.Sort(a);

			long sum = a.Aggregate(0L, (x, y) => x + y);
			s = sum / n;
			partialSum = new long[30];

			matrix = new long[n, n];
			f(0);

			output.WriteLine(s);
			for (int i = 0; i < n; ++i) {
				output.Write(matrix[i, 0]);
				for (int j = 1; j < n; ++j)
					output.Write(" {0}", matrix[i, j]);
				output.WriteLine();
			}
		}

		private int g(int[] p)
		{
			int x = 0;
			foreach (var i in p) x |= 1 << i;
			return x;
		}

		private bool f(int i)
		{
			if (n * n == i) return true;

			for (int t = i; t < n * n; ++t)
				if (t == i || a[t] != a[t - 1]) {
					long h = a[i];
					a[i] = a[t];
					a[t] = h;

					int y = tmpl[i, 0], x = tmpl[i, 1], test = tmpl[i, 2];
					matrix[y, x] = a[i];
					partialSum[y] += a[i]; // |
					partialSum[x + n] += a[i]; // -
					partialSum[x - y + (n - 1) + n * 2] += a[i]; // \
					partialSum[x + y + n * 4 - 1] += a[i]; // /

					bool b = true;

					for (int z = 0; b && test != 0; ++z, test >>= 1)
						if ((test & 1) != 0 && partialSum[z] != s)
							b = false;

					if (!b) {
						partialSum[y] -= a[i]; // |
						partialSum[x + n] -= a[i]; // -
						partialSum[x - y + (n - 1) + n * 2] -= a[i]; // \
						partialSum[x + y + n * 4 - 1] -= a[i]; // /

						a[t] = a[i];
						a[i] = h;

						continue;
					}

					if (f(i + 1)) return true;

					partialSum[y] -= a[i]; // |
					partialSum[x + n] -= a[i]; // -
					partialSum[x - y + (n - 1) + n * 2] -= a[i]; // \
					partialSum[x + y + n * 4 - 1] -= a[i]; // /

					a[t] = a[i];
					a[i] = h;
				}

			return false;
		}

		public static void Main()
		{
			var obj = new Task178D1();
			obj.Solve();
		}

		#region
		private class InputTokenizer
		{
			private List<string> _tokens = new List<string>();
			private int _offset = 0;

			public InputTokenizer()
			{
			}

			public InputTokenizer String(String s)
			{
				_tokens.AddRange(s.Split(new char[] { ' ', '\n', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries));
				return this;
			}

			public InputTokenizer Line()
			{
				return String(Console.In.ReadLine());
			}

			public InputTokenizer Read(out int v)
			{
				v = int.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out int[] v)
			{
				v = new int[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out long v)
			{
				v = long.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out long[] v)
			{
				v = new long[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out ulong v)
			{
				v = ulong.Parse(_tokens[_offset++]);
				return this;
			}

			public InputTokenizer Read(int n, out ulong[] v)
			{
				v = new ulong[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out double v)
			{
				v = double.Parse(_tokens[_offset++].Replace('.', ','));
				return this;
			}

			public InputTokenizer Read(int n, out double[] v)
			{
				v = new double[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}

			public InputTokenizer Read(out string v)
			{
				v = _tokens[_offset++];
				return this;
			}

			public InputTokenizer Read(int n, out string[] v)
			{
				v = new string[n];
				for (int i = 0; i < n; ++i) Read(out v[i]);
				return this;
			}
		}
		#endregion
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Xsl;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			//string input3 = Console.ReadLine();
			//string input4 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();

			int n = int.Parse(input1);

			var copyN = n;
			var f = copyN / 36;
			copyN -= 36 * f;

			var d = copyN / 3;
			copyN -= 3 * d;
			if (copyN > 1)
			{
				d++;
			}

			while (d > 11)
			{
				d -= 12;
				f++;
			}

			Console.WriteLine($"{f} {d}");
		}

		public class Team
		{
			public string Name { get; set; }

			public int Points { get; set; }

			public int GoalsFor { get; set; }

			public int GoalsAgainst { get; set; }
		}

		static long Factorial(long a)
		{
			return a > 1 ? a * Factorial(a - 1) : 1;
		}
	}
}


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

namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a = n/36;
            int b = (n-a*36)/3;
            if ((n - a * 36) % 3 == 2) b++;
            if (b == 12) { a++; b = 0; }
            Console.WriteLine(a+" "+b);

        }
    }
}/*using System;
using System.Collections.Generic;
using System.Text;

namespace chislo
{
    class Program
    {
        static void Main(string[] args)
        {int sch = 0;
            string[] s = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(s[0]);
            long l1 = Convert.ToInt64(s[1]);
            long r1 = Convert.ToInt64(s[2]);
            List<long> l = new List<long>(); if (n == 0) Console.WriteLine(0);
            else
                if (n == 1)
                {
                    if (l1 <= 2 && r1 >= 2) Console.WriteLine(1);
                    else
                        Console.WriteLine(0);
                }
                else
            {
                for (int i = 0; n > 1; i++)
                {
                    l.Add(n); n /= 2;
                }
                string c = Convert.ToString(l[l.Count - 1] / 2);
                string c1 = Convert.ToString(l[l.Count - 1] % 2);
                string str = (c + c1 + c);
                for (int i = l.Count - 2; i >= 0; i--)
                {
                    c1 = Convert.ToString(l[i] % 2);
                    str += c1 + str;
                }
                Console.WriteLine(str);

                /*for (long i = l1 - 1; i < r1; i++)
                {
                    if (str[i] == '1') sch++;
                }
                 Console.WriteLine(str);
                Console.WriteLine(sch);

            }

        }
    }
}*/


using System;
 class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int res = n % 3;
            if (res == 2)
              n++;
            res = n / 36;
            n %= 36;
            Console.WriteLine("{0} {1}", res, n/3);

        }
    }


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

namespace Task
{
    class Program
    {
        void Solve()
        {
            // Place your code here
            int x = io.NextInt();

            int inch = x / 3;
            if (x % 3 == 2)
                inch++;

            int ft = inch / 12;
            inch %= 12;

            io.Print(ft + " " + inch);
        }

        MyIo io = new MyIo();

        static void Main(string[] args)
        {
            var p = new Program();

            p.Solve();
            p.io.Close();
        }
    }

    class MyIo
    {
        char[] separators = new char[] { ' ', '\t' };

#if TEST
        TextReader inputStream = new StreamReader("..\\..\\input.txt");
#else
        TextReader inputStream = System.Console.In;
#endif
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

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

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

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

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

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

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

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

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

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


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

namespace _111
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = Convert.ToInt32(Console.ReadLine());
            int a, b;
            a = n / 36;
            n -= a*36;
            b = n / 3;
            n -= b*3;
            if (n == 2)
                b++;
            if (b == 12)
            {
                b = 0;
                a++;
            }
            Console.Write(a);
            Console.Write(" ");
            Console.Write(b);
        }
    }
}


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

namespace Artyom
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int b = n / 36;
            n = n % 36;
            int a = n / 3;
            if (n % 3 > 1) a = a + 1;
            if (a == 12)
            { b += 1; a = 0; }
            Console.WriteLine(b + " " + a);
        }
    }
}


using System;

class Program {
    static void Main()  {
        int n = int.Parse(Console.ReadLine());

        int b = n%3 == 2? n/3 + 1 : n/3;
        int a = b/12;
        b %= 12;

        Console.WriteLine(a + " " + b);
    }
}


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

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

            int b = n/36;

            n %= 36;

            int c = n/3;
            if (n%3 == 2)
                c++;

            if (c == 12)
            {
                b++;
                c = 0;
            }

            writer.Write(b);
            writer.Write(' ');
            writer.Write(c);

            writer.Flush();
        }
    }
}


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

namespace Artyom
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a = n / 3;
            int b = a / 12;
            n = n - b*36;
            a = n / 3;
            if (n % 3 > 1) a = a + 1;
            Console.WriteLine(b + " " + a);
        }
    }
}


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

namespace Artyom
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int b = n / 36;
            n = n%36;
            int a = n / 3;
            if (n % 3 > 1) a = a + 1;
            Console.WriteLine(b + " " + a);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int d = 3;
            const int f = 36;
            double sm;
            sm =Convert.ToDouble(Console.ReadLine());
            double k = sm / f;
            double s = (k % 1) *12;
            Console.WriteLine(Convert.ToInt16(Math.Round(k)) + " " + Convert.ToInt16(Math.Round(s)));
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int d = 3;
            const int f = 36;
            double sm;
            sm =Convert.ToDouble(Console.ReadLine());
            double k = (sm / f)  ;
            double s = (k % 1) *12;
            Console.WriteLine(Convert.ToInt16((int) k) + " " + Convert.ToInt16(Math.Round(s)));
        }
    }
}


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

namespace Artyom
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int b = n / 36;
            n = n - b*36;
            int a = n / 3;
            if (n % 3 > 1) a = a + 1;
            Console.WriteLine(b + " " + a);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Xsl;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			//string input3 = Console.ReadLine();
			//string input4 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] {' ', '}', '{', ','}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs3 = input3.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs4 = input4.Split(new[] { ' ', '}', '{', ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();

			int n = int.Parse(input1);

			var copyN = n;
			var f = copyN / 36;
			copyN -= 36 * f;

			var d = copyN / 3;
			copyN -= 3 * d;
			if (copyN > 1)
			{
				d++;
			}

			Console.WriteLine($"{f} {d}");
		}

		public class Team
		{
			public string Name { get; set; }

			public int Points { get; set; }

			public int GoalsFor { get; set; }

			public int GoalsAgainst { get; set; }
		}

		static long Factorial(long a)
		{
			return a > 1 ? a * Factorial(a - 1) : 1;
		}
	}
}


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

namespace _111
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = Convert.ToInt32(Console.ReadLine());
            int a, b;
            a = n / 36;
            n -= a*36;
            b = n / 3;
            n -= b*3;
            if (n == 2)
                b++;
            Console.Write(a);
            Console.Write(" ");
            Console.Write(b);
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int d = 3;
            const int f = 36;
            double sm;
            sm =Convert.ToDouble(Console.ReadLine());
            double s = sm / d;
            double k = sm / f;

            sm = Math.Round(s);
            Console.WriteLine(Convert.ToInt16(Math.Round(k)) + " " +Convert.ToInt16(Math.Round(s)));

            sm = Console.Read();

        }
    }
}


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

namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a = n/36;
            int b = (n-a*36)/3;
            if ((n - a * 36) % 3 == 2) b++;
            Console.WriteLine(a+" "+b);

        }
    }
}/*using System;
using System.Collections.Generic;
using System.Text;

namespace chislo
{
    class Program
    {
        static void Main(string[] args)
        {int sch = 0;
            string[] s = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(s[0]);
            long l1 = Convert.ToInt64(s[1]);
            long r1 = Convert.ToInt64(s[2]);
            List<long> l = new List<long>(); if (n == 0) Console.WriteLine(0);
            else
                if (n == 1)
                {
                    if (l1 <= 2 && r1 >= 2) Console.WriteLine(1);
                    else
                        Console.WriteLine(0);
                }
                else
            {
                for (int i = 0; n > 1; i++)
                {
                    l.Add(n); n /= 2;
                }
                string c = Convert.ToString(l[l.Count - 1] / 2);
                string c1 = Convert.ToString(l[l.Count - 1] % 2);
                string str = (c + c1 + c);
                for (int i = l.Count - 2; i >= 0; i--)
                {
                    c1 = Convert.ToString(l[i] % 2);
                    str += c1 + str;
                }
                Console.WriteLine(str);

                /*for (long i = l1 - 1; i < r1; i++)
                {
                    if (str[i] == '1') sch++;
                }
                 Console.WriteLine(str);
                Console.WriteLine(sch);

            }

        }
    }
}*/


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

namespace The_Wall__medium_
{
    internal class Program
    {
        private const int mod = 1000003;
        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 long[] fact;
        private static long[] fact1;

        private static void Main(string[] args)
        {
            int n = Next();
            int c = Next();

            InitFact(n + c + 1);
            long ans = (GetCFact(n + c, c) - 1 + mod)%mod;

            writer.WriteLine(ans);
            writer.Flush();
        }

        private static void InitFact(int n)
        {
            fact = new long[n];
            fact1 = new long[n];

            fact[0] = 1;

            for (int i = 1; i < fact.Length; i++)
            {
                fact[i] = (fact[i - 1]*i)%mod;
            }
            fact1[n - 1] = Pow(fact[n - 1], mod - 2);
            for (int i = fact1.Length - 2; i >= 0; i--)
            {
                fact1[i] = (fact1[i + 1]*(i + 1))%mod;
            }
        }

        private static long Pow(long a, int k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a)%mod;
                }
                a = (a*a)%mod;
                k >>= 1;
            }
            return r;
        }

        private static long GetCFact(int n, int k)
        {
            return (((fact[n]*fact1[k])%mod)*fact1[n - k])%mod;
        }

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


#define Online

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

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

    class Program
    {

        static void Main(string[] args)
        {

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

            D();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {
            int n = ReadInt();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] tokens = ReadArray(' ');
                a[i] = int.Parse(tokens[0]);
                b[i] = int.Parse(tokens[1]);
            }
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                bool isHere = false;
                for (int j = 0; j < n; j++)
                {
                    if (i == j) continue;
                    if (b[j] == a[i])
                        isHere = true;
                }
                if (!isHere)
                    ans++;
            }
            Console.WriteLine(ans);
        }

        static void B()
        {
            int n, m;
            string[] tokens = ReadArray(' ');
            n = int.Parse(tokens[0]);
            m = int.Parse(tokens[1]);
            int[] a = new int[n];
            tokens = ReadArray(' ');
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(tokens[i]);

            int[] sum = new int[m + 1];
            int[] last = new int[n];
            StringBuilder ans = new StringBuilder();
            for (int i = 1; i <= m; i++)
            {
                sum[i] = sum[i - 1];
                tokens = ReadArray(' ');
                int t = int.Parse(tokens[0]);
                if (t == 1)
                {
                    int v = int.Parse(tokens[1]);
                    int x = int.Parse(tokens[2]);
                    a[v - 1] = x;
                    last[v - 1] = i;
                }
                if (t == 2)
                {
                    int y = int.Parse(tokens[1]);
                    sum[i] += y;
                }
                if (t == 3)
                {
                    int q = int.Parse(tokens[1]);
                    int val = a[q - 1] + (sum[i] - sum[last[q - 1]]);
                    ans.AppendLine(val.ToString());
                }
            }
            Console.Write(ans);
        }

        static void C()
        {
            long n, k;
            string[] tokens = ReadArray(' ');
            n = long.Parse(tokens[0]);
            k = long.Parse(tokens[1]);
            long[] a = new long[n + 1];
            tokens = ReadArray(' ');
            for (int i = 1; i <= n; i++)
            {
                a[i] = long.Parse(tokens[i - 1]);
            }
            StringBuilder ans = new StringBuilder();
            long cnt = 0;
            long cur = 0;
            long _d = 0;
            for (int i = 1; i <= n; i++)
            {
                _d = 0;
                _d -= (i - 1 - cnt) * ((n-cnt) - (i-cnt)) * a[i];
                _d += cur;
                if (_d < k)
                {
                    ans.AppendLine(i.ToString());
                    cnt++;
                }
                else
                {
                    cur += (i - cnt - 1) * a[i];
                }
            }
            Console.Write(ans);
        }

        static int FirstIndex(string a, string c, int i,int z, int j)
        {
            for (int k = 0; k < a.Length; k++, z++)
            {
                if (a[(i + z) % a.Length].Equals(c[j])) return (z + 1);
            }
            return -1;
        }

        static void D()
        {
            int b, d;
            string[] tokens = ReadArray(' ');
            b = int.Parse(tokens[0]);
            d = int.Parse(tokens[1]);
            string a = ReadLine();
            string c = ReadLine();

            int[] _cnt = new int[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                int z = 0;
                for (int j = 0; j < c.Length; j++)
                {
                    int m = FirstIndex(a, c, i, z, j);
                    if (m == -1)
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    z = m;
                }
                _cnt[i] = z;
            }

            int[] r = new int[a.Length];
            int[] __cnt = new int[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                int j = 0;
                for (int k = 0; k < d; j += _cnt[(i + j) % a.Length], k++)
                {
                    if (r[(i + j) % a.Length] > 0)
                    {
                        int dif = j - r[(i + j) % a.Length];
                        j += (d - k) * dif;
                        break;
                    }
                    r[(i + j) % a.Length] = j;
                    r = new int[a.Length];
                }
                __cnt[i] = j;
            }
            r = new int[a.Length];
            int[] _r = new int[a.Length];
            int p = 0;
            for (int j = 0; j < a.Length * b; )
            {
                if (r[j % a.Length] > 0)
                {
                    int dif = j - r[j % a.Length];
                    int _dif = p - _r[j % a.Length];
                    p += ((a.Length * b - j) / dif) * (_dif);
                    j += ((a.Length * b - j) / dif) * dif;
                    while (j + __cnt[j % a.Length] < a.Length * b)
                    {
                        p++;
                        j += __cnt[j % a.Length];
                    }
                    break;
                }
                r[j % a.Length] = j;
                _r[j % a.Length] = p;
                j += __cnt[j % a.Length];
                if (j < a.Length * b) p++;
            }
            Console.WriteLine(p);

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

        static string[] ReadArray(char sep)
        {
            return Console.ReadLine().Split(sep);
        }

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

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

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

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

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

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

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

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

    class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;
        public Stack<int> ans = new Stack<int>();
        public Graph(int n)
        {
            g = new List<int>[n + 1];
            for (int i = 0; i <= n; i++)
                g[i] = new List<int>();
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }

        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public bool DFS(int u, ref int time)
        {
            color[u] = gray;
            time++;
            o[u] = time;
            for (int i = 0; i < g[u].Count; i++)
            {
                int v = g[u][i];
                if (color[v] == gray)
                {
                    return true;
                }
                if (color[v] == white)
                {
                    p[v] = u;
                    if (DFS(v, ref time)) return true;
                }
            }
            color[u] = black;
            ans.Push(u);
            c[u] = time;
            time++;
            return false;
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static bool DFS(int u, ref int time, Graph g, Stack<int> st)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == gray)
                {
                    return true;
                }
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    if (DFS(v, ref time, g, st)) return true;
                }
            }
            g.color[u] = black;
            st.Push(u);
            g.c[u] = time;
            time++;
            return false;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }

    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

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

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

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

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


#define Online

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

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

    class Program
    {

        static void Main(string[] args)
        {

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

            D();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {
            int n = ReadInt();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] tokens = ReadArray(' ');
                a[i] = int.Parse(tokens[0]);
                b[i] = int.Parse(tokens[1]);
            }
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                bool isHere = false;
                for (int j = 0; j < n; j++)
                {
                    if (i == j) continue;
                    if (b[j] == a[i])
                        isHere = true;
                }
                if (!isHere)
                    ans++;
            }
            Console.WriteLine(ans);
        }

        static void B()
        {
            int n, m;
            string[] tokens = ReadArray(' ');
            n = int.Parse(tokens[0]);
            m = int.Parse(tokens[1]);
            int[] a = new int[n];
            tokens = ReadArray(' ');
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(tokens[i]);

            int[] sum = new int[m + 1];
            int[] last = new int[n];
            StringBuilder ans = new StringBuilder();
            for (int i = 1; i <= m; i++)
            {
                sum[i] = sum[i - 1];
                tokens = ReadArray(' ');
                int t = int.Parse(tokens[0]);
                if (t == 1)
                {
                    int v = int.Parse(tokens[1]);
                    int x = int.Parse(tokens[2]);
                    a[v - 1] = x;
                    last[v - 1] = i;
                }
                if (t == 2)
                {
                    int y = int.Parse(tokens[1]);
                    sum[i] += y;
                }
                if (t == 3)
                {
                    int q = int.Parse(tokens[1]);
                    int val = a[q - 1] + (sum[i] - sum[last[q - 1]]);
                    ans.AppendLine(val.ToString());
                }
            }
            Console.Write(ans);
        }

        static void C()
        {
            long n, k;
            string[] tokens = ReadArray(' ');
            n = long.Parse(tokens[0]);
            k = long.Parse(tokens[1]);
            long[] a = new long[n + 1];
            tokens = ReadArray(' ');
            for (int i = 1; i <= n; i++)
            {
                a[i] = long.Parse(tokens[i - 1]);
            }
            StringBuilder ans = new StringBuilder();
            long cnt = 0;
            long cur = 0;
            long _d = 0;
            for (int i = 1; i <= n; i++)
            {
                _d = 0;
                _d -= (i - 1 - cnt) * ((n-cnt) - (i-cnt)) * a[i];
                _d += cur;
                if (_d < k)
                {
                    ans.AppendLine(i.ToString());
                    cnt++;
                }
                else
                {
                    cur += (i - cnt - 1) * a[i];
                }
            }
            Console.Write(ans);
        }

        static int FirstIndex(string a, string c, int i,int z, int j)
        {
            for (int k = 0; k < a.Length; k++, z++)
            {
                if (a[(i + z) % a.Length].Equals(c[j])) return (z + 1);
            }
            return -1;
        }

        static void D()
        {
            int b, d;
            string[] tokens = ReadArray(' ');
            b = int.Parse(tokens[0]);
            d = int.Parse(tokens[1]);
            string a = ReadLine();
            string c = ReadLine();

            int[] _cnt = new int[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                int z = 0;
                for (int j = 0; j < c.Length; j++)
                {
                    int m = FirstIndex(a, c, i, z, j);
                    if (m == -1)
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    z = m;
                }
                _cnt[i] = z;
            }

            int[] r = new int[a.Length];
            int[] __cnt = new int[a.Length];
            for (int i = 0; i < a.Length; i++)
            {
                int j = 0;
                for (int k = 0; k < d; j += _cnt[(i + j) % a.Length], k++)
                {
                    if (r[(i + j) % a.Length] > 0)
                    {
                        int dif = j - r[(i + j) % a.Length];
                        j += (d - k) * dif;
                        break;
                    }
                    r[(i + j) % a.Length] = j;
                    r = new int[a.Length];
                }
                __cnt[i] = j;
            }
            r = new int[a.Length];
            int[] _r = new int[a.Length];
            int p = 0;
            for (int j = 0; j < a.Length * b; j += __cnt[j % a.Length], p++)
            {
                if (r[j % a.Length] > 0)
                {
                    int dif = j - r[j % a.Length];
                    int _dif = p - _r[j % a.Length];
                    p += ((a.Length * b - j) / dif) * (_dif);
                    break;
                }
                r[j % a.Length] = j;
                _r[j % a.Length] = p;
            }
            Console.WriteLine(p);

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

        static string[] ReadArray(char sep)
        {
            return Console.ReadLine().Split(sep);
        }

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

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

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

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

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

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

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

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

    class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;
        public Stack<int> ans = new Stack<int>();
        public Graph(int n)
        {
            g = new List<int>[n + 1];
            for (int i = 0; i <= n; i++)
                g[i] = new List<int>();
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }

        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public bool DFS(int u, ref int time)
        {
            color[u] = gray;
            time++;
            o[u] = time;
            for (int i = 0; i < g[u].Count; i++)
            {
                int v = g[u][i];
                if (color[v] == gray)
                {
                    return true;
                }
                if (color[v] == white)
                {
                    p[v] = u;
                    if (DFS(v, ref time)) return true;
                }
            }
            color[u] = black;
            ans.Push(u);
            c[u] = time;
            time++;
            return false;
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static bool DFS(int u, ref int time, Graph g, Stack<int> st)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == gray)
                {
                    return true;
                }
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    if (DFS(v, ref time, g, st)) return true;
                }
            }
            g.color[u] = black;
            st.Push(u);
            g.c[u] = time;
            time++;
            return false;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }

    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

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

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

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

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}