Space Turtle is a fearless space adventurer. His spaceship, the Tortoise, is a little outdated, but it still gets him where he needs to go.
The Tortoise can do only two things: move forward an integer number of light-years, and turn 90 degrees in one of four directions relative to its current orientation — right, left, up, or down. Because it always moves along axis-aligned directions, you can think of the Tortoise as a ship travelling on a 3-dimensional coordinate grid measured in light-years.
In today's adventure, Space Turtle is searching for the fabled Golden Shell, which lies on a deserted planet somewhere in uncharted space. He plans to fly around looking for the planet, hoping his turtle instincts will lead him to the treasure.
You have the lonely job of guarding the Golden Shell, and your only hobby is to record how close treasure-seekers come to the deserted planet. Given Space Turtle's flight plan, determine the closest distance he comes to the Golden Shell at any point along his path. The closest approach may occur in the middle of a movement, not only at the points where he turns.
The first line contains three integers $sx$, $sy$, and $sz$, the coordinates of Space Turtle's starting point. He initially faces the positive $x$ direction, with the top of his spaceship pointing in the positive $z$ direction and the positive $y$ direction to his left. Each of these integers is between $-100$ and $100$.
The second line contains three integers $tx$, $ty$, and $tz$, the coordinates of the deserted planet. Each is between $-10,000$ and $10,000$.
Each remaining line describes one step of the flight plan and contains an integer $d$ ($0 \le d \le 100$) and a letter $c$, separated by a space. The Tortoise first moves forward $d$ light-years, then turns 90 degrees in direction $c$: L, R, U, and D stand for left, right, up, and down, respectively. There are at most 100 such lines.
On the last line, the letter E is given instead of a direction, indicating the end of the adventure. On that line the ship still moves forward $d$ light-years before stopping.
Output the closest distance Space Turtle gets to the hidden planet during his flight, rounded to 2 decimal places. If at any moment his coordinates coincide exactly with the planet's coordinates, output a distance of $0.00$ — he lands safely on the planet and finds the Golden Shell.