Global Warming

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

You are developing a new computer game. Let's consider an island in the middle of the ocean in a three-dimensional space with zz-axis pointing upwards. The surface of the ocean is a horizontal plane with z=0z = 0. The island is a polyhedron of a special form.

You are given nn points (x_i,y_i,z_i)(x\_i, y\_i, z\_i); there are some edges between them. If we look at the island from above or if we discard zz coordinate of each point, points and edges form a planar connected graph. Every face of this planar graph, except the external one, is a nondegenerate triangle. Every edge of the graph belongs to at least one internal face. All points that lie on the edge of the external face of the graph have zz coordinates equal to zero. Other points may have arbitrary non-negative zz coordinates. Every face of the planar graph corresponds to the face of the polyhedron with the same vertices.

Due to global warming, the level of the ocean is increasing and floods the island. Your task is to compute various global warming scenarios for the game.

In each scenario, the level of the ocean increased to the height hh, so that the surface of the ocean is a plane z=hz = h. Parts of the island that are below or at the height hh are now flooded, even though some parts may be not reachable from the ocean by water (see the illustration for the second example). In a scenario, a player is standing in pp-th point. You shall compute the area of the surface of the part of the island where the player is standing, or determine that the player is standing at or below the water level and has drowned.

Formally, we say that two points on the surface of the island belong to the same part if a player can move between them walking by the surface of the island staying strictly higher than ocean level. Note that you should find the area of the surface of the island itself, not the area of its projection on a horizontal plane.

입력

The first line contains a single integer nn --- the number of points (1n1051 \le n \le 10^5).

Each of the next nn lines contains three integers x_ix\_i, y_iy\_i, and z_iz\_i --- the coordinates of ii-th point (106x_i,y_i106-10^6 \le x\_i, y\_i \le 10^6; 0z_i1060 \le z\_i \le 10^6).

The next line contains a single integer mm --- the number of internal faces of the planar graph (1m1051 \le m \le 10^5). They are also the faces of the island's polyhedron.

Each of the next mm lines contains three integers a_ia\_i, b_ib\_i, and c_ic\_i --- the indices of three points that are vertices of ii-th internal face (1a_i,b_i,c_in1 \le a\_i, b\_i, c\_i \le n).

It is guaranteed that if zz coordinate is discarded, then the resulting graph is a connected and planar graph. All its faces, except the external one, are nondegenerate triangles. All points that lie on the edge of the external face of the planar graph have zz coordinate equal to zero.

The next line contains an integer qq --- the number of global warming scenarios to compute (1q1051 \le q \le 10^5).

Each of the next qq lines contains two integers h_ih\_i and p_ip\_i --- the level of the ocean and the index of the point where the player is standing respectively (0h_i1060 \le h\_i \le 10^6; 1p_in1 \le p\_i \le n).

출력

For every scenario output a single real number --- the area of the surface of part of the island where the player is standing. If the player's position is flooded by water, output 1-1 instead.

The answer is considered correct if its absolute or relative error does not exceed 10610^{-6}.