Driving in City Squares 

The city AllSquared has been designed by many famous architects and engineers. The city lays in a retangular area of $n \times m$ squared miles (n refers to the retangle basis, and m to its height). The streets are horizontal divisions distributed uniformly at every one mile, and the avenues are vertical divisions also uniformly distributed at every one mile. Streets are numbered from north to south, starting from zero; avenues from west to east, also starting from zero.

The figure (a) below portrays the city layout for n = 11 and m = 8. The city is also


#1#2#3#4#5 @font#1#2pt #3#4#5
\begin{picture}(6525,2415)(361,-1951)
%\linethickness{.1in}
\thinlines
\put(21...
...mash{\SetFigFont{8}{9.6}{\rmdefault}{\mddefault}{\updefault}(b)}}}
\end{picture}


divided in horizontal and vertical strips, with the intersection of these strips defining the city subregions (counties). Figure (b) pictures a city divided into 12 counties.

Every county is associated with a vehicle circulation fee, which should be paid every time a car enters the county. If the car origin is a street or avenue delimiting the county, there is no fee. For example, in the above figure a car whose origin is street = 2 and avenue = 3 and whose target is street = 2 and avenue = 9 will have to pay only the county crossing fee relative to avenue 6.


You should write a program that has the following input:

The output should be the smallest possible price to pay for going from local 1 to local 2 .

Input 

The input format may contain several instances of the problem. Each instance is terminated by a line starting with % (percentage symbol).

The description for one instance has the following format:

n m    
h v    
s1 s2 $\dots$ sh-1
a1 a2 $\dots$ av-1
p11 p12 $\dots$ p1v
p21 p22 $\dots$ p2v
$\dots$      
ph1 ph2 $\dots$ phv
w1 t1 w2 t2
%      

where

Output 

For an input file with k instances of the problem, the output file should follow the format:

c1

c2

$\dots$

ck

where ci is the result for the ith instance in the input file.

Sample Input 

100 100
3 4
30 60
10 70 80
5 100 1 20
1 100 1 20
1 1 1 20
5 5 10 75
%
11 8
4 3
1 6 7
3 6
10 10 10
10 10 10
10 10 10
10 10 10
2 3 2 9
%

Sample Output 

6
10



Miguel Revilla
2000-12-30