Ferry Loading

Time limit1sMemory limit128 MB

Problem

Before bridges were common, ferries carried cars across rivers. Unlike their seagoing cousins, river ferries run along a guide line and are driven by the river's current. Cars drive onto the ferry in two lanes from one end; the ferry crosses the river, and the cars leave from the other end.

The cars waiting for the ferry form a single queue. Taking them from the front of the queue in order, the operator sends each car to either the left lane (port) or the right lane (starboard) to keep the load balanced. On each lane, the combined length of the cars must not exceed the length of the ferry. Subject to this limit, the goal is to load as many cars as possible, starting with the first car in the queue and continuing in order until a car can no longer be loaded. Decide which lane each car should take so that the number of cars loaded is as large as possible.

Input

The first line contains an integer $L$, the length of the ferry in metres ($1 \le L \le 100$). Each of the following lines gives the length of one car in the queue, an integer in centimetres between $100$ and $3000$ inclusive. A final line contains the integer $0$, marking the end of the input.

Each lane's capacity equals the length of the ferry, i.e. $L \times 100$ centimetres. Cars may be loaded only in queue order, and on neither lane may the combined length of the loaded cars exceed this capacity. Under this rule, load as many cars as possible, starting with the first car and continuing in order until some car can no longer be loaded.

Output

On the first line, print the maximum number of cars that can be loaded onto the ferry. Then, for each loaded car in input order, print one line: port if the car is sent to the left lane, or starboard if it is sent to the right lane.

Several arrangements may load this maximum number of cars, so to make the answer unique, print the one whose sequence of lane labels is lexicographically smallest. Compare the sequences line by line from top to bottom; at any position, port comes before starboard. Equivalently, for each car choose port whenever the remaining cars can still all be loaded.