{$APPTYPE CONSOLE}
{$R-,Q-,O+}
uses
SysUtils, Math;
const
eps = 1e- 9;
var
w, n, m, i, j, l, r, mid, ans, k, ans2, x, q, ll, rr, m1, m2: integer ;
a, b: array [ 0 .. 200001 ] of extended;
s, len: extended;
function dist( x1, y1, x2, y2: extended) : extended;
begin
result : = sqrt ( ( x1 - x2) * ( x1 - x2) + ( y1 - y2) * ( y1 - y2) ) ;
end ;
function f( k: integer ) : integer ;
begin
s : = dist( a[ i] , w, b[ j] , 0 ) + a[ k] - a[ i] ;
l : = j;
r : = m + 1 ;
while ( r - l) > 1 do begin
mid : = ( r + l) div 2 ;
if len + eps >= ( s + b[ mid] - b[ j] + dist( a[ k] , w, b[ mid] , 0 ) ) then
l : = mid
else
r : = mid;
end ;
mid : = l;
if len + eps >= ( s + b[ mid] - b[ j] + dist( a[ k] , w, b[ mid] , 0 ) ) then
result : = k - i + 1 + mid - j + 1
else
result : = 0 ;
end ;
begin
{reset(input, 'birch.in');
rewrite(output, 'birch.out');}
read ( len, w) ;
read ( n) ;
for i : = 1 to n do
read ( a[ i] ) ;
read ( m) ;
for i : = 1 to m do
read ( b[ i] ) ;
ans : = 0 ;
for i : = 1 to n do
for j : = 1 to m do begin
ll : = i;
rr : = n + 2 ;
while ( rr - ll) > 2 do begin
m1 : = ll + ( rr - ll) div 3 ;
m2 : = rr - ( rr - ll) div 3 ;
if f( m1) >= f( m2) then
rr : = m2
else
ll : = m1;
end ;
ans : = max( ans, f( ll) ) ;
ans : = max( ans, f( min( ll + 1 , n) ) ) ;
if ans = n + m then begin
write ( ans) ;
exit;
end ;
end ;
write ( ans) ;
end .
eyRBUFBUWVBFIENPTlNPTEV9CnskUi0sUS0sTyt9Cgp1c2VzCiAgU3lzVXRpbHMsIE1hdGg7Cgpjb25zdAogIGVwcyA9IDFlLTk7Cgp2YXIKICB3LCBuLCBtLCBpLCBqLCBsLCByLCBtaWQsIGFucywgaywgYW5zMiwgeCwgcSwgbGwsIHJyLCBtMSwgbTI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