program cch(input,output);
var
i,t,a,v,w,l,p,cost:longint;
n,b,ans:array[1..1000] of longint;
begin
assign(input,'sail.in');
assign(output,'sail.out');
reset(input);
rewrite(output);
readln(t,v,a,w);
for i:=1 to t do
readln(n[i],b[i]);
l:=b[1]; cost:=n[1]*b[1]; p:=1; ans[1]:=n[1];
for i:=2 to t do
begin
l:=l+w;
if l>b[i] then
begin
l:=b[i]; p:=i;
end;
inc(ans[p],n[i]);
inc(cost,l*n[i]);
end;
writeln(cost);
for i:=1 to t do
writeln(ans[i]);
close(input);
close(output);
end.