Earl's Extremely Efficient Encryption

Given a growing set of stored image indices, find the longest run of consecutive unmarked indices below each query length w_j.

Medium6ArraySortingMathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Earl has just finished an extremely efficient encryption algorithm that shrinks video files. A video can be seen as a series of images placed in order.

The simplest method stores every image on its own. Earl's algorithm instead stores only the difference between successive images. One difference fits in a single 32-bit integer, and such a value is called a transition integer. Given the unencrypted first image and all of the transition integers, you can recreate the video exactly.

The problem is that computing a transition integer is lossy. A 32-bit integer is only an approximation of the real difference, so errors happen and an image can be displayed incorrectly. Each single transition works correctly with very high probability, but the probability of playing a whole video with no error is quite low. Errors also pile up, because the next difference is applied on top of an image that was already generated incorrectly.

To limit this, the algorithm stores a whole subset of the images in unencrypted form instead of the first image alone. At each transition the algorithm checks whether the true next image is stored. If it is, that stored image is displayed. If it is not, the algorithm uses the transition integer to generate the next image.

The badness of a video is the largest number of transition integers used in a row. Earl's algorithm handles every video with at most LL images. Given the number of images in each video of a collection and the set of images Earl stores unencrypted, compute the badness of every video.

Input

The input contains a single test case.

The first line contains six integers separated by spaces: kk (1k1001 \le k \le 100), nn (1n1051 \le n \le 10^5), LL (1L1091 \le L \le 10^9), aa (0aL0 \le a \le L), bb (0bL0 \le b \le L) and g1g_1 (0g1L0 \le g_1 \le L). Set g0=0g_0 = 0 and define the remaining terms by

gi=(agi1+b)mod(L+1)(2in)g_i = (a \cdot g_{i-1} + b) \bmod (L+1) \quad (2 \le i \le n)

Each of the next kk lines contains one integer. The jjth of them holds wjw_j (1wjL1 \le w_j \le L), the number of images in the jjth video when it is stored uncompressed. The images of the jjth video are numbered 00 through wj1w_j - 1, and the set of images Earl stores unencrypted is

{gi:0in}{0,1,,wj1}\{g_i : 0 \le i \le n\} \cap \{0, 1, \dots, w_j - 1\}

Because g0=0g_0 = 0, image 00 is always stored unencrypted. The videos are given in increasing order of wjw_j.

Output

Print the badness of each video on its own line, in the order the videos are given.

Hint

In the first example the images stored unencrypted are 0, 2, 4, 6, 8 and 10. The video of length 1 needs no transition integer at all, so its badness is 0. The video of length 3 uses a transition integer only to go from image 0 to image 1. The video of length 7 uses one transition integer when going from image 0 to 1, from 2 to 3 and from 4 to 5, but never two in a row, so its badness is 1. The video of length 14 has to generate images 11, 12 and 13 with consecutive transition integers, so its badness is 3.