Given $N$ points in 2D plane, and each point has some value. Have to answer $Q$ queries of the form:
Given $x_1, x_2, y_1, y_2$, find sum of values of all points $(x,y)$ such that $x_1 \le x \le x_2$ and $y_1 \le y \le y_2$. $N$ and $Q$ are $\le 10^6$. Also it will be helpful if someone can provide implementation.