/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem G. Grand Theft Auto Wheel                            */
/*                                                              */
/* Original idea         Pavel Mavrin                           */
/* Problem statement     Pavel Mavrin                           */
/* Testset               Pavel Mavrin                           */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Georgiy Korneev                        */
/*--------------------------------------------------------------*/
 
import java.util.*;
import java.io.*;

public class gtaw_gk implements Runnable {
    private static final double PI2 = Math.PI * 2;
    static final double EPS = 1e-6;
    static Scanner in;
    static PrintWriter out;
    
    class Segment {
        final double l;
        final double r;

        Segment(double l, double r) {
            while (l > r) {
                 l -= PI2;
            }
            while (l + PI2 < r) {
                r -= PI2;
            }
            this.l = l;
            this.r = r;
        }
    }
    
    class Point {
        final double a;
        final double r;

        public Point(double r, double a) {
            this.r = r;
            this.a = a;
        }

        public double x() {
            return r * Math.cos(a);
        }

        public double y() {
            return r * Math.sin(a);
        }
    }

    public void run() {
        int n = in.nextInt();
        int r = in.nextInt();
        
        Point[] head = readPoly();
        
        List<Integer> result = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            if (match(head, readPoly(), r)) {
                result.add(i);
            }
        }
        
        out.println(result.size());
        for (Integer i : result) {
            out.println(i + 1);
        }
    }

    private Point[] readPoly() {
        Point[] points = new Point[in.nextInt()];
        for (int i = 0; i < points.length; i++) {
            points[i] = new Point(in.nextDouble(), in.nextInt() * Math.PI / 180);
        }
        return points;
    }

    private boolean match(Point[] head, Point[] wrench, double radius) {
        final List<Segment> forbidden = new ArrayList<Segment>();
        
        for (int i = 0; i < head.length; i++) {
            for (int j = 0; j < wrench.length; j++) {
                List<Segment> f = forbidden(
                        head[i], 
                        head[(i + 1) % head.length], 
                        wrench[j], 
                        wrench[(j + 1) % wrench.length],
                        radius
               );
               for (Segment s : f) {
                    double l = s.l;
                    double r = s.r;
                    while (l > EPS) {
                        l -= PI2;
                        r -= PI2;
                    }
                    while (l < -PI2) {
                        l += PI2;
                        r += PI2;
                    }
                    forbidden.add(new Segment(l, r));
                    forbidden.add(new Segment(l + PI2, r + PI2));
                    forbidden.add(new Segment(l + Math.PI * 4, r + Math.PI * 4));
                }
            }
        }
        
        if (forbidden.isEmpty()) {
            return false;
        }
        Collections.sort(forbidden, new Comparator<Segment>() {
            public int compare(Segment p1, Segment p2) {
                return Double.compare(p1.l, p2.l);
            }
        });
        
        PriorityQueue<Segment> open = new PriorityQueue<Segment>(forbidden.size(), new Comparator<Segment>() {
            public int compare(Segment p1, Segment p2) {
                return Double.compare(p1.r, p2.r);
            }
        });
        for (Segment p : forbidden) {
            if (p.l < -EPS && EPS < p.r) {
                open.add(p);
            }
        }
        
        if (open.isEmpty()) {
            return true;
        }
        for (Segment p : forbidden) {
            if (p.l < -EPS) continue;
            while (!open.isEmpty() && open.peek().r < p.l + EPS) {
                open.remove();
            }
            if (open.isEmpty()) {                
                return true;
            }
            open.add(p);
        }
        return false;
    }
    
    double sign(Point p1, Point p2) {
        double a = p1.y() - p2.y();
        double b = p2.x() - p1.x();
        double c = a * p1.x() + b * p1.y();
        return c;
    }

    double[] intersect(Point p1, Point p2, double r, boolean draw) {
        double a = p1.y() - p2.y();
        double b = p2.x() - p1.x();
        double c = a * p1.x() + b * p1.y();
        double d = Math.hypot(a, b) * Math.signum(c);
        a /= d;
        b /= d;
        c /= d;

        if (r < c - EPS) {
            return new double[0];
        }
        
        double angle = Math.atan2(b, a);
        double dangle = Math.atan2(Math.sqrt(r * r - c * c), c);
        return new double[]{angle - dangle, angle + dangle};
    }

    private List<Segment> forbidden(Point head1, Point head2, Point wrench1, Point wrench2, double radius) {
        if (head2.a < head1.a) {
            head2 = new Point(head2.r, head2.a + PI2);
        }
        if (wrench2.a < head1.a) {
            wrench2 = new Point(wrench2.r, wrench2.a + PI2);
        }
                
        Segment head = new Segment(head1.a, head2.a);
        Segment wrench = new Segment(wrench1.a, wrench2.a);
        
        double[] i1out = intersect(wrench1, wrench2, head1.r, false);
        double[] i2out = intersect(wrench1, wrench2, head2.r, false);
        
        double[] i1in = intersect(head1, head2, wrench1.r, false);
        double[] i2in = intersect(head1, head2, wrench2.r, false);
        
        List<Segment> result = new ArrayList<Segment>(2);
        if (i1in.length != 0) {
            double r1 = ((wrench1.r < head2.r + EPS) ? i1in[1] - wrench1.a : head2.a - wrench1.a);
            if (wrench1.r < head1.r + EPS) {
                if (i2out.length == 0) {
                    double l1 = circleMax(head1.a - wrench1.a, i2in[0] - wrench2.a, r1);
                    result.add(new Segment(l1, r1));
                } else if (segmentsIntersects(new Segment(i1in[0], i1in[1]), head)) {
                    result.add(new Segment(i1in[0] - wrench1.a, r1));
                }
            } else if (i1out.length != 0) {
                if (segmentsIntersects(new Segment(i1out[0] - 10 * EPS, i1out[1] + 10 * EPS), wrench)) {
                    result.add(new Segment(head1.a - i1out[0], r1));
                } else {
                    result.add(new Segment(head1.a - wrench2.a, r1));
                }
            } else {
                result.add(new Segment(head1.a - wrench2.a, r1));
            }
        }
        
        if (i2in.length != 0) {
            double l2 = ((wrench2.r < head1.r + EPS) ? i2in[0] - wrench2.a : head1.a - wrench2.a);
            if (wrench2.r < head2.r + EPS) {
                if (i1out.length == 0) {
                    double r2 = circleMin(head2.a - wrench1.a, i1in[1] - wrench1.a, l2);
                    result.add(new Segment(l2, r2));
                } else if (segmentsIntersects(new Segment(i2in[0], i2in[1]), head)) {
                    result.add(new Segment(l2, i2in[1] - wrench2.a));
                }
            } else if (i2out.length != 0) {             
                if (segmentsIntersects(new Segment(i2out[0] - 10 * EPS, i2out[1] + 10 * EPS), wrench)) {
                    result.add(new Segment(l2, head2.a - i2out[1]));
                } else {
                    result.add(new Segment(l2, head2.a - wrench1.a));
                }
            } else {
                result.add(new Segment(l2, head2.a - wrench1.a));
            }
        }
        return result;
    }

    private double circleMin(double a, double b, double to) {
        return bound(a, to) < bound(b, to) ? a : b;
    }

    private double circleMax(double a, double b, double to) {
        return bound(a, to) > bound(b, to) ? a : b;
    }

    private double bound(double a, double to) {
        while (a < to) {
            a += PI2;
        }
        while (a > to + PI2) {
            a -= PI2;
        }
        return a;
    }

    private boolean segmentsIntersects(Segment s, Segment head) {
        return segmentsIntersects(s.l, s.r, head.l, head.r);
    }

    private boolean segmentsIntersects(double l1, double r1, double l2, double r2) {        
        return between(l1 + 2 * EPS, l2, r2) || between(r1 - 2 * EPS, l2, r2) || between(l2 + 2 * EPS, l1, r1) || between(r2 - 2 * EPS, l1, r1);
    }

    private boolean between(double x, double a, double b) {
        while (x < a + EPS) {
            x += 2 * Math.PI;
        }
        while (a < x - 2 * Math.PI - EPS) {
            x -= 2 * Math.PI;
        }
        return x < b - EPS;
    }

    private double degree(double x) {
        return x * 180 / Math.PI;
    }

    private double x(double radius, double a) {
        return radius * Math.cos(a);
    }

    private double y(double radius, double a) {
        return radius * Math.sin(a);
    }
    
    public static void main(String[] args) throws Exception {
        Locale.setDefault(Locale.ENGLISH);
        in = new Scanner(new File("gtaw.in"));
        out = new PrintWriter("gtaw.out");

        new gtaw_gk().run();

        in.close();
        out.close();
    }
}
