Remember Space Turtle, the fearless space adventurer? When we last met him, he was searching for the fabled Golden Shell aboard the Tortoise, his trusty spaceship.
Space Turtle has run out of fuel, but he believes he is very close to the Golden Shell. Unfortunately, because of a spatial anomaly (the kind you see on TV), both the Tortoise and the Golden Shell are trapped on a two-dimensional grid, endlessly travelling along very strange orbits. Each orbit moves from one lattice point (a point with integer coordinates) to an adjacent lattice point, and travelling one unit of distance takes exactly one minute. The Tortoise and the Golden Shell entered the anomaly at the same instant, so you can think of this simply as two objects moving around on a grid.
As the Tortoise and the Golden Shell travel along their orbits, the distance between them changes a great deal. As the lonely keeper of the Golden Shell, your job is to observe the Tortoise once every minute — precisely when both you and the Tortoise are on lattice points — and record how far away it is. Your goal is to determine the closest distance at which the Tortoise is ever observed from the Golden Shell. (It may come closer while you are not looking, but that does not count.)
The first line contains three integers $s_x$, $s_y$, and $s_m$: the coordinates $(s_x, s_y)$ of the Tortoise's starting point and the number of moves $s_m$ in its orbit. Each of the next $s_m$ lines describes one move as an integer $d$ ($-100 \le d \le 100$) and a letter $c$, separated by a space. The value $d$ is the signed distance the Tortoise moves, and $c$ is the direction, either X or Y, corresponding to the $x$- and $y$-axes of the grid. There are at most $100$ move lines.
After this orbit comes an analogous description of the Golden Shell's orbit: a line with $t_x$, $t_y$, and $t_m$, followed by $t_m$ move lines in the same format. Both orbits are guaranteed to return to their starting point, so each one is a closed cycle.
Output the closest distance ever observed between the Tortoise and the Golden Shell, rounded to $2$ decimal places. If the two ever meet on the same lattice point, output 0.00.