eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Bowling Ball

Bowling Ball

Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB

There are a lot of mountain ranges in the Neverlands. Every mountain range consists of a number of valleys and summits. The slope between two consecutive summit and valley is always either 1 or -1, and all the summits and the valleys have integer heights. A bowling ball is swinging on a part of a mountain range consisting of n valleys and n-1 summits. The ball is always touching down the surface of the mountain range (it does not jump). Mountains before the first and after the last valleys are too high such that the ball can never exit the mountain range. At time t_0 the ball is located in the valley number s moving to the upper-right direction and it has an initial kinetic energy K_0. The following figure shows a mountain range with 4 valleys and 3 summits, and the ball located in the 2^nd valley (enumerated from left to right).

By the simple physics we know that at any time t the ball has a gravitational potential energy P_t = mgh and also a kinetic energy K_t = (½)mv^2, where m is the mass of the ball, g is the constant of the Earth gravity (here equals to 10), and h and v are the height and the velocity of the ball at time t. By the transformation of energy from potential to kinetic or vice versa, the total energy of the ball P_t + K_t is fixed during its movements, unless it falls into a valley: at the i^th valley (from left), c_i units of the kinetic energy is lost due to friction or it stops if its kinetic energy is below c_i but consider no friction in other locations. Note that the ball loses c_s unit of energy when it leaves the starting valley at time t_0. You can assume the ball diameter is equal to 0 and its mass is equal to 1. Your task is to find the valley or summit at which the ball will stop.

Вхідні дані

There are multiple test cases in the input. The first line of each test case contains three space-separated positive integers n, and s and K_0 (1n3000, 1sn, 1K_010^15). Each of the following n lines contains two integers h_{i }and c_i, the height and friction of the i^th valley. The j^th line of the next n-1 lines contains H_j, the height of The j^th summit from the left (0h_i, c_i, H_j10^9). It is guaranteed that at least one of c_is is greater than zero. The input terminates with "0 0 0 0" which should not be processed.

Вихідні дані

For each test case, output a line conforming one of the following formats depending on whether the ball stops at either a valley or a summit.

  • If the ball stops at valley number k, output "Valley: k" (omit the quotes.)

  • If the ball stops at Summit number k, output "Summit: k" (omit the quotes.)

Приклад

Вхідні дані #1
4 2 17
1 1
2 1
1 1
1 2
3
3
2
1 1 1000000000000000
1 1
0 0 0 0
Вихідні дані #1
Summit: 2
Valley: 1
Джерело 38th ACM International Collegiate Programming Contest, 2013–2014 Asia Region, Tehran Site, Sharif University of Technology, 19–20 December 2013