This page is still under construction.

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

StuPId

Time limit3sMemory limit128 MB

Summary
Given an ID with one unknown digit, use the checksum rule to find the missing digit and print the corrected ID.
Level

Easy2 of 10

Topics
Math, Implementation, Brute force
Solved
No attempts yet

Problem

At DUT, the Dreamland University of Technology, every student has a personal id number with six or seven digits. These are not arbitrary numbers: an id is valid only if its checksum ends in the digit zero.

The checksum is computed as follows. Reading the digits from back to front, multiply them by the repeating factors 9, 3, 7 (the last digit uses 9, the second-to-last uses 3, the third-to-last uses 7, the fourth-to-last uses 9 again, and so on). Then add all of the products together.

For example:

id number :  1  3  9  0  2  7  2
factors   :  9  7  3  9  7  3  9
products  :  9 21 27  0 14 21 18

Here the checksum is 9 + 21 + 27 + 0 + 14 + 21 + 18 = 110. Its last digit is zero, so this id is valid.

Sometimes a student's handwriting is so bad that a teaching assistant cannot read one of the digits. You must help in the special case where exactly one digit is unreadable. Because 9, 3, and 7 are each relatively prime to 10, the missing digit is always uniquely determined. The students always start out focused, so the first digit is always readable and is never zero.

Input

The first line contains the number of scenarios. Each scenario is given on a single line: an id number of length six or seven in which exactly one digit has been replaced by a question mark (?).

Output

For each scenario, first print a line "Scenario #i:", where i is the scenario number starting at 1. On the next line, print the complete, corrected id number. Separate consecutive scenarios with a blank line.

Examples1

  1. Example 1

    Input
    4
    13?0272
    3?5678
    345?78
    314?592
    
    Expected output
    Scenario #1:
    1390272
    
    Scenario #2:
    335678
    
    Scenario #3:
    345778
    
    Scenario #4:
    3146592