eolymp
bolt
Try our new interface for solving problems
Problems

House Numbers

House Numbers

NarmakSung has a hardware shop that makes new digit plates for house numbers. If a house number is \textbf{195}, for example, he has to create one plate for digit \textbf{1}, one for digit \textbf{9}, and one for digit \textbf{5}. But, the orders are not always that simple. He may get orders to make digit plates, for example, for all houses in one side of a street. Since making several plates of the same digit costs much less than making all digits for each house one by one, he wants to know, for a big order he receives, how many of each digit plate he has to make. \InputFile The first number in the input line, \textbf{t} (\textbf{1} ≤ \textbf{t} ≤ \textbf{10}) is the number of orders. Following this, \textbf{t} orders are written in the input file. Each order starts with a line containing a street name, an arbitrary string of length at most \textbf{50} characters. The second line contains a single integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10}), the number of sub-orders, followed by \textbf{N} lines of sub-orders. Sub-orders are of three kinds: \begin{itemize} \item A single house number: in this case, the sub-order line contains only a single integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{9999}) \item A series of house numbers: in this case, the sub-order line starts with a '\textbf{+}', followed by three integer numbers \textbf{a}, \textbf{b}, \textbf{c} (\textbf{1} ≤ \textbf{a}, \textbf{b}, \textbf{c} ≤ \textbf{9999}). This means that NarmakSung has to make plates for house numbers from \textbf{a} up to \textbf{b} with distance of \textbf{c}. That is, digit plates have to be made for house numbers \textbf{a}, \textbf{a+c}, \textbf{a+2c}, ..., \textbf{b}. We assume that \textbf{a} < \textbf{b}, \textbf{b - a} is \textbf{a} multiple of \textbf{c}, and \textbf{c} ≤ \textbf{b - a}. \item A series of house numbers to be excluded: this kind of sub-orders specifies that a series of house numbers should not be made. In this case, the sub-order line starts with a '\textbf{-}', followed by three integer numbers with exactly the same conditions as in the previous case. \end{itemize} Note that if a house number is ordered more than once in two separate sub-orders, it is counted only once if it is not excluded at all (like number \textbf{100} in the second test case in the sample input). Also, if a house number is excluded somewhere in the test case, it cancels any order for that number, even if it appears later in the test case (like number \textbf{500} in the second sample). Note that it is possible to exclude some numbers that do not appear in other orders at all. In this case, these numbers are ignored (like \textbf{900} in the second sample). \OutputFile One set of output data is written for each input order consisting of \textbf{13} lines. Each set starts with one line containing the street name exactly as appeared in the input order. The next line must be of the form C addresses where \textbf{C} is the total number of house numbers to be made. In the special case of \textbf{C = 1}, the output line should be \textbf{1} address. The next \textbf{10} lines should be of the following form: Line \textbf{i} should contain the number of digit plates needed to be made for digit \textbf{i}. These \textbf{10} lines are on the format "\textbf{Make X digit Y}" where \textbf{X} is how many copies of digit \textbf{Y} they need to make. The last line states the total number \textbf{Z} of digits needed, on the format "\textbf{In total Z digits}". If there is only one digit to produce, it should say, "\textbf{In total 1 digit}", in order to be grammatically correct. The output should be case-sensitive.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2 
Azadi Street
2
+ 101 103 2 
275 
Sharif Highway
3
100
- 500 900 100
+  100 800 100
Output example #1
Azadi Street
3 addresses
Make 2 digit 0
Make 3 digit 1
Make 1 digit 2
Make 1 digit 3
Make 0 digit 4
Make 1 digit 5
Make 0 digit 6
Make 1 digit 7
Make 0 digit 8
Make 0 digit 9
In total 9 digits
Sharif Highway
4 addresses
Make 8 digit 0
Make 1 digit 1
Make 1 digit 2
Make 1 digit 3
Make 1 digit 4
Make 0 digit 5
Make 0 digit 6
Make 0 digit 7
Make 0 digit 8
Make 0 digit 9
In total 12 digits