We consider all the rectangles of P(t) and how they intersect the staircase. On this behalf, we sort the lower left corners ai of the rectangles pi according to the difference between y- and x-coordinates and process the rectangles in this ordering. Clearly, all those corners lie to the left of the left boundary of r (t). Assume that we have already processed the corners a1,..., ai-1 as well as the topmost j steps of the staircase with j ≥ 0. Let s(tj) be the actual step defined by rectangle r (tj) to be considered. We consider pi. If pi is below of the diagonal of r (tj), it can be neglected since it has been considered while processing r (tj). Otherwise, if the lower boundary intersects step s(tj), the upper part of s(tj) is cut off, and we proceed to Pi+1. If the lower boundary is even lower than the whole step, s(tj) is completely cut off, and we proceed to s(tj+1). In this case, we reconsider pi (see Fig. 8).