/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem J. Japanese Writing                                  */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Andrey Stankevich                      */
/*--------------------------------------------------------------*/
 
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class japanese_as implements Runnable {
    class Point implements Comparable<Point> {
        int x;
        int y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Point o) {
            if (x != o.x) {
                return x - o.x;
            } else {
                return y - o.y;
            }
        }

        @Override
        public boolean equals(Object o) {
            Point point = (Point) o;

            if (x != point.x) return false;
            if (y != point.y) return false;

            return true;
        }

        @Override
        public int hashCode() {
            int result;
            result = x;
            result = 31 * result + y;
            return result;
        }

        public int rel(Point p) {
            if (x < p.x && y < p.y) {
                return 0;
            } else if (x < p.x && y == p.y) {
                return 1;
            } else if (x < p.x && y > p.y) {
                return 2;
            } else if (x == p.x && y < p.y) {
                return 3;
            } else if (x == p.x && y == p.y) {
                return 4;
            } else if (x == p.x && y > p.y) {
                return 5;
            } else if (x > p.x && y < p.y) {
                return 6;
            } else if (x > p.x && y == p.y) {
                return 7;
            } else {
                return 8;
            }

        }
    }

    class Stroke {
        Point p1;
        Point p2;

        Stroke(Point p1, Point p2) {
            this.p1 = p1;
            this.p2 = p2;
        }
    }

    class Writing {
        int n;
        int m;

        TreeSet<Point> points;
        ArrayList<Point> pp;
        HashMap<Point, Integer> ind;
        HashSet<Stroke> strokes;

        Writing(Scanner in) {
            m = in.nextInt();
            points = new TreeSet<Point>();
            pp = new ArrayList<Point>();
            ind = new HashMap<Point, Integer>();
            strokes = new HashSet<Stroke>();
            for (int i = 0; i < m; i++) {
                int xa = in.nextInt();
                int ya = in.nextInt();
                int xb = in.nextInt();
                int yb = in.nextInt();
                Point pa = new Point(xa, ya);
                Point pb = new Point(xb, yb);
                Stroke s = new Stroke(pa, pb);
                points.add(pa);
                points.add(pb);
                strokes.add(s);
            }

            n = points.size();

            int index = 0;
            for (Point p : points) {
                pp.add(p);
                ind.put(p, index++);
            }

            String s = checkData();
            assert s.equals("") : s;
        }

        public boolean matches(Writing w) {
            if (n != w.n || m != w.m) {
                return false;
            }
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    Point p1 = pp.get(i);
                    Point p2 = pp.get(j);
                    Point q1 = w.pp.get(i);
                    Point q2 = w.pp.get(j);
                    if (p1.rel(p2) != q1.rel(q2)) {
                        return false;
                    }
                }
            }

            if (!strokesSubset(this, w)) {
                return false;
            }
            if (!strokesSubset(w, this)) {
                return false;
            }

            return true;
        }

        public boolean strokesSubset(Writing w1, Writing w2) {
            for (Stroke s : w1.strokes) {
                int i1 = w1.ind.get(s.p1);
                int i2 = w1.ind.get(s.p2);

                boolean found = false;
                for (Stroke z : w2.strokes) {
                    int j1 = w2.ind.get(z.p1);
                    int j2 = w2.ind.get(z.p2);
                    if (i1 == j1 && i2 == j2) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    return false;
                }
            }
            return true;
        }

        public String checkData() {
            for (Point p : points) {
                if (p.x < -1000 || p.x > 1000 || p.y < -1000 || p.y > 1000) {
                    return "Point (" + p.x + ", " + p.y + ") is incorrect";
                }
            }
            for (Stroke s : strokes) {
                if (s.p1.equals(s.p2)) {
                    return "Stroke (" + s.p1.x + ", " + s.p1.y + ")-(" + s.p2.x + ", " + s.p2.y + ") is incorrect";
                }
                for (Stroke z : strokes) {
                    if (s != z) {
                        if (s.p1.equals(z.p1) && s.p2.equals(z.p2)) {
                            return "Stroke (" + s.p1.x + ", " + s.p1.y + ")-(" + s.p2.x + ", " + s.p2.y + ") occurs twice or more";
                        }
                        if (s.p1.equals(z.p2) && s.p2.equals(z.p1)) {
                            return "Stroke (" + s.p1.x + ", " + s.p1.y + ")-(" + s.p2.x + ", " + s.p2.y + ") has opposite duplicate";
                        }
                    }
                }
            }
            return "";
        }
    }

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("input.txt"));
        PrintWriter out = new PrintWriter("output.txt");

        int n = in.nextInt();
        Writing[] w = new Writing[n];
        for (int i = 0; i < n; i++) {
            w[i] = new Writing(in);
        }

        for (int i = 1; i < n; i++) {
            if (w[i].matches(w[0])) {
                out.println("CORRECT");
            } else {
                out.println("INCORRECT");
            }
        }

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

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        Locale.setDefault(Locale.US);
        new Thread(new japanese_as()).start();
    }
}