Cut the Cake

No attempts yetTime limit1sMemory limit128 MB

Problem

Today is the birthday of Mr. Bon Vivant, known as one of the greatest pâtissiers in the world. The guests invited to his party are gourmets from all over the globe, eager to see and taste his extremely creative cakes. A large, box-shaped cake is now being carried into the party. It is plainly decorated and looks rather simple, but it is surely delicious beyond anyone's imagination. Let us cut it into pieces with a knife and serve them to the guests.

Seen from above, the cake is rectangular. It will be cut repeatedly, and on each cut exactly one existing piece is divided into two smaller pieces. Every cut surface is orthogonal to the bottom face (that is, vertical) and is either orthogonal or parallel to a side face. Consequently, every piece is always rectangular when viewed from above, and every side face stays vertical.

The resulting piece sizes may vary greatly and seem unfair, but you need not worry. Guests who want to taste as many kinds of cake as possible tend to prefer smaller pieces, while others prefer larger ones.

Your task is to write a program that simulates the cutting process and reports the size of each piece.

Input

The input is a sequence of datasets. Each dataset has the following format.

n w d
p1 s1
...
pn sn

The first line contains an integer n (0 ≤ n ≤ 100), the number of cuts to perform, followed by integers w and d (1 ≤ w, d ≤ 100), the width and depth of the cake. The cake is placed so that w is the length in the east-west direction and d the length in the north-south direction.

Each of the following n lines describes a single cut, which divides exactly one piece into two. Just before the i-th cut there are exactly i pieces, and each piece has a unique identification number from 1 to i, assigned as follows.

  • The earlier a piece was created, the smaller its identification number.
  • Of the two pieces created together by one cut, the one with the smaller top-view area gets the smaller number. If their areas are equal, either order may be used; the choice does not affect the final answer.

Identification numbers are reassigned after every cut. pi (1 ≤ pi ≤ i) is the identification number of the piece that the i-th cut divides.

si (1 ≤ si ≤ 1000) specifies the starting point of the i-th cut. Starting from the northwest corner of piece pi and moving clockwise along its perimeter for a distance of si (continuing around the perimeter as many times as needed), you reach the starting point. This point is guaranteed never to be one of the four corners of the piece. The i-th cut surface is orthogonal to the side face on which this starting point lies.

The end of the input is indicated by a line containing three zeros.

Output

For each dataset, print on one line the top-view areas of all pieces that exist after the dataset's n cuts have been performed. Print them in ascending order, separated by single spaces. When several pieces have the same area, print that area once for each such piece.