King of Operations

Time limit1sMemory limit128 MB

Problem

There is an operator $\odot : {0,1,\dots,9} \times {0,1,\dots,9} \to {0,1,\dots,9}$ that always satisfies $0 \odot 0 = 0$.

Using this operator we define another operator $\otimes$ on non-negative integers. For two non-negative integers $a$ and $b$, the value $a \otimes b$ is computed digit by digit: the digit at the $i$-th position counting from the right equals ($i$-th digit of $a$) $\odot$ ($i$-th digit of $b$). If the two numbers have different lengths, the shorter one is padded with leading zeros so the positions line up.

For example, suppose $x \odot y = (x \times y) \bmod 10$. Then $5566 \otimes 239$ is computed as follows: first pad $239$ to $0239$, then compute each position $6 \odot 9 = 4$, $6 \odot 3 = 8$, $5 \odot 2 = 0$, $5 \odot 0 = 0$, so the result is $0084$, i.e. $84$.

Given the table of the operator $\odot$ and two non-negative integers $a$ and $b$ ($a \le b$), compute $a \otimes (a+1) \otimes (a+2) \otimes \dots \otimes (b-1) \otimes b$.

The operator $\otimes$ is evaluated from left to right, i.e. $a \otimes b \otimes c = (a \otimes b) \otimes c$.

Input

The first $10$ lines each contain $10$ numbers. The $j$-th number on the $i$-th line is the value of $(i-1) \odot (j-1)$ (for $1 \le i, j \le 10$). $0 \odot 0$ is always $0$.

The $11$-th line contains two integers $a$ and $b$ separated by a space ($0 \le a \le b \le 10^{18}$).

Output

Print the result of combining every number from $a$ to $b$ with $\otimes$. Do not print unnecessary leading zeros (print $0$ if the result is $0$).