This page is still under construction.

Parts of this page are still being built. What you see may change.

Bowling Ball

Time limit1sMemory limit128 MB

Summary
A ball rolls back and forth over valleys and summits while friction drains its energy at each valley, and the task is to find where it finally stops.
Level

Medium6 of 10

Topics
Simulation, Math
Solved
No attempts yet

Problem

Neverland has many mountain ranges. A range is a chain of valleys and summits, the slope between a summit and a valley next to it is always 11 or −1-1, and every valley and summit has an integer height. A bowling ball rolls inside a section of a range made of nn valleys and n−1n-1 summits. The ball always touches the ground, so it never jumps. The mountains left of the first valley and right of the last valley are so high that the ball can never leave this section.

At time t0t_0 the ball starts in valley ss and moves toward the upper right, and its kinetic energy is K0K_0. The figure below shows a range with 44 valleys and 33 summits, with the ball in the second valley from the left.

At time tt the ball has potential energy Pt=mghP_t = mgh and kinetic energy Kt=12mv2K_t = \frac{1}{2}mv^2, where mm is the mass of the ball, gg is the gravity constant, here 1010, and hh and vv are the height and the speed of the ball at time tt. The two forms turn into each other, so the total energy Pt+KtP_t + K_t stays the same while the ball moves. Valleys are the exception. Every time the ball passes the ii-th valley from the left, friction takes cic_i units of kinetic energy away, and if its kinetic energy at that moment is smaller than cic_i, the ball stops in that valley. There is no friction outside the valleys. The ball also loses csc_s of energy when it leaves the starting valley at time t0t_0. The diameter of the ball is 00 and its mass is 11.

Find the valley or the summit where the ball stops.

Input

The input holds several test cases. The first line of each test case has three space separated integers nn, ss, and K0K_0 (1≤n≤30001 \le n \le 3000, 1≤s≤n1 \le s \le n, 1≤K0≤10151 \le K_0 \le 10^{15}). Each of the next nn lines has the height hih_i and the friction cic_i of the ii-th valley. Each of the following n−1n-1 lines has the height HjH_j of the jj-th summit from the left (0≤hi,ci,Hj≤1090 \le h_i, c_i, H_j \le 10^9). The jj-th summit lies between valley jj and valley j+1j+1 and is higher than both of them. At least one cic_i is greater than 00, and the ball always stops after a finite time. The last line of the input is 0 0 0 0 and is not a test case.

Output

For each test case print the place where the ball stopped on one line.

  • If the ball stops in valley kk, print Valley: k.
  • If the ball stops on summit kk, print Summit: k.

Examples1

  1. Example 1

    Input
    4 2 17
    1 1
    2 1
    1 1
    1 2
    3
    3
    2
    1 1 1000000000000000
    1 1
    0 0 0 0
    
    Expected output
    Summit: 2
    Valley: 1