#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff, SINF = 0x3f3f3f3f;
const double PI = 3.141592653589793;
const long long LINF = 0x7fffffffffffffffLL, SLINF = 0x3f3f3f3f3f3f3f3fLL;
int _v, _f, _c;
long long _l;
void read() {
  _c = getchar(), _v = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _v = (_v << 3) + (_v << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _v = -_v;
  }
}
void read_ll() {
  _c = getchar(), _l = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _l = (_l << 3) + (_l << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _l = -_l;
  }
}
const int MAXN = 100005, MAXM = 100005, MAXK = 100005, MOD = 1e9 + 7;
const long double EPS = 1e-13;
int cmp(long double a, long double b) {
  return a - b > EPS ? 1 : (a - b < -EPS ? -1 : 0);
}
const int GREATER = 1, LESS = -1, EQUAL = 0;
struct Point {
  long long x, y;
  long double k;
  long long d;
  Point(long long a = 0, long long b = 0) { x = a, y = b; }
  Point(long long a, long long b, Point& c) {
    x = a, y = b;
    k = sub(c).angle(), d = sub(c).len_sq();
  }
  Point sub(Point v) { return Point(x - v.x, y - v.y); }
  long long cross(Point v) { return x * v.y - v.x * y; }
  long double angle() { return atan2(y, x); }
  long long len_sq() { return (long long)x * x + (long long)y * y; }
  bool operator<(const Point& e) const {
    return k < e.k || (k == e.k && d < e.d);
  }
} init[4];
Point center;
set<Point> ch;
bool put(Point p, bool simulate) {
  set<Point>::iterator it = ch.lower_bound(p);
  if (it == ch.end()) {
    it = ch.begin();
  }
  Point nxt = *it;
  if (it == ch.begin()) {
    it = ch.end();
  }
  Point lst = *(--it);
  if (nxt.sub(lst).cross(p.sub(lst)) >= 0) {
    return true;
  }
  if (simulate) {
    return false;
  }
  while (ch.size() >= 2) {
    set<Point>::iterator i = ch.lower_bound(p);
    if (i == ch.end()) {
      i = ch.begin();
    }
    Point n = *i;
    i++;
    Point nn = i == ch.end() ? *ch.begin() : *i;
    if (nn.sub(p).cross(n.sub(p)) >= 0) {
      ch.erase(n);
    } else {
      break;
    }
  }
  while (ch.size() >= 2) {
    set<Point>::iterator i = ch.lower_bound(p);
    if (i == ch.begin()) {
      i = ch.end();
    }
    --i;
    Point l = *i;
    if (i == ch.begin()) {
      i = ch.end();
    }
    Point ll = *(--i);
    if (p.sub(ll).cross(l.sub(ll)) >= 0) {
      ch.erase(l);
    } else {
      break;
    }
  }
  ch.insert(p);
  return false;
}
int num;
int main() {
  num = (read(), _v);
  for (int i = 0; i < 3; i++) {
    (read(), _v);
    int x = (read(), _v) * 3, y = (read(), _v) * 3;
    center.x += x / 3, center.y += y / 3;
    init[i] = Point(x, y);
  }
  for (int i = 0; i < 3; i++) {
    Point p = Point(init[i].x, init[i].y, center);
    ch.insert(p);
  }
  num -= 3;
  for (int i = 0; i < num; i++) {
    int op = (read(), _v), x = (read(), _v) * 3, y = (read(), _v) * 3;
    Point p = Point(x, y, center);
    if (op == 1) {
      put(p, false);
    } else {
      printf(put(p, true) ? "YES\n" : "NO\n");
    }
  }
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff, SINF = 0x3f3f3f3f;
const double PI = 3.141592653589793;
const long long LINF = 0x7fffffffffffffffLL, SLINF = 0x3f3f3f3f3f3f3f3fLL;
int _v, _f, _c;
long long _l;
void read() {
  _c = getchar(), _v = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _v = (_v << 3) + (_v << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _v = -_v;
  }
}
void read_ll() {
  _c = getchar(), _l = _f = 0;
  while (_c < '0' || _c > '9') {
    if (_c == -1) {
      _f = -1;
      return;
    } else if (_c == '-') {
      _f = 1;
    }
    _c = getchar();
  }
  while (_c <= '9' && _c >= '0') {
    _l = (_l << 3) + (_l << 1) + (_c ^ 48);
    _c = getchar();
  }
  if (_f) {
    _l = -_l;
  }
}
const int MAXN = 100005, MAXM = 100005, MAXK = 100005, MOD = 1e9 + 7;
const long double EPS = 1e-13;
int cmp(long double a, long double b) {
  return a - b > EPS ? 1 : (a - b < -EPS ? -1 : 0);
}
const int GREATER = 1, LESS = -1, EQUAL = 0;
struct Point {
  long long x, y;
  long double k;
  long long d;
  Point(long long a = 0, long long b = 0) { x = a, y = b; }
  Point(long long a, long long b, Point& c) {
    x = a, y = b;
    k = sub(c).angle(), d = sub(c).len_sq();
  }
  Point sub(Point v) { return Point(x - v.x, y - v.y); }
  long long cross(Point v) { return x * v.y - v.x * y; }
  long double angle() { return atan2(y, x); }
  long long len_sq() { return (long long)x * x + (long long)y * y; }
  bool operator<(const Point& e) const {
    return k < e.k || (k == e.k && d < e.d);
  }
} init[4];
Point center;
set<Point> ch;
bool put(Point p, bool simulate) {
  set<Point>::iterator it = ch.lower_bound(p);
  if (it == ch.end()) {
    it = ch.begin();
  }
  Point nxt = *it;
  if (it == ch.begin()) {
    it = ch.end();
  }
  Point lst = *(--it);
  if (nxt.sub(lst).cross(p.sub(lst)) >= 0) {
    return true;
  }
  if (simulate) {
    return false;
  }
  while (ch.size() >= 2) {
    set<Point>::iterator i = ch.lower_bound(p);
    if (i == ch.end()) {
      i = ch.begin();
    }
    Point n = *i;
    i++;
    Point nn = i == ch.end() ? *ch.begin() : *i;
    if (nn.sub(p).cross(n.sub(p)) >= 0) {
      ch.erase(n);
    } else {
      break;
    }
  }
  while (ch.size() >= 2) {
    set<Point>::iterator i = ch.lower_bound(p);
    if (i == ch.begin()) {
      i = ch.end();
    }
    --i;
    Point l = *i;
    if (i == ch.begin()) {
      i = ch.end();
    }
    Point ll = *(--i);
    if (p.sub(ll).cross(l.sub(ll)) >= 0) {
      ch.erase(l);
    } else {
      break;
    }
  }
  ch.insert(p);
  return false;
}
int num;
int main() {
  num = (read(), _v);
  for (int i = 0; i < 3; i++) {
    (read(), _v);
    int x = (read(), _v) * 3, y = (read(), _v) * 3;
    center.x += x / 3, center.y += y / 3;
    init[i] = Point(x, y);
  }
  for (int i = 0; i < 3; i++) {
    Point p = Point(init[i].x, init[i].y, center);
    ch.insert(p);
  }
  num -= 3;
  for (int i = 0; i < num; i++) {
    int op = (read(), _v), x = (read(), _v) * 3, y = (read(), _v) * 3;
    Point p = Point(x, y, center);
    if (op == 1) {
      put(p, false);
    } else {
      printf(put(p, true) ? "YES\n" : "NO\n");
    }
  }
  return 0;
}

```