Farmer John's cows thoroughly enjoy throwing pebbles into the lake next to their grazing field. When a pebble hits the surface of the lake, it generates a wave that propagates across the surface of the lake.
The surface of the lake is represented by a large grid of squares. The water at each square is at some depth, which is determined by the interaction of the waves. Before any pebbles are dropped, every square (except those on the original river banks) has a depth of 0. When displayed, each square will be represented as follows:
o Square has a depth < 0
- Square has a depth = 0
* Square has a depth > 0
X Square is part of the original river bank
0 seconds 1 second 2 seconds 3 seconds
------- ------- ------- ---*---
------- ------- ---*--- --*-*--
------- ---*--- --*-*-- -*-o-*-
---*--- --*-*-- -*-o-*- *-o-o-*
------- ---*--- --*-*-- -*-o-*-
------- ------- ---*--- --*-*--
------- ------- ------- ---*---
1 second 2 seconds 3 seconds 4 seconds 5 seconds
X------ X------ X--*--- X-*-*-- X*---*-
X------ X--*--- X-*-*-- X*---*- X*----*
X--*--- X-*-*-- X*---*- X*----* X-*----
X-*-*-- X*---*- X*----* X-*---- X--*---
X--*--- X-*-*-- X*---*- X*----* X-*----
X------ X--*--- X-*-*-- X*---*- X*----*
X------ X------ X--*--- X-*-*-- X*---*-
1 second 2 seconds 3 seconds 4 seconds
--------- --------- --------- ---*-----
--------- --------- ---*----- --*-*-*--
--------- ---*----- --*-*-*-- -*-o-*-*-
---*----- --*-*-*-- -*-o-*-*- *-o-----*
--*-*-*-- -*-o-*-*- *-o-----* -o-*-o---
---*----- --*-*-*-- -*-o-*-*- *-o-----*
--------- ---*----- --*-*-*-- -*-o-*-*-
--------- --------- ---*----- --*-*-*--
--------- --------- --------- ---*-----
* Line 1: Four space-separated integers: P, B1, B2, and R:
* P (1 <= P <= 5) indicates the number of pebbles,
* B1 (-500,000 <= B1 <= 500,000) and B2 (-500,000 <= B2 <= 500,000) are the x co-ordinates of two river banks, and
* R (1 <= R <= 500,000) the time at which you are to display the lake.
No two pebbles will be dropped at the same position at the same time. The two banks will have different x co-ordinates, and no pebble will be dropped on a bank.
* Lines 1..9: The output contains a 9 x 9 grid, centered on 0,0. The bottom left of the grid represents (-4, -4) and the top right represents (4,4). The grid should represent the state of the lake at time R.
2 4 100 4 -3 0 1 0 0 2
--------X -*------X *-*-*---X -o-*-*--X o-----*-X -o-*-*--X *-*-*---X -*------X --------X