One Khanate had a lot of roads and very little wood. Riding along the roads was inconvenient, because the roads did not have road signs indicating the direction to important cities.The Han decided that it's time to fix the issue, and ordered to put signs on every road. The Minister of Transport has to do that, but he has only k signs. Help the minister to solve his problem, otherwise the poor guy can lose not only his position, but also his head.More formally, every road in the Khanate is a line on the Oxy plane, given by an equation of the form Ax + By + C = 0 (A and B are not equal to 0 at the same time). You are required to determine whether you can put signs in at most k points so that each road had at least one sign installed.

The input starts with two positive integers n, k (1 ≤ n ≤ 105, 1 ≤ k ≤ 5) Next n lines contain three integers each, Ai, Bi, Ci, the coefficients of the equation that determines the road (|Ai|, |Bi|, |Ci| ≤ 105, Ai2 + Bi2 ≠ 0). It is guaranteed that no two roads coincide.

If there is no solution, print "NO" in the single line (without the quotes). Otherwise, print in the first line "YES" (without the quotes). In the second line print a single number m (m ≤ k) — the number of used signs. In the next m lines print the descriptions of their locations. Description of a location of one sign is two integers v, u. If u and v are two distinct integers between 1 and n, we assume that sign is at the point of intersection of roads number v and u. If u =  - 1, and v is an integer between 1 and n, then the sign is on the road number v in the point not lying on any other road. In any other case the description of a sign will be assumed invalid and your answer will be considered incorrect. In case if v = u, or if v and u are the numbers of two non-intersecting roads, your answer will also be considered incorrect. The roads are numbered starting from 1 in the order in which they follow in the input.

NoteNote that you do not have to minimize m, but it shouldn't be more than k.In the first test all three roads intersect at point (0,0).In the second test all three roads form a triangle and there is no way to place one sign so that it would stand on all three roads at once.

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
    }
}