public static void main(String[] args) {

        if (args.length > 0) {
            String param = args[0];
            if (param.equalsIgnoreCase("-gui")) {

                JFrame f = new JFrame("2d-Tree Demo");

                f.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
                    }
                });

                applet = new Demo();
                f.getContentPane().add("Center", applet);
                applet.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent me) {
                        int x;
                        int y;
                        x = me.getX() / pointSize;
                        y = me.getY() / pointSize;
                        applet.addPoint(new Point(x, y));
                    }

                    public void mousePressed(MouseEvent me) {
                        int x;
                        int y;
                        x = me.getX() / pointSize;
                        y = me.getY() / pointSize;
                        applet.setStartRectanglePoint(new Point(x, y));
                    }

                    public void mouseReleased(MouseEvent me) {
                        int x;
                        int y;
                        x = me.getX() / pointSize;
                        y = me.getY() / pointSize;
                        applet.setEndRectanglePoint(new Point(x, y));
                        applet.search();
                    }
                });

                applet.addMouseMotionListener(new MouseMotionListener() {
                    @Override
                    public void mouseDragged(MouseEvent me) {
                        int x;
                        int y;
                        x = me.getX() / pointSize;
                        y = me.getY() / pointSize;
                        applet.setEndRectanglePoint(new Point(x, y));
                    }

                    @Override
                    public void mouseMoved(MouseEvent me) {
                    }
                });

                applet.addKeyListener(new KeyAdapter() {
                    public void keyTyped(KeyEvent ke) {
                        applet.clear();
                    }
                });

                applet.init();
                applet.clear();

                f.pack();
                f.setSize(new Dimension(600, 600));
                f.setLocation(400, 200);
                f.setResizable(false);
                f.setVisible(true);
            }
        } else {
                        
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            try {
                
                List<Point> points = new ArrayList<Point>();
                List<Rectangle> rectangles = new ArrayList<Rectangle>();
                
                String line = in.readLine();
                int pointsNumber = Integer.parseInt(line);
                
                for (int i = 0; i < pointsNumber; i++) {
                    line = in.readLine();
                    
                    Scanner s = new Scanner(line);
                    s.findInLine("\\((\\d+),(\\s*)(\\d+)\\)");
                    MatchResult result = s.match();
                    int x = Integer.parseInt(result.group(1));
                    int y = Integer.parseInt(result.group(3));
                    Point p = new Point(x, y);
                    points.add(p);
                }
                
                line = in.readLine();
                int rectNumber = Integer.parseInt(line);
                
                for (int i = 0; i < rectNumber; i++) {
                    line = in.readLine();
                    
                    Scanner s = new Scanner(line);
                    s.findInLine("\\((\\d+),(\\s*)(\\d+),(\\s*)(\\d+),(\\s*)(\\d+)\\)");
                    MatchResult result = s.match();
                    int x1 = Integer.parseInt(result.group(1));
                    int y1 = Integer.parseInt(result.group(3));
                    int x2 = Integer.parseInt(result.group(5));
                    int y2 = Integer.parseInt(result.group(7));
                    Rectangle rectangle = new Rectangle(x1, x2, y1, y2);
                    rectangles.add(rectangle);
                }

                Tree2d tree = new Tree2d(points);
                for (Rectangle rectangle : rectangles) {
                    System.out.println(tree.findPointsNumber(rectangle));
                }
                
            } catch (IOException ex) {
                System.err.println(ex);
            }
        }

    }