Necklace Problem

View as PDF

Submit solution


Points: 4
Time limit: 2.0s
Memory limit: 64M

Author:
Problem types

jsumabat has a necklace. This necklace consists solely of beads labelled with a single digit number between 1 and 9 both inclusive. The order of the beads follow a pattern:
Starting from two single digit numbers, add them together add a bead labelled with the ones digit of the sum. Repeat this process using the last two beads until you arrive at the original first two numbers.
Given the starting numbers for several necklaces, print the pattern on each.

Input

The first line n (1 \le n \le 81) represents the number of necklaces jsumabat has.
The next n lines each contain two space separated single digit integers representing the starting two numbers.

Output

For each necklace, print on a new line the pattern of beads on it with each digit separated by a space.

Sample Input

2
1 8
3 4

Sample Output

1 8 9 7 6 3 9 2 1 3 4 7 1 8
3 4 7 1 8 9 7 6 3 9 2 1 3 4

Comments


  • 2
    Henry_Zhang  commented on Oct. 22, 2019, 1:29 p.m. edit 2

    David, there are some problems with this question. My fellow peers do not know why their code doesn't work, and I cannot find the issue either. Could you please look into this for my buddies? Thanks.


    • 1
      David  commented on Oct. 22, 2019, 4:19 p.m. edited

      Make sure each sequence is on a new line, I've added that clarification to the problem description. For anything else, use the editorial I've just added as a reference if you are stuck.

      In regards to http://tssoj.me/submission/8976 check output for 5 5. Let me know if there's another submission you want looked at.