Points

No attempts yetTime limit3sMemory limit128 MB

Problem

You are given a set of grid points in the plane (points whose two Cartesian coordinates are both integers); we call this set the pattern. You are also given a family of other sets of grid points in the plane.

For each set, decide whether it is similar to the pattern, i.e. whether it can be turned into a set identical to the pattern by some combination of rotations, translations, reflections and dilations (scalings).

For example, the set {(0,0),(2,0),(2,1)}\{(0,0),(2,0),(2,1)\} is similar to the set {(6,1),(6,5),(4,5)}\{(6,1),(6,5),(4,5)\}, but it is not similar to the set {(4,0),(6,0),(5,1)}\{(4,0),(6,0),(5,-1)\}.

Write a program that:

  • reads the pattern and the family of investigated sets from standard input,
  • determines which of the investigated sets are similar to the pattern,
  • writes the result to standard output.

Input

The first line contains a single integer kk (1k250001 \le k \le 25\,000) — the number of points in the pattern. Each of the next kk lines contains two integers separated by a single space; the ii-th of them holds the coordinates xix_i and yiy_i (20000xi,yi20000-20\,000 \le x_i, y_i \le 20\,000) of the ii-th pattern point. The points of the pattern are pairwise distinct.

The next line contains the number of sets to investigate, nn (1n201 \le n \le 20). Then follow the descriptions of the nn sets. Each description begins with a line containing a single integer ll (1l250001 \le l \le 25\,000) — the number of points in that set. Each of the next ll lines contains two integers xx and yy (20000x,y20000-20\,000 \le x, y \le 20\,000), the coordinates of one point. The points belonging to the same set are pairwise distinct.

Output

Print nn lines, one for each investigated set. On the ii-th line print TAK (Polish for “yes”) if the ii-th set is similar to the pattern, or NIE (Polish for “no”) otherwise.

Hint