Author: | Антон Карабанов | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 512 Mb | |
Output file: | Standard output |
Oh, those math lessons! Today, for example was the fourth test on the subject. To those who finished ahead of time the teacher offered an extra task for bonus points.
Two n-digit numbers are written on the blackboard, first composed of only the digit d1, second — of only the digit d2. Determine which digit occupies position k in the sum of those numbers. Positions are numbered left to right starting from 1.
You want bonus points, don't you?
Four lines of input contain four integers: n, d1, d2 and k. It is guaranteed that k is correct.
Output a single decimal digit — answer to the problem.
1 ≤ n ≤ 109
1 ≤ k ≤ n + 1
1 ≤ d1, d2 ≤ 9
Sample has n = 2 (adding two-digit numbers), d1 = 5 (first number is 55), d2 = 8 (second number is 88). Sum is 55 + 88 = 143. k = 1 (teacher asks the first digit of the result). The digit at first position of the number 143 is 1.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|