Under construction

Still being built. Things may change

Hardware

Time limit1sMemory limit128 MB

Summary
Expand each house-number order into individual numbers, count how many times each digit 0-9 appears, and print the per-digit totals plus the grand total.
Level

Easy3 of 10

Topics
Simulation, Implementation, Math
Solved
No attempts yet

Problem

Ola Clason's hardware store is an old company where most of the work is still done the old-fashioned way. Among other things, the company is the one and only supplier of marble house numbers. These house numbers have become extremely popular with construction companies, especially those building luxury estates. This is great for Ola Clason, but it also creates a small problem: Nisse, who manages the incoming orders, has become a bottleneck in the business.

Most orders look like "Coconut Drive 200, 202, 204, ..., 220", which means every even number between 200 and 220. Nisse's job is to convert such an order into a list of the individual digits (and other symbols) that must be produced.

Your task is to write a program that automates Nisse's work for orders that contain only positive integer house numbers. Nisse will keep handling all special orders (those that include non-digit symbols) by hand.

Input

The first line of input contains a single positive integer nn, the number of orders that follow.

Each order is given as follows:

  • The first line contains the road name for that order. No road name is longer than 50 characters.
  • The second line states the total number of buildings that need new marble numbers in that order.
  • Then come the house-number specifications, one per line. There are two kinds of lines:
    • A single-number line consists of just one house number.
    • A multiple-number line starts with a "+" sign, followed by three positive integers: the first number, the last number, and the interval between consecutive house numbers. The distance between the first and last number is always a multiple of the interval.

A house number never has more than five digits. After the last house-number specification line of an order, the next order follows, if there is one.

Output

For each order, the output consists of 13 lines.

  • The first and second lines are identical to the first two input lines of that order (the road name and the building-count line).
  • Then follow 10 lines describing how many marble digits of each kind are needed, one line per digit from 0 to 9, in the format Make X digit Y, where XX is how many copies of digit YY must be made.
  • The last line states the total number ZZ of digits needed, in the format In total Z digits. If exactly one digit must be produced, the line reads In total 1 digit instead, so that it stays grammatically correct.

Examples3

  1. Example 1

    Input
    1
    Short Street
    23 addresses
    + 101 125 2
    275
    + 100 900 100
    
    Expected output
    Short Street
    23 addresses
    Make 23 digit 0
    Make 22 digit 1
    Make 5 digit 2
    Make 4 digit 3
    Make 1 digit 4
    Make 5 digit 5
    Make 1 digit 6
    Make 4 digit 7
    Make 1 digit 8
    Make 3 digit 9
    In total 69 digits
    
  2. Example 2

    Input
    1
    Main Road
    1 address
    5
    
    Expected output
    Main Road
    1 address
    Make 0 digit 0
    Make 0 digit 1
    Make 0 digit 2
    Make 0 digit 3
    Make 0 digit 4
    Make 1 digit 5
    Make 0 digit 6
    Make 0 digit 7
    Make 0 digit 8
    Make 0 digit 9
    In total 1 digit
    
  3. Example 3

    Input
    2
    First Avenue
    3 addresses
    10
    20
    30
    Second Avenue
    2 addresses
    + 5 15 10
    
    Expected output
    First Avenue
    3 addresses
    Make 3 digit 0
    Make 1 digit 1
    Make 1 digit 2
    Make 1 digit 3
    Make 0 digit 4
    Make 0 digit 5
    Make 0 digit 6
    Make 0 digit 7
    Make 0 digit 8
    Make 0 digit 9
    In total 6 digits
    Second Avenue
    2 addresses
    Make 0 digit 0
    Make 1 digit 1
    Make 0 digit 2
    Make 0 digit 3
    Make 0 digit 4
    Make 2 digit 5
    Make 0 digit 6
    Make 0 digit 7
    Make 0 digit 8
    Make 0 digit 9
    In total 3 digits