A rectangular painting is made of several axis-aligned rectangles that satisfy all of the following rules:
The sizes and orientations of the photo-rectangles are given and cannot be changed. For every group of co-rectangles you may independently choose whether they are laid out horizontally or vertically. Choose these directions so that the area of the root rectangle is as small as possible, and report that minimum area.
The input contains several test cases. Each test case begins with a line containing two integers $n$ and $d$ ($1 \le n \le 100$, $0 \le d \le 30$), where $n$ is the number of rectangles.
The next $n$ lines describe the rectangles; the $i$-th of these lines describes the rectangle with id $i$. The root rectangle always has id $1$. Let $R_i$ be the set of ids of the rectangles whose super-rectangle is rectangle $i$.
k (where k $= |R_i|$) followed by the k ids in $R_i$, all separated by spaces.0 a b, where $1 \le a \le 30$ and $1 \le b \le 30$ are the lengths of its sides along the x-axis and the y-axis, respectively.The input ends with a line containing 0 0.
For each test case, print a single line containing the minimum possible area of the root rectangle over all valid choices of horizontal/vertical directions for the co-rectangle groups.
An example configuration that achieves the sample answer:
