Minimal Product

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

문제

You are given an array of integers a_1,,a_na\_1,\dots,a\_n. Find two indices ii and jj such that i\<ji\<j, a_i\<a_ja\_i\<a\_j, and the product a_ia_ja\_i \cdot a\_j is as small as possible.

입력

The input consists of several tests. The first line contains a single integer tt --- the number of tests (1t1041 \leq t \leq 10^4). Each of the following tt lines describes one test.

Each test is generated using the following algorithm. The test is described by integers nn, ll, rr, xx, yy, zz, b_1b\_1, b_2b\_2 (2n1072 \leq n \leq 10^7, 2109lr2109-2\cdot10^9 \leq l \leq r \leq 2\cdot10^9, 0x,y,z,b_1,b_2<2320 \leq x,y,z,b\_1,b\_2 < 2^{32}), where nn is the length of the array.

First, the sequence b_ib\_i of length nn is generated. Elements b_1b\_1 and b_2b\_2 are given. For i>2i>2 let b_i=(b_i2x+b_i1y+z)mod232b\_i=(b\_{i-2}x+b\_{i-1}y+z) \bmod 2^{32}. For each ii between 11 and nn, a_i=(b_imod(rl+1))+la\_i=(b\_i \bmod (r - l + 1)) + l (thus, 2109a_i2109-2\cdot10^9 \leq a\_i \leq 2\cdot10^9).

It is recommended to use 64-bit integers to generate the sequence to avoid integer overflow.

The sum of nn in all tests does not exceed 21072 \cdot 10^7.

출력

For each test, print the smallest possible product a_ia_ja\_i \cdot a\_j in a separate line. If there are no such ii and jj that i\<ji\<j and a_i\<a_ja\_i\<a\_j, print "IMPOSSIBLE".

힌트

Let us consider the generation of the array in the first test.

First, the sequence bb is generated.

  • b_1=0b\_1 = 0
  • b_2=3b\_2 = 3
  • b_3=(110+133+17)mod232=56b\_3 = (11\cdot 0 + 13\cdot 3 + 17)\bmod 2^{32}=56
  • b_4=(113+1356+17)mod232=778b\_4 = (11\cdot 3 + 13\cdot 56 + 17)\bmod 2^{32}=778

Then it is used to generate aa.

  • a_1=(0mod(5(5)+1))+(5)=(0mod11)5=5a\_1 = (0\bmod (5-(-5) + 1)) + (-5)=(0 \bmod 11) - 5 = -5
  • a_2=(3mod11)5=2a\_2 = (3 \bmod 11) - 5 = -2
  • a_3=(56mod11)5=4a\_3 = (56 \bmod 11) - 5 = -4
  • a_4=(778mod11)5=3a\_4 = (778 \bmod 11) - 5 = 3

Thus, a=\[5,2,4,3]a = \[-5,-2,-4,3]. The answer is 53=15-5 \cdot 3=-15.

In the second test the array is \[42,42,42,42,42]\[42,42,42,42,42].