Mobiles

Time limit1sMemory limit128 MB

Problem

Alabama Mobiles Inc. designs and builds mobiles: lightweight kinetic sculptures. A mobile is a bar hung from a string tied at the bar's center. From each end of the bar hangs another string that supports either a small decorative object or a smaller mobile.

A well-designed mobile must be balanced: the weights on the two ends of every bar must be equal so that each bar naturally hangs horizontally. Because every bar is tied at its center, a bar balances exactly when the total weight hanging from its left end equals the total weight hanging from its right end. In addition, the bar lengths must be chosen so that each bar can rotate about its supporting string without ever striking another bar.

You are given a partial design for a mobile. Determine whether it can be balanced and, if so, whether the bars will swing freely without bumping into one another.

You may assume that the bars and strings are weightless compared with the decorative objects, and that every connecting string has the same length. Every mobile contains at least one bar.

Input

The input contains one or more mobile specifications. Within a specification the elements are numbered starting from 1 and increasing by one.

Each element is given on its own line. The line starts with the element's number, followed by a letter that is either B (a bar) or D (a decorative object).

  • For a bar (B): the letter is followed by a floating-point number, the length of the bar, and then two integers, the numbers of the elements hanging from the bar's two ends. Every element except the topmost bar is listed as hanging from exactly one bar end.
  • For a decorative object (D): the letter is followed either by a floating-point number, the object's weight, or by the letter X, meaning its weight is unknown. Each specification contains exactly one X object.

Tokens on a line are separated by one or more spaces.

A specification ends with a line whose element-number position holds a value that is not positive. A value of 0 ends the current specification and more specifications follow; a negative value ends the current specification and marks the end of the input.

Output

For each mobile, print one or two lines.

The first line is either

Object M must have weight NN

or

The mobile cannot be balanced.

Here M is the number of the X object and NN is the weight, printed with exactly two digits after the decimal point, that balances the whole mobile. Print the second form if and only if no positive weight can balance the mobile.

If the mobile can be balanced, print a second line, either

The mobile will swing freely.

or

The mobile will not swing freely.

according to whether every pair of bars stays separated by a positive distance for all rotations of the bars about their strings.