Binary Operation

Consider a binary operation ⊙ defined on digits 0 to 9, ⊙:{0, 1, . . . , 9} × {0, 1, . . . , 9} → {0, 1, . . . , 9} such that 0 ⊙ 0 = 0. A binary operation ⊗ is a generalization of ⊙ to the set of non-negative integers, ⊗:Z0+ × Z0+ → Z0+ The result of a ⊗ b is defined in the following way: if one of the numbers a and b has fewer digits than the other in decimal notation, then append leading zeroes to it, so that the numbers are of the same length; then apply the operation digit-wise to the corresponding digits of a and b. Example. Ifa⊙b=abmod10,then5566⊗239=84. Let us define ⊗ to be left-associative, that is, a ⊗ b ⊗ c is to be interpreted as (a ⊗ b) ⊗ c. Given a binary operation ⊙ and two non-negative integers a and b, calculate the value of a⊗(a+1)⊗(a+2)⊗...⊗(b−1)⊗b Input The input file contains several test cases, each of them as described below. The first ten lines of the input file contain the description of the binary operation ⊙. The i-th line of the input file contains a space-separated list of ten digits — the j-th digit in this list is equal to (i−1)⊙(j −1). The first digit in the first line is always 0. The eleventh line of the input file contains two non-negative integers a and b (0 ≤ a ≤ b ≤ 1018). Output For each test case, output on a line by itself a single number — the value of a⊗(a+1)⊗(a+2)⊗ . . . ⊗ (b − 1) ⊗ b without extra leading zeroes. Sample Input 0123456789 1234567890 2345678901 3456789012 4567890123 5678901234 6789012345 7890123456 8901234567 9012345678 0 10

2/2 Sample Output 15