N-dimensional Segment tree for fast range queries.