Street Numbers

No attempts yetTime limit1sMemory limit128 MB

Problem

A company that makes metal digits produces the numbers fixed to the front of a house to display its street number. When a new street of houses is built, the company is often asked to supply the numbers for the whole street at once. To avoid waste, the company must work out exactly how many of each digit (0-9) are needed to complete an order.

The builders give the company the range of house numbers used on the new street. Sometimes there is a gap in the houses (for example where there is a school or a sports ground), so the numbers for those positions are not needed.

Input

The input consists of several scenarios. Each scenario begins with three integers $L$, $H$ and $G$. The input ends with a line where all three values are $0$; that terminating line is not processed.

$L$ is the lowest house number on the street and $H$ is the highest ($0 < L \le H \le 999$). $G$ is the number of gaps in the housing that must be taken into account ($0 \le G < 20$).

If $G$ is $0$, the company must supply numbers for every house from $L$ to $H$ inclusive. Otherwise, $G$ gap sections follow $L$ and $H$ on the same line. Each section consists of two integers $L1$ and $H1$ and one of the letters A, E or O, all separated by single spaces. $L1$ is the lowest number of a block of missing houses and $H1$ the highest; $H1$ may equal $L1$ to mark a single missing house ($L \le L1$, $H1 \le H$). The letter A means every house in the range is missing, E means only even-numbered houses are missing, and O means only odd-numbered houses are missing. Gaps never overlap, so no house is excluded more than once.

Output

For each scenario, print one line containing 10 integers separated by single spaces. The integers are the number of each digit required to complete the order, from digit $0$ (leftmost) to digit $9$ (rightmost). If a digit is not required, print $0$ in its place.