Segment tree query and update