luogu#P5109. 归程

归程

Problem Description

dkw is playing a game called ION8102. The game is divided into the prologue, Chapter 1, and Chapter 2.

She has cleared the prologue with full health and has arrived at the first level of Chapter 1.

This level is called Return Journey. She needs to reach a specified location, and along the way she must pass through mm mechanical doors.

Each mechanical door has a keyhole, and only a special key can be inserted. Inside there are kk dial locks. Each dial lock must be turned to the target position aia_i exactly in order to open the door. The maximum scale of each dial is vv, with labels from 00 to vv. The initial position of every dial lock is 00.

dkw has nn keys. Each key has kk rotation amounts bib_i, meaning that if this key is turned by one full circle, it will move the corresponding dial lock in the door by that many positions.

Each mechanical door also has a turn limit cc, which means that in total you can use keys to turn at most cc circles. Also, each key can only be turned forward, and only an integer number of circles can be turned.

The task requires opening these mm doors in order. Such an easy problem is of course solved instantly by dkw, but she is curious: for each door, how many different plans can open it successfully?

Two plans are different if and only if either the total number of circles is different, or the key used in some circle is different.

If you satisfy dkw’s curiosity, you will receive a big gift from her—100 points.

Input Format

The first line contains four positive integers n,m,k,vn,m,k,v, with meanings as described above.

The next nn lines each contain kk non-negative integers, representing the rotation amounts bib_i of this key in order.

The next mm lines: first a non-negative integer cc representing the turn limit, followed by kk non-negative integers representing the target positions aia_i of this door in order.

Output Format

For each query, output one line with one non-negative integer representing the answer to this query, modulo 23332333.

5 5 2 3
0 0 
1 2 
3 3 
2 1 
3 2 
1 3 0 
2 1 2 
3 0 1 
4 1 2 
2 0 1 

0
3
14
34
2

5 5 2 3
2 2 
2 0 
2 3 
0 3 
2 1 
2 0 1 
3 1 1 
1 0 2 
2 3 0 
5 0 2 

4
0
0
0
465

Hint

This problem uses subtasks.

  • Subtask 1 (9pts): 1n,m,k,c,v51\le n,m,k,c,v\le 5.
  • Subtask 2 (16pts): 1n105,1m,c100,v=1,k121\le n\le 10^5,1\le m,c\le 100,v=1,k\le 12.
  • Subtask 3 (17pts): 1n105,1m,c100,v=2,k81\le n\le 10^5,1\le m,c\le 100,v=2,k\le 8.
  • Subtask 4 (19pts): 1n105,1m,c100,v=3,k61\le n\le 10^5,1\le m,c\le 100,v=3,k\le 6.
  • Subtask 5 (16pts): 1n105,1m,c1001\le n\le 10^5,1\le m,c\le 100.
  • Subtask 6 (23pts): 1n105,1m5,1c1091\le n\le 10^5,1\le m\le 5,1\le c\le 10^9.

For each test point, vv and kk are chosen from the corresponding relation in the table below.

Here, maxkmaxk means that kk will not exceed this value.

Index v maxk
1 12
2 8
3 6
4 5
5 4
6
7 3
8
9

Translated by ChatGPT 5