#P11372. 「CZOI-R2」加训

「CZOI-R2」加训

Problem Description

_O_v_O_ has arrived in a kk-dimensional world.

The computer lab can be viewed as a kk-dimensional cube of size nkn^k (you can think of it as a kk-dimensional coordinate system), where the coordinate on each dimension ranges from 11 to nn.

There are mm OIers. The ii-th one is at (ai,1,ai,2,,ai,k)(a_{i,1},a_{i,2},\cdots,a_{i,k}). Unfortunately, all OIers are slacking off.

There are also xx obstacles in the lab. The ii-th obstacle is at (bi,1,bi,2,,bi,k)(b_{i,1},b_{i,2},\cdots,b_{i,k}).

In addition, there are yy coaches. The ii-th coach is at (ci,1,ci,2,,ci,k)(c_{i,1},c_{i,2},\cdots,c_{i,k}).

A coach does not want to see OIers slacking off. As long as a coach and some OIer have exactly k1k-1 coordinates (dimensions) that are the same, and the line segment connecting them contains no other obstacle, OIer, or coach, then that OIer is caught slacking off.

For each coach, ask how many OIers they can catch slacking off.

Input Format

The first line contains two integers n,kn,k, representing the side length of the cube and the number of dimensions.

The second line contains three integers m,x,ym,x,y, representing the numbers of OIers, obstacles, and coaches.

Next come mm lines, each containing kk numbers. Line i+2i+2 gives the position of the ii-th OIer.

Next come xx lines, each containing kk numbers. Line i+m+2i+m+2 gives the position of the ii-th obstacle.

Next come yy lines, each containing kk numbers. Line i+m+x+2i+m+x+2 gives the position of the ii-th coach.

Output Format

Output one line with yy integers, where the ii-th integer is the number of OIers seen by the ii-th coach.

10 2
2 2 2
1 1
1 2
2 1
2 3
3 1
3 2
0 1

Hint

[Sample Explanation]

Pairs of an OIer and a coach that satisfy having k1k-1 equal coordinates are: OIer 1 with coach 1, and OIer 2 with coach 2. However, there is an obstacle between OIer 1 and coach 1, so the OIer will not be caught.

[Constraints]

This problem uses bundled testdata.

  • Subtask #1 (25 pts25\ \text{pts}): k=1k=1.
  • Subtask #2 (35 pts35\ \text{pts}): k=2k=2.
  • Subtask #3 (40 pts40\ \text{pts}): k=3k=3.

For 100%100\% of the testdata, 1n1031\le n\le 10^3, 1k3\bf{1\le k\le 3}, m,x,y1m,x,y\ge1, m+x+ymin(103,nk)m+x+y\le\min(10^3,n^k), 1ai,j,bi,j,ci,jn1\le a_{i,j} ,b_{i,j},c_{i,j} \le n. It is guaranteed that no OIer, coach, or obstacle shares the same position.

Translated by ChatGPT 5