long long a[1010][1010],b[1010][1010],su[1010][1010];
void init(signed lenx,signed leny){
for(signed i=1;i<=lenx;i++)
for(signed j=1;j<=leny;j++) b[i][j]=a[i][j]-a[i][j-1];
}
void correct(signed lx,signed rx,signed ly,signed ry,long long cr=1){for(signed i=ly;i<=ry;i++) b[lx][i]+=cr,b[rx+1][i]-=cr;}
void use(signed lenx,signed leny){
for(signed i=1;i<=lenx;i++)
for(signed j=1;j<=leny;j++) a[i][j]=a[i][j-1]+b[i][j],su[i][j]=su[i][j-1]+su[i-1][j]-su[i-1][j-1]+a[i][j];
}
void val(signed x,signed y){return a[x][y];}
void sum(signed lx,signed rx,signed ly,signed ry){return a[rx][ry]-a[lx-1][ry]-a[rx][ly-1]+a[lx-1][ly-1];}