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

namespace Task
{

    #region MyIo

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

        private string[] tokens;
        private int pointer;

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

        }

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

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

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

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

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

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

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

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

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

            outputStream.WriteLine();
        }

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

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

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

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

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

        void IDisposable.Dispose()
        {
            Close();

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

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

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

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

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

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

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

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

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

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

                        return tr;
                    }
                }
            }

            public P()
            {
            }

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

            public T1 Key
            {
                get;
                set;
            }

            public T2 Value
            {
                get;
                set;
            }

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

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

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

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

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

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

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

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

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

            }
        }

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

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

            var fi = io.NextSeq<int>(n).ToArray();

            var g = new int[n][];
            var c = new int[n];

            var g1 = new int[n][];
            var c1 = new int[n];

            for (int i = 0; i < m; i++)
            {
                var from = io.NextInt() - 1;
                var to = io.NextInt() - 1;

                if (g[from] == null)
                    g[from] = new int[m];

                g[from][c[from]++] = to;

                if (g1[to] == null)
                    g1[to] = new int[m];

                g1[to][c1[to]++] = from;
            }

            var used = new bool[n];

            for (int i = 0; i < n; i++)
            {
                if (fi[i] == 1)
                    BFS(g, c, used, null, 0 , i);
            }

            var used1 = new bool[n];

            for (int i = 0; i < n; i++)
            {
                if (fi[i] == 2)
                    BFS(g1, c1, used1, fi, 1, i);
            }

            for (int i = 0; i < n; i++)
            {
                io.PrintLine((used[i] && used1[i]) ? "1":"0");
            }
        }

        public void BFS(int[][] g, int[] c, bool[] used, int[] fi, int ifi, int s)
        {

            var n = g.Length;

            used = used ?? new bool[n];

            if (used[s])
                return;

            Queue<int> q = new Queue<int>();
            q.Enqueue(s);

            used[s] = true;

            while (q.Count > 0)
            {
                int v = q.Dequeue();
                for (var i = 0; i < c[v]; ++i)
                {
                    var to = g[v][i];

                    if ((used[to])  && (fi != null && fi[n] == ifi))
                        continue;

                    used[to] = true;
                    q.Enqueue(to);
                }
            }
        }

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

            var n = list.Count;

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

    }

}


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

namespace Task
{

    #region MyIo

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

        private string[] tokens;
        private int pointer;

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

        }

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

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

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

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

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

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

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

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

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

            outputStream.WriteLine();
        }

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

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

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

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

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

        void IDisposable.Dispose()
        {
            Close();

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

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

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

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

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

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

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

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

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

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

                        return tr;
                    }
                }
            }

            public P()
            {
            }

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

            public T1 Key
            {
                get;
                set;
            }

            public T2 Value
            {
                get;
                set;
            }

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

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

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

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

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

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

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

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

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

            }
        }

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

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

            var fi = io.NextSeq<int>(n).ToArray();

            var g = new P<int, int>[m];
            var g1 = new P<int, int>[m];

            var sk = Enumerable.Range(0, m).ToArray();
            var sk1 = Enumerable.Range(0, m).ToArray();
            var c = new int[n + 1];
            var c1 = new int[n + 1];

            for (int i = 0; i < m; i++)
            {
                var from = io.NextInt() - 1;
                var to = io.NextInt() - 1;

                g[i] = P.Create(from , to);
                c[from + 1]++;
                g1[i] = P.Create(to, from);
                c1[to + 1]++;
            }

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

            Array.Sort(sk, (i, i1) => P<int, int>.KeyComparer.Compare(g[i], g[i1]));

            Array.Sort(sk1, (i, i1) => P<int, int>.KeyComparer.Compare(g1[i], g1[i1]));

            var used = new bool[n];
            var used1 = new bool[n];

            for (int i = 0; i < n; i++)
            {
                if (fi[i] == 1)
                    BFS(g, sk, c, used, null, 0 , i);
            }

            for (int i = 0; i < n; i++)
            {
                if (fi[i] == 2)
                    BFS(g1, sk1, c1, used1, fi, 1, i);
            }

            for (int i = 0; i < n; i++)
            {
                io.PrintLine((used[i] && used1[i]) ? "1":"0");
            }
        }

        public void BFS(P<int, int>[] g, int[] sk, int[] c, bool[] used, int[] fi, int ifi, int s)
        {

            var n = c.Length;

            used = used ?? new bool[n];

            if (used[s])
                return;

            Queue<int> q = new Queue<int>();
            q.Enqueue(s);

            used[s] = true;

            while (q.Count > 0)
            {
                int v = q.Dequeue();
                for (var i = c[v]; i < c[v + 1]; i++)
                {
                    var to = g[sk[i]].Value;

                    if (used[to])
                        continue;

                    used[to] = true;

                    if (fi != null && fi[to] == ifi)
                        continue;

                    q.Enqueue(to);
                }
            }
        }

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

            var n = list.Count;

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

    }

}


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

namespace Sign_Posts
{
    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 = Next();
            int k = Next();

            var a = new long[n];
            var b = new long[n];
            var c = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
                b[i] = Next();
                c[i] = Next();
            }

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

            var result = new List<Tuple<int, int>>();

            for (int kk = 0; kk < k; kk++)
            {
                if (remain.Count < 2)
                {
                    if (remain.Count == 1)
                    {
                        result.Add(new Tuple<int, int>(remain[0], -2));
                    }
                    remain.Clear();
                    break;
                }

                int max = Math.Min(remain.Count, 100);

                var list = new List<Point>();
                for (int ii = 0; ii < max; ii++)
                {
                    int i = remain[ii];
                    for (int jj = ii + 1; jj < max; jj++)
                    {
                        int j = remain[jj];
                        long l1 = a[i]*b[j] - a[j]*b[i];
                        if (l1 == 0)
                            continue;

                        long r1 = c[i]*b[j] - c[j]*b[i];
                        long r2 = c[i]*a[j] - c[j]*a[i];

                        list.Add(new Point(new Rational(-r1, l1), new Rational(-r2, -l1), i, j));
                    }
                }

                if (list.Count == 0)
                {
                    result.Add(new Tuple<int, int>(remain[remain.Count - 1], -2));
                    remain.RemoveAt(remain.Count - 1);
                }
                else
                {
                    max = 0;

                    list.Sort(list[0]);

                    int count = 1;
                    int mc = 1;
                    for (int i = 1; i < list.Count; i++)
                    {
                        if (list[i].Compare(list[i], list[i - 1]) == 0)
                        {
                            count++;
                        }
                        else
                        {
                            if (count > mc)
                            {
                                mc = count;
                                max = i - 1;
                            }
                            count = 1;
                        }
                    }

                    result.Add(new Tuple<int, int>(list[max]._i1, list[max]._i2));
                    var remain1 = new List<int>(n);

                    foreach (int i in remain)
                    {
                        if (a[i]*list[max].x.p*list[max].y.q + b[i]*list[max].y.p*list[max].x.q + c[i]*list[max].x.q*list[max].y.q != 0)
                        {
                            remain1.Add(i);
                        }
                    }

                    remain = remain1;
                }
            }

            if (remain.Count != 0)
            {
                writer.WriteLine("NO");
            }
            else
            {
                writer.WriteLine("YES");
                writer.WriteLine(result.Count);

                foreach (var tuple in result)
                {
                    writer.Write(tuple.Item1 + 1);
                    writer.Write(' ');
                    writer.WriteLine(tuple.Item2 + 1);
                }
            }
            writer.Flush();
        }

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

        #region Nested type: Point

        private class Point : IComparer<Point>
        {
            public readonly int _i1;
            public readonly int _i2;
            public readonly Rational x;
            public readonly Rational y;

            public Point(Rational x, Rational y, int i1, int i2)
            {
                this.x = x;
                this.y = y;
                _i1 = i1;
                _i2 = i2;
            }

            #region IComparer<Point> Members

            public int Compare(Point x, Point y)
            {
                int c = x.x.Compare(x.x, y.x);
                if (c == 0)
                    c = x.x.Compare(x.y, y.y);
                return c;
            }

            #endregion
        }

        #endregion

        #region Nested type: Rational

        private class Rational : IComparer<Rational>
        {
            public readonly long p;
            public readonly long q;

            public Rational(long p, long q)
            {
                long g = gcd(p, q);
                this.p = p/g;
                this.q = q/g;
            }

            #region IComparer<Rational> Members

            public int Compare(Rational x, Rational y)
            {
                return (x.p*y.q).CompareTo(x.q*y.p);
            }

            #endregion

            private long gcd(long a, long b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a%b);
            }
        }

        #endregion
    }
}


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

namespace Sign_Posts
{
    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 = Next();
            int k = Next();

            var a = new long[n];
            var b = new long[n];
            var c = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
                b[i] = Next();
                c[i] = Next();
            }

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

            var result = new List<Tuple<int, int>>();

            for (int kk = 0; kk < k; kk++)
            {
                if (remain.Count < 2)
                {
                    if (remain.Count == 1)
                    {
                        result.Add(new Tuple<int, int>(remain[0], -2));
                    }
                    remain.Clear();
                    break;
                }

                int max = Math.Min(remain.Count, 30);

                var list = new List<Point>();
                for (int ii = 0; ii < max; ii++)
                {
                    int i = remain[ii];
                    for (int jj = ii + 1; jj < max; jj++)
                    {
                        int j = remain[jj];
                        long l1 = a[i]*b[j] - a[j]*b[i];
                        if (l1 == 0)
                            continue;

                        long r1 = c[i]*b[j] - c[j]*b[i];
                        long r2 = c[i]*a[j] - c[j]*a[i];

                        list.Add(new Point(new Rational(-r1, l1), new Rational(-r2, -l1), i, j));
                    }
                }

                if (list.Count == 0)
                {
                    result.Add(new Tuple<int, int>(remain[remain.Count - 1], -2));
                    remain.RemoveAt(remain.Count - 1);
                }
                else
                {
                    max = 0;

                    list.Sort(list[0]);

                    int count = 1;
                    int mc = 1;
                    for (int i = 1; i < list.Count; i++)
                    {
                        if (list[i].Compare(list[i], list[i - 1]) == 0)
                        {
                            count++;
                        }
                        else
                        {
                            if (count > mc)
                            {
                                mc = count;
                                max = i - 1;
                            }
                            count = 1;
                        }
                    }

                    result.Add(new Tuple<int, int>(list[max]._i1, list[max]._i2));
                    var remain1 = new List<int>(n);

                    foreach (int i in remain)
                    {
                        if (a[i]*list[max].x.p*list[max].y.q + b[i]*list[max].y.p*list[max].x.q + c[i]*list[max].x.q*list[max].y.q != 0)
                        {
                            remain1.Add(i);
                        }
                    }

                    remain = remain1;
                }
            }

            if (remain.Count != 0)
            {
                writer.WriteLine("NO");
            }
            else
            {
                writer.WriteLine("YES");
                writer.WriteLine(result.Count);

                foreach (var tuple in result)
                {
                    writer.Write(tuple.Item1 + 1);
                    writer.Write(' ');
                    writer.WriteLine(tuple.Item2 + 1);
                }
            }
            writer.Flush();
        }

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

        #region Nested type: Point

        private class Point : IComparer<Point>
        {
            public readonly int _i1;
            public readonly int _i2;
            public readonly Rational x;
            public readonly Rational y;

            public Point(Rational x, Rational y, int i1, int i2)
            {
                this.x = x;
                this.y = y;
                _i1 = i1;
                _i2 = i2;
            }

            #region IComparer<Point> Members

            public int Compare(Point x, Point y)
            {
                int c = x.x.Compare(x.x, y.x);
                if (c == 0)
                    c = x.x.Compare(x.y, y.y);
                return c;
            }

            #endregion
        }

        #endregion

        #region Nested type: Rational

        private class Rational : IComparer<Rational>
        {
            public readonly long p;
            public readonly long q;

            public Rational(long p, long q)
            {
                long g = gcd(p, q);
                this.p = p/g;
                this.q = q/g;
            }

            #region IComparer<Rational> Members

            public int Compare(Rational x, Rational y)
            {
                return (x.p*y.q).CompareTo(x.q*y.p);
            }

            #endregion

            private long gcd(long a, long b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a%b);
            }
        }

        #endregion
    }
}


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

namespace Sign_Posts
{
    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 = Next();
            int k = Next();

            var a = new long[n];
            var b = new long[n];
            var c = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
                b[i] = Next();
                c[i] = Next();
            }

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

            var result = new List<Tuple<int, int>>();

            for (int kk = 0; kk < k; kk++)
            {
                if (remain.Count < 2)
                {
                    if (remain.Count == 1)
                    {
                        result.Add(new Tuple<int, int>(remain[0], -2));
                    }
                    remain.Clear();
                    break;
                }

                int max = Math.Min(remain.Count, 100);

                var list = new List<Point>();
                for (int i = 0; i < max; i++)
                {
                    for (int j = i + 1; j < max; j++)
                    {
                        long l1 = a[i]*b[j] - a[j]*b[i];
                        if (l1 == 0)
                            continue;

                        long r1 = c[i]*b[j] - c[j]*b[i];
                        long r2 = c[i]*a[j] - c[j]*a[i];

                        list.Add(new Point(new Rational(-r1, l1), new Rational(-r2, -l1), i, j));
                    }
                }

                if (list.Count == 0)
                {
                    result.Add(new Tuple<int, int>(remain[remain.Count - 1], -2));
                    remain.RemoveAt(remain.Count - 1);
                }
                else
                {
                    max = 0;

                    list.Sort(list[0]);

                    int count = 1;
                    int mc = 1;
                    for (int i = 1; i < list.Count; i++)
                    {
                        if (list[i].Compare(list[i], list[i - 1]) == 0)
                        {
                            count++;
                        }
                        else
                        {
                            if (count > mc)
                            {
                                mc = count;
                                max = i - 1;
                            }
                            count = 1;
                        }
                    }

                    result.Add(new Tuple<int, int>(list[max]._i1, list[max]._i2));
                    var remain1 = new List<int>(n);

                    foreach (int i in remain)
                    {
                        if (a[i]*list[max].x.p*list[max].y.q + b[i]*list[max].y.p*list[max].x.q + c[i]*list[max].x.q*list[max].y.q != 0)
                        {
                            remain1.Add(i);
                        }
                    }

                    remain = remain1;
                }
            }

            if (remain.Count != 0)
            {
                writer.WriteLine("NO");
            }
            else
            {
                writer.WriteLine("YES");
                writer.WriteLine(result.Count);

                foreach (var tuple in result)
                {
                    writer.Write(tuple.Item1 + 1);
                    writer.Write(' ');
                    writer.WriteLine(tuple.Item2 + 1);
                }
            }
            writer.Flush();
        }

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

        #region Nested type: Point

        private class Point : IComparer<Point>
        {
            public readonly int _i1;
            public readonly int _i2;
            public readonly Rational x;
            public readonly Rational y;

            public Point(Rational x, Rational y, int i1, int i2)
            {
                this.x = x;
                this.y = y;
                _i1 = i1;
                _i2 = i2;
            }

            #region IComparer<Point> Members

            public int Compare(Point x, Point y)
            {
                int c = x.x.Compare(x.x, y.x);
                if (c == 0)
                    c = x.x.Compare(x.y, y.y);
                return c;
            }

            #endregion
        }

        #endregion

        #region Nested type: Rational

        private class Rational : IComparer<Rational>
        {
            public readonly long p;
            public readonly long q;

            public Rational(long p, long q)
            {
                long g = gcd(p, q);
                this.p = p/g;
                this.q = q/g;
            }

            #region IComparer<Rational> Members

            public int Compare(Rational x, Rational y)
            {
                return (x.p*y.q).CompareTo(x.q*y.p);
            }

            #endregion

            private long gcd(long a, long b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a%b);
            }
        }

        #endregion
    }
}


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

namespace Sign_Posts
{
    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 = Next();
            int k = Next();

            var a = new long[n];
            var b = new long[n];
            var c = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
                b[i] = Next();
                c[i] = Next();
            }

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

            var result = new List<Tuple<int, int>>();

            for (int kk = 0; kk < k; kk++)
            {
                if (remain.Count < 3)
                {
                    if (remain.Count == 1)
                    {
                        result.Add(new Tuple<int, int>(remain[0], -2));
                    }
                    else if (remain.Count == 2)
                    {
                        result.Add(new Tuple<int, int>(remain[0], remain[1]));
                    }
                    remain.Clear();
                    break;
                }

                int max = Math.Min(remain.Count, 100);

                var list = new List<Point>();
                for (int i = 0; i < max; i++)
                {
                    for (int j = i + 1; j < max; j++)
                    {
                        long l1 = a[i]*b[j] - a[j]*b[i];
                        if (l1 == 0)
                            continue;

                        long r1 = c[i]*b[j] - c[j]*b[i];
                        long r2 = c[i]*a[j] - c[j]*a[i];

                        list.Add(new Point(new Rational(-r1, l1), new Rational(-r2, -l1), i, j));
                    }
                }

                if (list.Count == 0)
                {
                    result.Add(new Tuple<int, int>(remain[remain.Count - 1], -2));
                    remain.RemoveAt(remain.Count - 1);
                }
                else
                {
                    max = 0;

                    int count = 1;
                    int mc = 1;
                    for (int i = 1; i < list.Count; i++)
                    {
                        if (list[i].Compare(list[i], list[i - 1]) == 0)
                        {
                            count++;
                        }
                        else
                        {
                            if (count > mc)
                            {
                                mc = count;
                                max = i - 1;
                            }
                            count = 1;
                        }
                    }

                    result.Add(new Tuple<int, int>(list[max]._i1, list[max]._i2));
                    var remain1 = new List<int>(n);

                    foreach (int i in remain)
                    {
                        if (a[i]*list[max].x.p*list[max].y.q + b[i]*list[max].y.p*list[max].x.q + c[i]*list[max].x.q*list[max].y.q != 0)
                        {
                            remain1.Add(i);
                        }
                    }

                    remain = remain1;
                }
            }

            if (remain.Count != 0)
            {
                writer.WriteLine("NO");
            }
            else
            {
                writer.WriteLine("YES");
                writer.WriteLine(result.Count);

                foreach (var tuple in result)
                {
                    writer.Write(tuple.Item1 + 1);
                    writer.Write(' ');
                    writer.WriteLine(tuple.Item2 + 1);
                }
            }
            writer.Flush();
        }

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

        #region Nested type: Point

        private class Point : IComparer<Point>
        {
            public readonly int _i1;
            public readonly int _i2;
            public readonly Rational x;
            public readonly Rational y;

            public Point(Rational x, Rational y, int i1, int i2)
            {
                this.x = x;
                this.y = y;
                _i1 = i1;
                _i2 = i2;
            }

            #region IComparer<Point> Members

            public int Compare(Point x, Point y)
            {
                int c = x.x.Compare(x.x, y.x);
                if (c == 0)
                    c = x.x.Compare(x.y, y.y);
                return c;
            }

            #endregion
        }

        #endregion

        #region Nested type: Rational

        private class Rational : IComparer<Rational>
        {
            public readonly long p;
            public readonly long q;

            public Rational(long p, long q)
            {
                long g = gcd(p, q);
                this.p = p/g;
                this.q = q/g;
            }

            #region IComparer<Rational> Members

            public int Compare(Rational x, Rational y)
            {
                return (x.p*y.q).CompareTo(x.q*y.p);
            }

            #endregion

            private long gcd(long a, long b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a%b);
            }
        }

        #endregion
    }
}


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

class Prog
{
    public static void Main(String[] args)
    {
        int m1 = 0, m2;
        string s1, s2 = "";
        s1 = Console.ReadLine();
        switch (s1)
        {
            case "January"  : m1 = 1; break;
            case "February" : m1 = 2; break;
            case "March"    : m1 = 3; break;
            case "April"    : m1 = 4; break;
            case "May"      : m1 = 5; break;
            case "June"     : m1 = 6; break;
            case "July"     : m1 = 7; break;
            case "August"   : m1 = 8; break;
            case "September": m1 = 9; break;
            case "October"  : m1 = 10; break;
            case "November" : m1 = 11; break;
            case "December" : m1 = 12; break;
        }
        int i = Convert.ToInt32(Console.ReadLine());
        m2 = m1 + i;
        if (m2 > 12) { m2 -= 12; }
        switch (m2)
        {
            case 1: s2 = "January"; break;
            case 2: s2 = "February"; break;
            case 3: s2 = "March"; break;
            case 4: s2 = "April"; break;
            case 5: s2 = "May"; break;
            case 6: s2 = "June"; break;
            case 7: s2 = "July"; break;
            case 8: s2 = "August"; break;
            case 9: s2 = "September"; break;
            case 10: s2 = "October"; break;
            case 11: s2 = "November"; break;
            case 12: s2 = "December"; break;
        }
        Console.WriteLine(s2);
    }
}


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

namespace Contest
{
    class TheBoredomDivTwo
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            int n = 0;
            switch (s)
            {
                case "January": n = 1; break;
                case "February": n = 2; break;
                case "March": n = 3; break;
                case "April": n = 4; break;
                case "May": n = 5; break;
                case "June": n = 6; break;
                case "July": n = 7; break;
                case "August": n = 8; break;
                case "September": n = 9; break;
                case "October": n = 10; break;
                case "November": n = 11; break;
                case "December": n = 12; break;
            }

            n += k;
            string ans = "";
            n %= 12;
            switch (n)
            {
                case 1: ans = "January"; break;
                case 2:ans = "February"; break;
                case 3:ans = "March"; break;
                case 4:ans = "April"; break;
                case 5:ans = "May"; break;
                case 6:ans = "June"; break;
                case 7:ans = "July"; break;
                case 8:ans = "August"; break;
                case 9:ans = "September"; break;
                case 10:ans = "October"; break;
                case 11:ans = "November"; break;
                case 12:ans = "December"; break;
            }
            Console.WriteLine(ans);
        }
    }
}


using System;

class Program {
	public static void Main() {
#if DVORAK
		Console.SetIn(new System.IO.StreamReader("..\\..\\in.txt"));
#endif
		String[] mon = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };

		Console.WriteLine(mon[(Array.IndexOf(mon, Console.ReadLine()) + Int32.Parse(Console.ReadLine())) % mon.Length]);
	}
}


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

namespace A.Codecraft_III
{
    class Program
    {
        static void Main(string[] args)
        {
            string actualMonth = Console.ReadLine();
            int numberMonths = int.Parse(Console.ReadLine());
            List<string> months = new List<string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            int actual = (months.IndexOf(actualMonth) + numberMonths) % 12;
            Console.WriteLine(months[actual]);
            Console.ReadLine();
        }
    }
}


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

namespace ConsoleApplication1
{
    class P1
    {
        static void Main(string[] args)
        {
            var monthName = new[]
{
"January", "February", "March", "April", "May", "June", "July", "August", "September",
"October", "November", "December"
};
            var m = Console.ReadLine();
            for (var i = 0; i < monthName.Length; i++)
            {
                if (m != monthName[i]) continue;
                var c = Int32.Parse(Console.ReadLine());
                Console.WriteLine(monthName[(i + c) % 12]);
                return;
            }
        }

    }
}


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

namespace task45A
{
    class Program
    {

        static void Main(string[] args)
        {
            Dictionary<string, Int32> months = new Dictionary<string, Int32>();
            months.Add("January", 1);
            months.Add("February", 2);
            months.Add("March", 3);
            months.Add("April", 4);
            months.Add("May", 5);
            months.Add("June", 6);
            months.Add("July", 7);
            months.Add("August", 8);
            months.Add("September", 9);
            months.Add("October", 10);
            months.Add("November", 11);
            months.Add("December", 12);
            string month = Console.ReadLine();
            Int32 monthCount = Int32.Parse(Console.ReadLine());
            monthCount = (months[month] + monthCount) % 12;
            if (monthCount == 0)
            {
                monthCount = 12;
            }
            foreach (string key in months.Keys)
            {
                if (months[key] == monthCount)
                {
                    Console.WriteLine(key);
                    break;
                }
            }
            //Console.ReadLine();
        }
    }
}


using System;
using System.Linq;

namespace Task45A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            string currentMonth = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            int currentIndex = Array.IndexOf(months,currentMonth);
            currentIndex += k;
            currentIndex =  currentIndex % 12;

            Console.WriteLine(months[currentIndex]);
            //Console.ReadKey();
        }
    }
}


// Codecraft III - CodeForces
// Status: Unsolved

using System;

class Program {

  static Func<int> inp =
    () => int.Parse(Console.ReadLine());

  static Func<string> insr =
    () => Console.ReadLine();

  static string[] months = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };

  static int findInArray(string[] arr, string value) {
    for (int i = 0; i < arr.Length; i++) {
      string e = arr[i];
      if (e == value) return i;
    }
    return -1;
  }
  static int Main(string[] args) {
    int m = findInArray(months, insr());
    int k = (int) inp() % 12;
    // Console.WriteLine(m + " " + k);

    Console.WriteLine(m + k > 11 ? months[m + k - 12] : months[m + k]);

    return 0;
  }
}


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

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

            int n = Int32.Parse(Console.ReadLine());

            Dictionary<int, string> monthNumber = new Dictionary<int, string>()
            {
                {1, "January"},
                {2, "February"},
                {3, "March"},
                {4, "April"},
                {5, "May"},
                {6, "June"},
                {7, "July"},
                {8, "August"},
                {9, "September"},
                {10, "October"},
                {11, "November"},
                {12, "December"}
            };

            int m = monthNumber.Where(el => el.Value == str).Select(el => el.Key).First();

            int result = (n + m) % 12;

            if (result == 0)
            {
                Console.WriteLine("December");
            }
            else
            {
                string month = monthNumber.Where(el => el.Key == result).Select(el => el.Value).First();

                Console.WriteLine(month);
            }

        }
    }
}


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

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var months = new[]
                             {
                                 "January", "February", "March", "April", "May", "June", "July", "August", "September",
                                 "October", "November", "December"
                             };
            var m = Console.ReadLine();
            for (var i = 0; i < months.Length; i++)
            {
                if (m != months[i]) continue;
                var c = Int32.Parse(Console.ReadLine());
                Console.WriteLine(months[(i + c) % 12]);
                return;
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
namespace FREECASH
{
    class Program
    {
        static void Main(string[] args)
        {

            try
            {
                string month = Console.ReadLine();
                int k = int.Parse(Console.ReadLine());
                int cm = 0;
                string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
                for (int i = 0; i < 12; i++)
                {
                    if (month == months[i])
                        cm = i;
                }
                Console.Write(months[(cm+ k)%12]);

                Console.ReadKey();
            }
            catch { }
        }
    }
}


using System;

namespace Task_45A
{
    class Program
    {
        static void Main(string[] args)
        {
            string currentMonth = Console.ReadLine();
            int timeRemaining = int.Parse(Console.ReadLine());
            string[] months = { "January","February","March","April","May","June",
                           "July","August","September","October","November","December"};
            string ans = "";
            for(int i = 0; i < 12; i++)
            {
                if (months[i] == currentMonth)
                {
                    if (i + timeRemaining % 12 > 11)
                    {
                        ans = months[i + timeRemaining % 12 - 12];
                        break;
                    }

                    else
                    {
                        ans = months[i + timeRemaining % 12];
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace Task
{
    class Program
    {

        //public static void qsort(int[] m, int a, int b)
        //{
        //    if (a >= b) return;
        //    int i = a;
        //    for (int j = a; j <= b; j++)    // просматриваем с a по b
        //    {
        //        if (m[j] <= m[b])               // если элемент m[j] не превосходит m[b],
        //        {
        //            int t = m[i];                    // меняем местами m[j] и m[a], m[a+1], m[a+2] и так далее...
        //            m[i] = m[j];                 // то есть переносим элементы меньшие m[b] в начало,
        //            m[j] = t;                    // а затем и сам m[b] «сверху»
        //            i++;                         // таким образом последний обмен: m[b] и m[i], после чего i++
        //        }
        //    }

        //    qsort(m, a, i - 2);
        //    qsort(m, i, b);
        //}

        static void Main(string[] args)
        {

            string[] month = new string[12];
            month[0] = "January";
            month[1] = "February";
            month[2] = "March";
            month[3] = "April";
            month[4] = "May";
            month[5] = "June";
            month[6] = "July";
            month[7] = "August";
            month[8] = "September";
            month[9] = "October";
            month[10] = "November";
            month[11] = "December";
            string s = Console.ReadLine();
            int num = int.Parse(Console.ReadLine());
            for (int i = 0; i < 12; i++)
            {
                if (month[i] == s)
                {
                    num += i;
                    break;

                }
            }
            num = num % 12;
            Console.WriteLine(month[num]);
        }
     }
 }


using System;

namespace _45A
{
    class Program
    {
        static void Main(string[] args)
        {
            string current = Console.ReadLine();
            int N = int.Parse(Console.ReadLine());
            string[] months = { "January", "February", "March", "April", "May", "June",
                                              "July", "August", "September", "October", "November", "December" };

            int indexCurr = Array.IndexOf(months, current);
            Console.WriteLine(months[(indexCurr + N)%12]);
        }
    }
}
/*
 may-4 index
 24+4=28
 28%12

     */


using System;
using System.Collections.Generic;

namespace Lomonosov_1
{
	public class EmptyClass
	{
		public static void Main(string[] args)
		{
			String month = Console.ReadLine ();
			Months MonthO = Months.January;
			int n = Int32.Parse (Console.ReadLine ());

			if (month == "January")
				MonthO  = Months.January;
			if (month == "February")
				MonthO  = Months.February;
			if (month == "March")
				MonthO = Months.March;
			if (month == "April")
				MonthO  = Months.April;
			if (month == "May")
				MonthO  = Months.May;
			if (month == "June")
				MonthO = Months.June;
			if (month == "July")
				MonthO = Months.July;
			if (month == "August")
				MonthO = Months.August;
			if (month == "September")
				MonthO = Months.September;
			if (month == "October")
				MonthO = Months.October;
			if (month == "November")
				MonthO = Months.November;
			if (month == "December")
				MonthO = Months.December;

			Months Original = MonthO;
			MonthO += n;
			MonthO = MonthO - ((int) MonthO / 12) * 12;

			Console.WriteLine (MonthO);
		}

		enum Months{ January , February, March, April, May, June, July, August, September, October, November, December }
	}
}


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

namespace CR_111_A
{
    class Program
    {

        static void Main()
        {
            string[] months = {"January", "February", "March",
            "April", "May", "June", "July", "August",
            "September", "October", "November", "December"};
            string find = Console.ReadLine();
            int m = int.Parse(Console.ReadLine());
            if (m > 12)
                m = m % 12;
            int a = Array.IndexOf(months, find);
            a += m ;
            while (a > 11)
                a -= 12;
            Console.WriteLine(months[a]);

        }

    }
}


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

namespace Contest
{
    class TheBoredomDivTwo
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            int n = 0;
            switch (s)
            {
                case "January": n = 1; break;
                case "February": n = 2; break;
                case "March": n = 3; break;
                case "April": n = 4; break;
                case "May": n = 5; break;
                case "June": n = 6; break;
                case "July": n = 7; break;
                case "August": n = 8; break;
                case "September": n = 9; break;
                case "October": n = 10; break;
                case "November": n = 11; break;
                case "December": n = 12; break;
            }

            n += k;
            string ans = "";
            while (n > 12)
            {
                n -= 12;
            }
            switch (n)
            {
                case 1: ans = "January"; break;
                case 2: ans = "February"; break;
                case 3: ans = "March"; break;
                case 4: ans = "April"; break;
                case 5:ans = "May"; break;
                case 6:ans = "June"; break;
                case 7:ans = "July"; break;
                case 8:ans = "August"; break;
                case 9:ans = "September"; break;
                case 10:ans = "October"; break;
                case 11:ans = "November"; break;
                case 12:ans = "December"; break;
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace Codecraft_III
{
    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)
        {
            string name = reader.ReadLine();
            int k = int.Parse(reader.ReadLine());

            var array = new[]
                            {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

            int index = Array.IndexOf(array, name);
            index += k;
            index %= array.Length;

            writer.WriteLine(array[index]);
            writer.Flush();
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
namespace FREECASH
{
    class Program
    {
        static void Main(string[] args)
        {

            try
            {
                string month = Console.ReadLine();
                int k = int.Parse(Console.ReadLine());
                int cm = 0;
                string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
                for (int i = 0; i < 12; i++)
                {
                    if (month == months[i])
                        cm = i + 1;
                }
                Console.Write(months[(cm+ k)%12-1]);

                Console.ReadKey();
            }
            catch { }
        }
    }
}


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

namespace task45A
{
    class Program
    {

        static void Main(string[] args)
        {
            Dictionary<string, Int32> months = new Dictionary<string, Int32>();
            months.Add("January", 1);
            months.Add("February", 2);
            months.Add("March", 3);
            months.Add("April", 4);
            months.Add("May", 5);
            months.Add("June", 6);
            months.Add("July", 7);
            months.Add("August", 8);
            months.Add("September", 9);
            months.Add("October", 10);
            months.Add("November", 11);
            months.Add("December", 12);
            string month = Console.ReadLine();
            Int32 monthCount = Int32.Parse(Console.ReadLine());
            monthCount = (months[month] + monthCount) % 12;
            foreach (string key in months.Keys)
            {
                if (months[key] == monthCount)
                {
                    Console.WriteLine(key);
                    break;
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace Lomonosov_1
{
	public class EmptyClass
	{
		public static void Main(string[] args)
		{
			String month = Console.ReadLine ();
			Months Month = Months.January;
			int n = Int32.Parse (Console.ReadLine ());

			switch (month)
			{
			case "January":
				Month = Months.January;
				break;
			case "February":
				Month = Months.February;
				break;
			case "March":
				Month = Months.March;
				break;
			case "April":
				Month = Months.April;
				break;
			case "May":
				Month = Months.May;
				break;
			case "June":
				Month = Months.June;
				break;
			case "July":
				Month = Months.July;
				break;
			case "August":
				Month = Months.August;
				break;
			case "September":
				Month = Months.September;
				break;
			case "October":
				Month = Months.October;
				break;
			case "November":
				Month = Months.November;
				break;
			case "December ":
				Month = Months.December;
				break;
			}

			Month += n;
			Month = Month - ((int) Month / 12) * 12;

			Console.WriteLine (Month);
		}

		enum Months{ January = 0, February, March, April, May, June, July, August, September, October, November, December }
	}
}


using System;

class File {

  public static void Main ( String [] args ) {

    String[] months = new String [12];

months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

int thisMonth = 0;
switch ( Console.ReadLine() )
{
case "January":
thisMonth = 0;
break;
case "February":
thisMonth = 1;
break;
case "March":
thisMonth = 2;
break;
case "April":
thisMonth = 3;
break;
case "May":
thisMonth = 4;
break;
case "June":
thisMonth = 5;
break;
case "July":
thisMonth = 6;
break;
case "August":
thisMonth = 7;
break;
case "September":
thisMonth = 8;
break;
case "October":
thisMonth = 9;
break;
case "November":
thisMonth = 10;
break;
case "December":
thisMonth = 11;
break;
}

int k = Convert.ToInt32( Console.ReadLine() );

int last = thisMonth + k;

if ( last > 11 ) { last -= 12; }

Console.WriteLine(months[last]);

  }

}


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

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

            int n = Int32.Parse(Console.ReadLine());

            Dictionary<int, string> monthNumber = new Dictionary<int, string>()
            {
                {1, "January"},
                {2, "February"},
                {3, "March"},
                {4, "April"},
                {5, "May"},
                {6, "June"},
                {7, "July"},
                {8, "August"},
                {9, "September"},
                {10, "October"},
                {11, "November"},
                {12, "December"}
            };

            int m = monthNumber.Where(el => el.Value == str).Select(el => el.Key).First();

            int result = (n + m) % 12;

            string month = monthNumber.Where(el => el.Key == result).Select(el => el.Value).First();

            Console.WriteLine(month);
        }
    }
}


using System;
using System.Collections.Generic;

namespace Lomonosov_1
{
	public class EmptyClass
	{
		public static void Main(string[] args)
		{
			String month = Console.ReadLine ();
			Months Month = Months.January;
			int n = Int32.Parse (Console.ReadLine ());

			switch (month)
			{
			case "January":
				Month = Months.January;
				break;
			case "February":
				Month = Months.February;
				break;
			case "March":
				Month = Months.March;
				break;
			case "April":
				Month = Months.April;
				break;
			case "May":
				Month = Months.May;
				break;
			case "June":
				Month = Months.June;
				break;
			case "July":
				Month = Months.July;
				break;
			case "August":
				Month = Months.August;
				break;
			case "September":
				Month = Months.September;
				break;
			case "October":
				Month = Months.October;
				break;
			case "November":
				Month = Months.November;
				break;
			case "December ":
				Month = Months.December;
				break;
			}

			Month += n;
			Month = Month - ((int) Month / 12) * 12;

			Console.WriteLine (Month);
			Console.ReadKey (true);
		}

		enum Months{ January = 0, February, March, April, May, June, July, August, September, October, November, December }
	}
}


using System;

class File {

  public static void Main ( String [] args ) {

    String[] months = new String [12];

months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

int thisMonth = 0;
String buf = Console.ReadLine()
switch ( buf )
{
case "January":
thisMonth = 0;
break;
case "February":
thisMonth = 1;
break;
case "March":
thisMonth = 2;
break;
case "April":
thisMonth = 3;
break;
case "May":
thisMonth = 4;
break;
case "June":
thisMonth = 5;
break;
case "July":
thisMonth = 6;
break;
case "August":
thisMonth = 7;
break;
case "September":
thisMonth = 8;
break;
case "October":
thisMonth = 9;
break;
case "November":
thisMonth = 10;
break;
case "December":
thisMonth = 11;
break;
}

int k = Convert.ToInt32( Console.ReadLine() );

int last = thisMonth + k;

if ( last > 11 ) { last -= 12; }

Console.WriteLine(months[last]);

  }

}


using System;

class File {

  public static void Main ( String [] args ) {

    String[] months = new String [12];

months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

int thisMonth = 0;
String buf = Console.ReadLine()
switch ( buf )
{
case buf == "January":
thisMonth = 0;
break;
case buf == "February":
thisMonth = 1;
break;
case buf == "March":
thisMonth = 2;
break;
case buf == "April":
thisMonth = 3;
break;
case buf == "May":
thisMonth = 4;
break;
case buf == "June":
thisMonth = 5;
break;
case buf == "July":
thisMonth = 6;
break;
case buf == "August":
thisMonth = 7;
break;
case buf == "September":
thisMonth = 8;
break;
case buf == "October":
thisMonth = 9;
break;
case buf == "November":
thisMonth = 10;
break;
case buf == "December":
thisMonth = 11;
break;
}

int k = Convert.ToInt32( Console.ReadLine() );

int last = thisMonth + k;

if ( last > 11 ) { last -= 12; }

Console.WriteLine(months[last]);

  }

}


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

namespace bla2
{
    class Program
    {
        static void Main()
        {
            //Random rand = new Random();

            string[] s = Console.ReadLine().Split();
            l = long.Parse(s[0]);
            r = long.Parse(s[1]);
            x = long.Parse(s[2]);
            y = long.Parse(s[3]);
            //while (true)
            {
                Solve();
                //x = rand.Next(1, 1000000000);
                //y = x * rand.Next(1, 1000000000 / (int)x);
                //l = rand.Next(1, 1000000000);
                //r = rand.Next(1, 1000000000);
            }
        }

        static void Solve()
        {
            List<long> yfactors = Factor(y);
            yf = new List<long>();
            long x2 = x;
            long f = -1;
            for (int i = 0; i < yfactors.Count; i++)
            {
                if (x2 % yfactors[i] == 0)
                {
                    x2 /= yfactors[i];
                }
                else if (yf.Count != 0 && yfactors[i] == f)
                {
                    yf[yf.Count - 1] *= yfactors[i];
                }
                else
                {
                    yf.Add(yfactors[i]);
                    f = yfactors[i];
                }
            }
            if (x2 != 1)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(Count(new bool[yf.Count], 0));
            }
        }

        static long x, y, r, l;
        static List<long> yf;

        public static long Count(bool[] b, long at)
        {
            if(at == b.Length)
            {
                //Console.WriteLine(string.Join(", ", b));
                long n = x, m = x;
                for (int i = 0; i < b.Length; i++)
                {
                    if (b[i])
                        n *= yf[i];
                    else
                        m *= yf[i];
                }
                if (n <= r && n >= l && m <= r && m >= l)
                {
                    //Console.WriteLine(n + ", " + m);
                    return 1;
                }
                else
                    return 0;
            }
            long e = 0;
            bool[] nb = new bool[b.Length];
            Array.Copy(b, nb, b.Length);
            nb[at] = false;
            e += Count(nb, at + 1);
            nb[at] = true;
            e += Count(nb, at + 1);
            return e;
        }

        public static List<long> Factor(long n)
        {
            List<long> r = new List<long>();

            while (n % 2 == 0)
            {
                n /= 2;
                r.Add(2);
            }
            while (n % 3 == 0)
            {
                n /= 3;
                r.Add(3);
            }

            long sqrtn = (long)(Math.Sqrt(n)) + 1;
            long i = 6;
            while (n > 1 && i <= sqrtn)
            {
                bool nc = false;
                long a;
                while ((a = n % (i - 1)) == 0)
                {
                    r.Add(i - 1);
                    n /= i - 1;
                    nc = true;
                }
                while ((a = n % (i + 1)) == 0)
                {
                    r.Add(i + 1);
                    n /= i + 1;
                    nc = true;
                }
                i += 6;
                if (nc)
                    sqrtn = (long)(Math.Sqrt(n)) + 1;
            }
            if (n != 1) r.Add(n);
            return r;
        }
    }
}


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

namespace Nastya_Studies_Informatics
{
    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)
        {
            int l = Next(), r = Next(), x = Next(), y = Next();

            if (y%x != 0)
                return 0;

            y /= x;
            l = (l + x - 1)/x;
            r /= x;

            int ans = 0;
            for (int i = Math.Max(1, l); i <= r; i++)
            {
                if (i*i > y)
                    break;

                if (y%i == 0)
                {
                    int z = y/i;
                    int g = Gcd(i, z);
                    if (g == 1)
                    {
                        if (z <= r)
                            ans += 2;
                        if (z == i)
                            ans--;
                    }
                }
            }
            return ans;
        }

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

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


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

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      if (y % x != 0)
      {
        Console.WriteLine(0);
        return;
      }

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      //divs.Add(1);
      div = (1 << divs.Count) - 1;
      for (i = 0; i <= div; i++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
        while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
          }
          ind -= 1;
          j >>= 1;
        }
        int div2 = yx / div1;
        if (InRange(l, r, div1 * x) && InRange(l, r, div2 * x))
          ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}


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

namespace bla2
{
    class Program
    {
        static void Main()
        {
            Random rand = new Random();

            string[] s = Console.ReadLine().Split();
            l = long.Parse(s[0]);
            r = long.Parse(s[1]);
            x = long.Parse(s[2]);
            y = long.Parse(s[3]);
            //while (true)
            {
                Solve();
                //x = rand.Next(1, 1000000000);
                //y = rand.Next(1, 1000000000);
                //l = rand.Next(1, 1000000000);
                //r = rand.Next(1, 1000000000);
            }
        }

        static void Solve()
        {
            List<long> yfactors = Factor(y);
            yf = new List<long>();
            long x2 = x;
            for (int i = 0; i < yfactors.Count; i++)
            {
                if (x2 % yfactors[i] == 0)
                {
                    x2 /= yfactors[i];
                }
                else if (yf.Count != 0 && yfactors[i] == yfactors[i - 1])
                {
                    yf[yf.Count - 1] *= yfactors[i];
                }
                else
                {
                    yf.Add(yfactors[i]);
                }
            }
            if (x2 != 1)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(Count(new bool[yf.Count], 0));
            }
        }

        static long x, y, r, l;
        static List<long> yf;

        public static long Count(bool[] b, long at)
        {
            if(at == b.Length)
            {
                long n = x, m = x;
                for (int i = 0; i < b.Length; i++)
                {
                    if (b[i])
                        n *= yf[i];
                    else
                        m *= yf[i];
                }
                if (n <= r && n >= l && m <= r && m >= l)
                {
                    //Console.WriteLine(n + ", " + m);
                    return 1;
                }
                else
                    return 0;
            }
            long e = 0;
            bool[] nb = new bool[b.Length];
            Array.Copy(b, nb, b.Length);
            nb[at] = false;
            e += Count(nb, at + 1);
            nb[at] = true;
            e += Count(nb, at + 1);
            return e;
        }

        public static List<long> Factor(long n)
        {
            List<long> r = new List<long>();

            while (n % 2 == 0)
            {
                n /= 2;
                r.Add(2);
            }
            while (n % 3 == 0)
            {
                n /= 3;
                r.Add(3);
            }

            long sqrtn = (long)(Math.Sqrt(n)) + 1;
            long i = 6;
            while (n > 1 && i <= sqrtn)
            {
                bool nc = false;
                long a;
                while ((a = n % (i - 1)) == 0)
                {
                    r.Add(i - 1);
                    n /= i - 1;
                    nc = true;
                }
                while ((a = n % (i + 1)) == 0)
                {
                    r.Add(i + 1);
                    n /= i + 1;
                    nc = true;
                }
                i += 6;
                if (nc)
                    sqrtn = (long)(Math.Sqrt(n)) + 1;
            }
            if (n != 1) r.Add(n);
            return r;
        }
    }
}


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

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      if (y % x != 0)
      {
        Console.WriteLine(0);
        return;
      }

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      divs.Add(1);
      div = 1 << (divs.Count - 1);
      for (i = 1; i <= div; i ++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
          while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
            ind -= 1;
          }
          j >>= 1;
        }
        int div2 = yx / div1;
        if (InRange(l, r, div1 * x) && InRange(l, r, div2 * y))
          ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}


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

namespace bla2
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            l = long.Parse(s[0]);
            r = long.Parse(s[1]);
            x = long.Parse(s[2]);
            y = long.Parse(s[3]);
            List<long> yfactors = Factor(y);
            yf = new List<long>();
            for (int i = 0; i < yfactors.Count; i++)
            {
                if(i != 0 && yfactors[i] == yfactors[i - 1])
                {
                    yf[yf.Count - 1] *= yfactors[i];
                }
                else
                {
                    yf.Add(yfactors[i]);
                }
            }
            Console.WriteLine(Count(new bool[yf.Count], 0));
        }

        static long x, y, r, l;
        static List<long> yf;

        public static long Count(bool[] b, long at)
        {
            if(at == b.Length)
            {
                long n = x, m = x;
                for (int i = 0; i < b.Length; i++)
                {
                    if (b[i])
                        n *= yf[i];
                    else
                        m *= yf[i];
                }
                if (n <= r && n >= l && m <= r && m >= l)
                {
                    return 1;
                }
                else
                    return 0;
            }
            long e = 0;
            bool[] nb = new bool[b.Length];
            Array.Copy(b, nb, b.Length);
            nb[at] = false;
            e += Count(nb, at + 1);
            nb[at] = true;
            e += Count(nb, at + 1);
            return e;
        }

        public static List<long> Factor(long n)
        {
            List<long> r = new List<long>();

            while (n % 2 == 0)
            {
                n /= 2;
                r.Add(2);
            }
            while (n % 3 == 0)
            {
                n /= 3;
                r.Add(3);
            }

            long sqrtn = (long)(Math.Sqrt(n)) + 1;
            long i = 6;
            while (n > 1 && i <= sqrtn)
            {
                bool nc = false;
                long a;
                while ((a = n % (i - 1)) == 0)
                {
                    r.Add(i - 1);
                    n /= i - 1;
                    nc = true;
                }
                while ((a = n % (i + 1)) == 0)
                {
                    r.Add(i + 1);
                    n /= i + 1;
                    nc = true;
                }
                i += 6;
                if (nc)
                    sqrtn = (long)(Math.Sqrt(n)) + 1;
            }
            if (n != 1) r.Add(n);
            return r;
        }
    }
}


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

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      if (y % x != 0)
      {
        Console.WriteLine(0);
        return;
      }

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      //divs.Add(1);
      div = (1 << divs.Count) - 1;
      for (i = 0; i <= div; i++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
        while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
            ind -= 1;
          }
          j >>= 1;
        }
        int div2 = yx / div1;
        if (InRange(l, r, div1 * x) && InRange(l, r, div2 * x))
          ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}


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

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      if (y % x != 0)
      {
        Console.WriteLine(0);
        return;
      }

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      divs.Add(1);
      div = (1 << divs.Count) - 1;
      for (i = 0; i <= div; i++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
        while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
            ind -= 1;
          }
          j >>= 1;
        }
        int div2 = yx / div1;
        if (InRange(l, r, div1 * x) && InRange(l, r, div2 * x))
          ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}


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

namespace bla2
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            l = long.Parse(s[0]);
            r = long.Parse(s[1]);
            x = long.Parse(s[2]);
            y = long.Parse(s[3]);
            List<long> yfactors = Factor(y);
            yf = new List<long>();
            long x2 = x;
            for (int i = 0; i < yfactors.Count; i++)
            {
                if(x2 % yfactors[i] == 0)
                {
                    x2 /= yfactors[i];
                }
                else if(i != 0 && yfactors[i] == yfactors[i - 1])
                {
                    yf[yf.Count - 1] *= yfactors[i];
                }
                else
                {
                    yf.Add(yfactors[i]);
                }
            }
            if(x2 != 1)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(Count(new bool[yf.Count], 0));
            }

        }

        static long x, y, r, l;
        static List<long> yf;

        public static long Count(bool[] b, long at)
        {
            if(at == b.Length)
            {
                long n = x, m = x;
                for (int i = 0; i < b.Length; i++)
                {
                    if (b[i])
                        n *= yf[i];
                    else
                        m *= yf[i];
                }
                if (n <= r && n >= l && m <= r && m >= l)
                {
                    //Console.WriteLine(n + ", " + m);
                    return 1;
                }
                else
                    return 0;
            }
            long e = 0;
            bool[] nb = new bool[b.Length];
            Array.Copy(b, nb, b.Length);
            nb[at] = false;
            e += Count(nb, at + 1);
            nb[at] = true;
            e += Count(nb, at + 1);
            return e;
        }

        public static List<long> Factor(long n)
        {
            List<long> r = new List<long>();

            while (n % 2 == 0)
            {
                n /= 2;
                r.Add(2);
            }
            while (n % 3 == 0)
            {
                n /= 3;
                r.Add(3);
            }

            long sqrtn = (long)(Math.Sqrt(n)) + 1;
            long i = 6;
            while (n > 1 && i <= sqrtn)
            {
                bool nc = false;
                long a;
                while ((a = n % (i - 1)) == 0)
                {
                    r.Add(i - 1);
                    n /= i - 1;
                    nc = true;
                }
                while ((a = n % (i + 1)) == 0)
                {
                    r.Add(i + 1);
                    n /= i + 1;
                    nc = true;
                }
                i += 6;
                if (nc)
                    sqrtn = (long)(Math.Sqrt(n)) + 1;
            }
            if (n != 1) r.Add(n);
            return r;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    Scanner sc = new Scanner();
    //
    public void Solve()
    {
        int l, r, x, y;
        sc.Make(out l, out r, out x, out y);
        var fx = Factorize(x);
        var fy = Factorize(y);
        foreach (var p in fx)
        {
            if (!fy.ContainsKey(p.Key)||fy[p.Key]<p.Value)
                Fail(0);
        }
        var n = new List<P>();
        foreach (var p in fy)
        {
            if (!fx.ContainsKey(p.Key)) fx[p.Key] = 0;
            n.Add(new P(p.Key, p.Value, fx[p.Key]));
        }
        var res = 0;
        var ok = new Dictionary<long, Dictionary<long, bool>>();
        for(var i = 0; i < (1 << n.Count); i++)
        {
            long u = 1, v = 1;
            for(var j=0;j<n.Count;j++)
                if ((1 & i >> j) == 1)
                {
                    for (var k = 0; k < n[j].x; k++)
                        u *= n[k].v;
                    for (var k = 0; k < n[j].y; k++)
                        v *= n[k].v;
                }
                else
                {
                    for (var k = 0; k < n[j].x; k++)
                        v *= n[k].v;
                    for (var k = 0; k < n[j].y; k++)
                        u *= n[k].v;
                }
            if (r < u || u < l || r < v || v < l) continue;
            if (!ok.ContainsKey(u))
                ok[u] = new Dictionary<long, bool>();
            if (!ok[u].ContainsKey(v))
            {
                res++;
                ok[u][v] = true;
            }
        }
        WriteLine(res);
    }
    struct P
    {
        public long v, x, y;
        public P(long V,int X,int Y)
        {
            v = V;x = X;y = Y;
        }
    }

    public static Dictionary<long, int> Factorize(long num)
    {
        var dic = new Dictionary<long, int>();
        for (var i = 2L; i * i <= num; i++)
        {
            var ct = 0;
            while (num % i == 0)
            {
                ct++;
                num /= i;
            }
            if (ct != 0) dic[i] = ct;
        }
        if (num != 1) dic[num] = 1;
        return dic;
    }
}

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

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

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

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

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

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


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

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      if (y % x != 0)
      {
        Console.WriteLine(0);
        return;
      }

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      div = 1 << divs.Count;
      for (i = 1; i <= div; i ++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
          while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
            ind -= 1;
          }
          j >>= 1;
        }
        int div2 = yx / div1;
          if (InRange(l, r, div1) && InRange(l, r, div2))
        ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}