ll@(h,w,x,y,n),d=1d9,s=0;rep(n){ll@(u,v,c);x-=u;y-=v;s+=d=x*y&&x*x-y*y?c>d?c-d:0:c;x=u;y=v;}wt(s);