Problem: Once a walrus professor Plato asked his programming students to perform the following practical task. 

The students had to implement such a data structure that would support a convex hull on some set of points S. The input to the program had q queries of two types: 

1. Add a point with coordinates (x, y) into the set S. Note that in this case the convex hull of S could have changed, and could have remained the same. 

2. Say whether a point with coordinates (x, y) belongs to an area limited by the convex hull, including the border. 

All the students coped with the task. What about you?

Input

The first line contains an integer q (4 ≤ q ≤ 105). 

Then follow q lines in the following way: "t x y", where t is the query type (1 or 2), and (x, y) are the coordinates of the point ( - 106 ≤ x, y ≤ 106, x and y are integers). 

There is at least one query of type 2.

It is guaranteed that the three queries of the first type follow first and the points given in the queries form a non-degenerative triangle. Also all the points added in S are distinct.

Output

For each query of the second type print one string containing "YES", if the point lies inside the convex hull or on its border. Otherwise, print "NO".

Examples

Input

8
1 0 0
1 2 0
1 2 2
2 1 0
1 0 2
2 1 1
2 2 1
2 20 -1


Output

YES
YES
YES
NO

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.NavigableSet;
import java.util.TreeSet;

public class Main {
    final static double EPS = 1e-10;

    public static class Point {
        int x, y;

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

        public String toString() {
            return x + " " + y;
        }

        public int compareTo(Point p) {
            return x != p.x ? Integer.compare(x, p.x) : Integer.compare(y, p.y);
        }
    }

    static long cross(Point origin, Point a, Point b) {
        return (long) (a.x - origin.x) * (b.y - origin.y) -
                (long) (a.y - origin.y) * (b.x - origin.x);
    }

    static void removeLeft(TreeSet<Point> hull, Point p, int sign) {
        Point a = hull.floor(p);
        if (a == null) return;
        if (a.x == p.x) {
            hull.remove(a);
            a = hull.floor(p);
        }
        if(a == null) return;
        Point b = hull.lower(a);
        while (b != null && cross(p, a, b) * sign <= 0) {
            hull.remove(a);
            a = b;
            b = hull.lower(a);
        }
    }

    static void removeRight(TreeSet<Point> hull, Point p, int sign) {
        Point a = hull.ceiling(p);
        if (a == null) return;
        if (a.x == p.x) {
            hull.remove(a);
            a = hull.ceiling(p);
        }
        if(a == null) return;
        Point b = hull.higher(a);
        while (b != null && cross(p, a, b) * sign >= 0) {
            hull.remove(a);
            a = b;
            b = hull.higher(a);
        }
    }

    public static class PointContainer {
        Point e;
    }

    private static double slope(Point a, Point b) {
        return (a.x == b.x) ? 1e99 : (double) (a.y - b.y) / (a.x - b.x);
    }

    private static int signCrossProduct(Point origin, Point a, Point b) {
        long c = (long) (a.x - origin.x) * (b.y - origin.y) -
                (long) (a.y - origin.y) * (b.x - origin.x);
        return (c < 0) ? -1 :
                (c > 0) ? 1 : 0;
    }

    private static boolean between(Point a, Point b, Point c) {
        if (a.x == c.x) {
            return a.y <= b.y && b.y <= c.y;
        }
        return a.x <= b.x && b.x <= c.x;
    }

    private static void workHull(TreeSet<Point> hull, Point p) {
        while (hull.size() >= 2) {
            Point f = hull.first();
            Point s = hull.higher(f);
            if (slope(p, f) + EPS > slope(p, s)) {
                hull.pollFirst();
            } else {
                break;
            }
        }

        while (hull.size() >= 2) {
            Point s = hull.last();
            Point f = hull.lower(s);
            if (slope(p, f) + EPS > slope(p, s)) {
                hull.pollLast();
            } else {
                break;
            }
        }
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        int N = Integer.parseInt(br.readLine());
        //PointContainer ref = new PointContainer();
        TreeSet<Point> upper = new TreeSet<>((a, b) -> a.x - b.x);
        TreeSet<Point> lower = new TreeSet<>((a, b) -> a.x - b.x);
        /*TreeSet<Point> hull = new TreeSet<>((o1, o2) -> {
            double s1 = slope(ref.e, o1);
            double s2 = slope(ref.e, o2);
            if (Math.abs(s1 - s2) > EPS) {
                return Double.compare(s1, s2);
            } else if (o1.x != o2.x) {
                return Integer.compare(o1.x, o2.x);
            } else {
                return Integer.compare(o1.y, o2.y);
            }
        });*/

        for (int i = 0; i < N; i++) {
            String[] input = br.readLine().split(" ");
            int type = Integer.parseInt(input[0]);
            Point p = new Point(Integer.parseInt(input[1]), Integer.parseInt(input[2]));

            Point a = upper.floor(p);
            Point b = upper.ceiling(p);
            Point c = lower.floor(p);
            Point d = lower.ceiling(p);

            boolean outUpper = (a == null || b == null
                    || a == b && a.y < p.y || cross(a, b, p) > 0);
            boolean outLower = (c == null || d == null
                    || c == d && c.y > p.y || cross(c, d, p) < 0);

            if (type == 1) {
                if (outUpper) {
                    removeLeft(upper, p, 1);
                    removeRight(upper, p, 1);
                    upper.add(p);
                }
                if (outLower) {
                    removeLeft(lower, p, -1);
                    removeRight(lower, p, -1);
                    lower.add(p);
                }
            } else {
                pw.println(outUpper || outLower ? "NO" : "YES");
            }

            /*
            if (type == 1) {
                if (ref.e == null) {
                    ref.e = p;
                } else if (p.compareTo(ref.e) < 0) {
                    workHull(hull, p);
                    Point prev = ref.e;
                    ref.e = p;
                    if (hull.size() == 0 ||
                            slope(p, prev) < slope(p, hull.first()) ||
                            slope(p, prev) > slope(p, hull.last())) {
                        hull.add(prev);
                    }
                    workHull(hull, p);
                } else {
                    NavigableSet<Point> smaller = hull.headSet(p, false);
                    while (smaller.size() >= 2) {
                        Point s = smaller.last();
                        Point f = smaller.lower(s);
                        if (signCrossProduct(f, s, p) <= 0) {
                            smaller.pollLast();
                        } else {
                            break;
                        }
                    }
                    Point d = hull.higher(p);
                    if (d != null && smaller.size() >= 1) {
                        Point l = smaller.last();
                        if (signCrossProduct(l, p, d) == 1) {
                            hull.add(p);
                        }
                    } else {
                        hull.add(p);
                        NavigableSet<Point> bigger = hull.tailSet(p, false);
                        while (bigger.size() >= 2) {
                            Point f = bigger.first();
                            Point s = bigger.higher(f);
                            if (signCrossProduct(p, f, s) <= 0) {
                                bigger.pollFirst();
                            } else {
                                break;
                            }
                        }
                    }
                }
            } else {
                if (p.compareTo(ref.e) < 0) {
                    pw.println("NO");
                } else if (p.compareTo(ref.e) == 0) {
                    pw.println("YES");
                } else {
                    Point f = hull.lower(p);
                    Point s = hull.ceiling(p);
                    if (f != null && signCrossProduct(ref.e, p, f) == 0 &&
                            between(ref.e, p, f)) {
                        pw.println("YES");
                    } else if (s != null
                            && signCrossProduct(ref.e, p, s) == 0
                            && between(ref.e, p, s)) {
                        pw.println("YES");
                    } else if (f == null || s == null) {
                        pw.println("NO");
                    } else if (signCrossProduct(ref.e, f, s) * signCrossProduct(p, f, s) >= 0) {
                        pw.println("YES");
                    } else {
                        pw.println("NO");
                    }
                }
            }*/
        }
        pw.close();
    }
}