This page is still under construction.

Parts of this page are still being built. What you see may change.

Spinner Lock Simulation

Interview

Time limit1sMemory limit128 MB

Summary
Given the starting digits of a spinner lock and a sequence of button labels, add each label's digits to the wheels modulo 10 and print the final readout.
Level

Easy1 of 10

Topics
Simulation, Implementation, Math, Array
Solved
No attempts yet

Problem

Simulate a digit spinner lock.

There is a row of DD spinner wheels, each labeled sequentially with the digits 00 through 99, similar to the dial on a briefcase combination lock.

Below the wheels are BB buttons, each carrying a label that is DD digits long. Pressing a button advances every wheel forward by the digit in the corresponding position of that button's label. A wheel wraps from 99 back to 00 (that is, each wheel is taken modulo 1010).

For example, if D=4D = 4 and you press the button labeled 1000, only the first wheel advances by one and the others stay put. Pressing the button labeled 1002 advances the first wheel by one and the fourth wheel by two, leaving the two middle wheels unchanged.

Given the starting positions of the wheels and the buttons that are pressed, output the final readout of the wheels after all buttons have been pressed in order.

Input

The first line contains DD digits giving the starting positions of the wheels (1≤D≤101 \le D \le 10).

Each of the following lines contains the label of the next button pressed, in order; every label is DD digits long. Button lines continue until end of input, and there may be no buttons at all.

Output

Output the final readout of the wheels after all buttons have been pressed, as a single line of DD digits. Print leading zeros as-is.

Examples1

  1. Example 1

    Input
    0001
    1003
    0206
    0034
    1111
    1003
    
    Expected output
    3348