Land Tax

No attempts yetTime limit1sMemory limit128 MB

Problem

The merchant Byteasar has arrived in Byteburg meaning to make his fortune on the real-estate market. He plans to buy up a section of the city and rent out its apartments. His main worry, however, is taxes.

The streets of Byteburg form a regular grid. There are n+1n + 1 streets running from west to east and m+1m + 1 streets running from south to north. On a flat map we call the streets of the first kind horizontal streets and those of the second kind vertical streets. Every horizontal street crosses every vertical street, so Byteburg contains nmn \cdot m blocks, where a block is an area bounded on every side by streets. The sides of every block have an integer length in bytemeters, and a block of size k×lk \times l is divided into klk \cdot l residential units.

One day the mayor decided to introduce a land tax. To keep it simple he ruled that within each of the nn horizontal rows of blocks the rate would be the same. More precisely, if in the ii-th row of blocks (1in1 \le i \le n) the mayor set the rate aia_i and that row has height xix_i, then every residential unit in the row pays a tax of ai/xia_i / x_i. Where many buildings in a row are historic landmarks, the mayor replaced the tax with a subsidy for their upkeep, paid from the city budget, at a rate that was again constant across the row. So if a row is taxed we take ai<0a_i < 0, and if it is subsidized then ai0a_i \ge 0.

The mayor did not clear his plan with the city council, which had independently hit on the same idea. As luck would have it, the council chose to tax the columns of blocks by exactly the same rule: with rate bjb_j in a column of width yjy_j, every unit pays a tax of bj/yjb_j / y_j. The council likewise accounted for landmarks and sometimes granted a subsidy instead of a tax, so a column is taxed when bj<0b_j < 0 and subsidized when bj0b_j \ge 0.

The mayor and the council announced their resolutions at about the same time. To avoid a dispute they reached a compromise: the rate for a given residential unit is the sum of the mayor's rate and the council's rate. Thus a unit in the block in row ii and column jj has combined rate ai/xi+bj/yja_i / x_i + b_j / y_j.

Byteasar would like to buy every residential unit inside some rectangular area. He may buy only whole blocks, so his area is a contiguous range of rows together with a contiguous range of columns, and it must be non-empty. The total of subsidies and taxes over an area is the sum, over all residential units in it, of each unit's combined rate. Help Byteasar find an area for which this total is as large as possible. This total is always an integer.

Input

The first line contains one integer nn. The second line contains nn integers aia_i. The third line contains nn positive integers xix_i. The fourth line contains one integer mm. The fifth line contains mm integers bjb_j. The sixth line contains mm positive integers yjy_j.

The numbers satisfy 1n,m2000001 \le n, m \le 200\,000. The elements of the sequences aia_i and bjb_j satisfy 10000ai,bj10000-10\,000 \le a_i, b_j \le 10\,000: a negative value is a tax rate set by the mayor or the council respectively, and a non-negative value is a subsidy for the upkeep of landmarks. The elements of xix_i and yjy_j (the heights of the rows and the widths of the columns of blocks) satisfy 1xi,yj100001 \le x_i, y_j \le 10\,000.

Output

Print one integer: the largest possible total of subsidies and taxes over a rectangular area of blocks.

Note

The numbers to the left of the figure are the tax rates in the rows of blocks (the sequence aia_i), and the numbers below it are the rates in the columns of blocks (the sequence bjb_j). The number inside each unit square is the combined tax rate in that block. The highlighted rectangle marks the area in which Byteasar should invest.