Taro tells digits to Hanako by laying straight bars on the floor. He forms each digit as one of ten fixed shapes, drawn in the style of a seven-segment display.
Because Taro may not have bars of exactly the right lengths, he cannot always lay the shapes out perfectly. Fortunately, Hanako recognizes a shape as a digit as long as the connection relation between its bars is preserved. Neither the lengths of the bars nor the overall orientation of a shape matters to her, only how the bars are connected. So she can still read stretched or rotated shapes as digits, while she rejects shapes whose connections match no digit.
When one bar touches another, the touching point is an endpoint of at least one of them, and the two bars overlap at exactly one single point; bars never cross, and two touching bars always meet at a right angle. Positions, lengths, and the overall rotation of a shape may change freely, as long as the connection relations are kept. Keeping the connection relations means:
The ten shapes are the ones shown in the original figure. Described in words, each digit is built from straight bars as follows (the words top, bottom, left, right, and middle refer to the segments of a seven-segment display):
Some digit shapes always contain the shapes of other digits. For example, a shape for 9 always contains four shapes for 1, one shape for 4, and two overlapping shapes for 7. Ignore any shape contained inside a larger one, and count only the largest shape formed by each maximal group of mutually connected bars. A single 9 counts as one 9 and adds nothing to the counts of 1, 4, or 7.
Your task is to count how many times each digit appears on the floor.
The input consists of several datasets. Each dataset has the following form:
n
xa_1 ya_1 xb_1 yb_1
xa_2 ya_2 xb_2 yb_2
.
.
.
xa_n ya_n xb_n yb_n
The first line contains $n$, the number of bars. Each of the next $n$ lines describes one bar with four integers $xa$, $ya$, $xb$, $yb$ separated by single spaces: $(xa, ya)$ and $(xb, yb)$ are the coordinates of the two ends of the bar, given in a fixed Cartesian coordinate system. You may assume $1 \le n \le 1000$ and $0 \le xa, ya, xb, yb \le 1000$.
The end of the input is a line containing a single zero.
You may also assume the following:
For each dataset, print a single line containing ten integers separated by single spaces. These integers are the numbers of times the digits $0, 1, 2, \ldots, 9$ appear on the floor, in that order. Print no other characters.