{$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;
we: array [ 0 .. 2001 , 0 .. 2001 ] of extended;
s, len: extended;
function f( k: integer ) : integer ;
begin
s : = we[ i, j] + 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] + we[ k, mid] ) then
l : = mid
else
r : = mid;
end ;
mid : = l;
if len + eps >= ( s + b[ mid] - b[ j] + we[ k, mid] ) 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] ) ;
for i : = 1 to n do
for j : = 1 to m do begin
we[ i, j] : = sqrt ( ( a[ i] - b[ j] ) * ( a[ i] - b[ j] ) + ( w) * ( w) ) ;
end ;
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 .
eyRBUFBUWVBFIENPTlNPTEV9CnskUi0sUS0sTyt9Cgp1c2VzCiAgU3lzVXRpbHMsIE1hdGg7Cgpjb25zdAogIGVwcyA9IDFlLTk7Cgp2YXIKICB3LCBuLCBtLCBpLCBqLCBsLCByLCBtaWQsIGFucywgaywgYW5zMiwgeCwgcSwgbGwsIHJyLCBtMSwgbTI6IG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