Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kopburchak-va-nuqtalar

Polygon and points

Medium 1000 ms 128 MB 64%
Share

A polygon with $n$ vertices is given on the plane: its vertices are listed in order (clockwise or counterclockwise), and the polygon does not intersect itself. Then $q$ points are given. For each point print ICHIDA if it lies inside the polygon, CHEGARADA if it lies on its boundary (on a side or at a vertex), and TASHQARIDA if it lies outside.

A non-convex polygon on the coordinate plane and three points: inside, on the boundary and outside

Input

The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $x_{i}$ and $y_{i}$.
The next line contains a positive integer $q$. Each of the next $q$ lines contains the two integer coordinates of a point.

Output

For each point, on a separate line, ICHIDA, CHEGARADA or TASHQARIDA.

Note

$3 \le n \le 1000$
$1 \le q \le 100$
all coordinates are from $-10^{4}$ to $10^{4}$

Examples

Input #1
5
0 0
4 0
4 4
2 2
0 4
3
1 1
2 3
4 2
Output #1
ICHIDA
TASHQARIDA
CHEGARADA
Input #2
3
0 0
2 0
0 2
2
1 1
2 2
Output #2
CHEGARADA
TASHQARIDA

Sign in to submit a solution

Signing up is free and takes a minute.