Rectangle
Create a program that determines how to assemble the final rectangle in a sequence using the remaining rectangles by joining them along their sides, without cutting or overlapping any internal parts.
Input
The input begins with a natural number n (n < 15), followed by a sequence of (n + 1) pairs of natural numbers. Each pair represents the length and height of a rectangle. The area of each rectangle does not exceed 1234567890.
Output
Position the (n + 1)-th rectangle such that its origin is at one vertex, with one side aligned along the ordinate axis, ensuring all internal points are within the first quadrant of the Cartesian plane. Each output line must contain n quadruples of non-negative integers that uniquely describe the corresponding arrangement.
In each quadruple, the first two numbers are the coordinates of the rectangle's lower-left vertex, the third number is its index, and the last number is 1 or 0, indicating whether the rectangle is rotated by 90° or not.
The rows should be listed in lexicographical order, and within each row, the quadruples should also be sorted lexicographically.
If it is not possible to assemble the rectangles as described, output the words: "No solution".