Segment tree problem