Five-pointed Queries

시간 제한3초메모리 제한1024 MB

요약
볼록 k각형(k ≤ 30)의 꼭짓점에 통신탑이 있고, 내부의 가입자가 활성 상태를 토글하며, 다섯 탑이 만드는 오각형 안에 들어가는 활성 가입자 수를 묻는 질의에 답한다.
난이도

어려움10점 중 8점

유형
기하, 누적 합, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

Nowadays, the 5G mobile communication standard is being introduced everywhere. But progress does not stand still, and the researchers of the Lucifer Laboratory are working hard to develop a new communication standard. The development turns out to be so innovative that it was decided to call the new standard not 6G, but immediately 666G. Researchers claim that this technology will make it possible to call Satan himself.

The new technology can be described as follows. The kk comminication towers, which can be considered points on the plane, are located at the vertices of a convex kk-gon. Any five pairwise different towers are the tops of a five-pointed star and allow serving subscribers inside a pentagon, which is bounded by edges of the five-pointed star.

You task is to test the load on communication towers using a model example. Let there be nn subscribers who can be considered as points on the plane inside the convex kk-gon formed by the kk communication towers. We will assume that subscribers do not change their location. For each subscriber it is known whether he is active or not.

Further, there are qq events of two types, ordered chronologically:

  1. Subscriber numbered tt changes its activity. That is, if the subscriber was active, then he becomes inactive and vice versa.
  2. For some five pairwise different communication towers, it is necessary to determine the number of active subscribers who are served by these five towers.

You need to simulate all events and respond to all requests of type 22.

입력

The first line contains an integer kk --- the number of communication towers (5≤k≤305 \le k \le 30).

The ii-th of the following kk lines contains two integers X_iX\_i and Y_iY\_i --- coordinates of the ii-th communication tower. It is guaranteed that the communication towers are at the vertices of a strictly convex kk-gon, that is, no three towers are on the same straight line. The towers are listed in clockwise order of traversing this kk -gon.

Further on a separate line is an integer nn --- the number of subscribers (1≤n≤50,0001 \le n \le 50\\,000).

The ii-th of the following nn lines contains three integers x_ix\_i, y_iy\_i and z_iz\_i --- the coordinates of the ii -th subscriber and his activity. z_i=1z\_i=1 means that the ii -th subscriber is active, z_i=0z\_i=0 --- that he is not. It is guaranteed that all subscribers are strictly inside the convex kk-gon formed by communication towers. No subscriber is on the segment that connects any two communication towers.

Further on a separate line is an integer qq --- the number of events (1≤q≤50,0001 \le q \le 50\\,000).

The ii-th of the following qq lines describes the ii-th event. An event of type 11 is written as "11 tt", where tt is the number of the subscriber for which the activity is changing (1≤t≤n1 \le t \le n). An event of type 22 is written as "22 a_ia\_i b_ib\_i c_ic\_i d_id\_i e_ie\_i", where a_ia\_i, b_ib\_i, c_ic\_i, d_id\_i and e_ie\_i --- tower indexes for which you need to determine the number of active served subscribers (1≤a_i<b_i<c_i<d_i<e_i≤k1 \le a\_i < b\_i < c\_i < d\_i < e\_i \le k).

It is guaranteed that there is at least one request of the type 22.

The coordinates of all points are integers not exceeding 5×1055 \times 10^5 in absolute value. No two points in the input are equal.

출력

Print pp lines, where pp is the number of events of type 22. In the ii-th line, print one integer - the answer to the ii-th query of the type 22.

힌트

The point configuration in the example is shown on picture above.

예제1

  1. 예제 1

    입력
    6
    0 2
    1 7
    7 7
    8 3
    7 1
    4 0
    6
    1 4 1
    3 3 1
    4 3 0
    4 2 1
    5 4 1
    6 3 1
    8
    2 1 2 3 4 5
    2 1 2 3 4 6
    1 3
    2 1 2 3 4 6
    2 1 2 3 5 6
    2 1 2 4 5 6
    2 1 3 4 5 6
    2 2 3 4 5 6
    
    예상 출력
    2
    2
    3
    3
    1
    0
    1