program plazma;
var N,Q,i,j,t,P:longint;
a,b,c:array [1..300000] of longint;
begin
read(N);read(Q);t:=0;P:=0;
for i:= 1 to N do begin
read(a[i]);read(b[i]);
end;
for i:= 1 to Q do 
read(c[i]);
for j:= 1 to Q do begin
for i:= 1 to N do begin
if a[i]<c[j] then begin
if b[i]<(c[j]+1-a[i]) then begin if p=0 then begin p:=p+(c[j]+1-a[i]-b[i]);t:=t+b[i]; end else p:=p-b[i]; end
else begin if p=0 then  t:=t +((c[j]-a[i])+1)
else if a[i]-a[i+1]<b[i] then t:=t+p-(a[i-1]-(a[i]+b[i]-1));
else t:=t+p
end;
end;
end;
writeln(t);
end;
end.