Segment tree query problem