This page is still under construction.

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

ID Key

Time limit1sMemory limit128 MB

Summary
Add the digit sum of each 13-digit ID to ten times its last three digits, then keep four digits as the key.
Level

Easy1 of 10

Topics
Implementation
Solved
No attempts yet

Problem

An ID card carries a 13 digit number. From those 13 digits you compute the ID Key, a four digit number, with these steps.

  1. Add up all 13 digits.
  2. Take the number formed by the last three digits and multiply it by 10.
  3. Add the value from step 1 and the value from step 2. If the sum has more than four digits, keep only its last four digits. If the sum is smaller than 1,000, add 1,000 to it. The four digit number left at the end is the ID Key.

Input

The first line has the number of people NN (1≤N≤1001 \le N \le 100). Each of the next NN lines has one person's 13 digit ID number. A number may start with 0.

Output

Print each person's ID Key on its own line, in the order the people are given. Always print four digits and keep any leading zero.

Examples1

  1. Example 1

    Input
    4
    1234567890123
    0213617002001
    9998888997899
    1099999999999
    
    Expected output
    1281
    1033
    9100
    0090