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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 50e4 + 10;
const int MOD = 1e6 + 3;
int T;
struct point {
  int x, y;
  point operator-(const point &A) const {
    point b;
    b.x = x - A.x;
    b.y = y - A.y;
    return b;
  }
} hlp[5];
int CJ(point A, point B) {
  long long c =
      (long long)A.x * (long long)B.y - (long long)A.y * (long long)B.x;
  if (c < 0) {
    return -1;
  }
  if (c > 0) {
    return 1;
  }
  return 0;
}
int cmp(point A, point B) { return A.x < B.x; }
struct nn {
  map<int, int> vis;
  map<int, int>::iterator posb, pos, posa;
  int tag;
  void PRT() {
    for (pos = vis.begin(); pos != vis.end(); pos++) {
      printf("	(%d,%d)\n", (*pos).first, (*pos).second);
    }
  }
  void prt() { printf("(%d,%d)\n", (*pos).first, (*pos).second); }
  void BUILD() {
    if (hlp[1].x == hlp[2].x) {
      if (tag == -1) {
        vis[hlp[1].x] = max(hlp[1].y, hlp[2].y);
      }
      if (tag != -1) {
        vis[hlp[1].x] = min(hlp[1].y, hlp[2].y);
      }
      vis[hlp[3].x] = hlp[3].y;
      return;
    }
    vis[hlp[1].x] = hlp[1].y;
    if (hlp[2].x == hlp[3].x) {
      if (tag == -1) {
        vis[hlp[2].x] = max(hlp[2].y, hlp[3].y);
      }
      if (tag != -1) {
        vis[hlp[2].x] = min(hlp[2].y, hlp[3].y);
      }
      return;
    }
    vis[hlp[3].x] = hlp[3].y;
    if (CJ(hlp[2] - hlp[1], hlp[3] - hlp[1]) == tag) vis[hlp[2].x] = hlp[2].y;
  }
  int check(point A) {
    pos = vis.end();
    pos--;
    if (A.x > (*pos).first) {
      return 0;
    }
    pos = vis.begin();
    if (A.x < (*pos).first) {
      return 0;
    }
    if (A.x == (*pos).first) {
      if (tag == -1) {
        if (A.y > (*pos).second) {
          return 0;
        }
        return 1;
      }
      if (tag != -1) {
        if (A.y < (*pos).second) {
          return 0;
        }
        return 1;
      }
    }
    pos = vis.lower_bound(A.x);
    point R = (point){(*pos).first, (*pos).second};
    pos--;
    point L = (point){(*pos).first, (*pos).second};
    if (CJ(R - L, A - L) == tag * -1) {
      return 0;
    }
    return 1;
  }
  void ADD(point A) {
    pos = vis.end();
    pos--;
    if (A.x < (*pos).first) {
      pos = vis.lower_bound(A.x);
      if ((*pos).first == A.x || pos == vis.begin()) {
        pos++;
      }
      posa = pos;
      posa--;
      if ((*posa).first < A.x) {
        pos++;
      }
      while (pos != vis.end()) {
        posa = pos;
        point R = (point){(*pos).first, (*pos).second};
        pos--;
        point L = (point){(*pos).first, (*pos).second};
        if (CJ(L - A, R - A) != tag * (-1) ||
            pos == vis.begin() && (*pos).first < A.x) {
          break;
        }
        vis.erase(pos);
        pos = posa;
        pos++;
      }
    }
    pos = vis.begin();
    if (A.x > (*pos).first) {
      pos = vis.end();
      pos--;
      if ((*pos).first >= A.x) {
        pos = vis.lower_bound(A.x);
        if (pos != vis.begin()) {
          pos--;
        }
      }
      while (pos != vis.begin()) {
        posa = pos;
        point R = (point){(*pos).first, (*pos).second};
        pos--;
        point L = (point){(*pos).first, (*pos).second};
        if (CJ(L - A, R - A) != tag * (-1)) {
          break;
        }
        posb = posa;
        posb++;
        if (posb == vis.end() && A.x <= (*posa).first) {
          111;
        } else {
          vis.erase(posa);
        }
      }
    }
    vis[A.x] = A.y;
  }
} tr[2];
int main() {
  int n;
  scanf("%d", &n);
  tr[0].tag = -1;
  tr[1].tag = 1;
  for (int i = 1; i <= 3; i++) {
    scanf("%*d%d%d", &hlp[i].x, &hlp[i].y);
  }
  sort(hlp + 1, hlp + 4, cmp);
  tr[0].BUILD();
  tr[1].BUILD();
  for (int i = 4; i <= n; i++) {
    int pd;
    point yh;
    scanf("%d%d%d", &pd, &yh.x, &yh.y);
    if (pd == 2) {
      if (tr[0].check(yh) && tr[1].check(yh)) {
        printf("YES\n");
      } else {
        printf("NO\n");
      }
    }
    if (pd == 1) {
      int pda = tr[0].check(yh);
      int pdb = tr[1].check(yh);
      if (!pda) {
        tr[0].ADD(yh);
      }
      if (!pdb) {
        tr[1].ADD(yh);
      }
    }
  }
  return 0;
}