Under construction

Still being built. Things may change

f(A + B)

Time limit1sMemory limit1024 MB

Summary
Given a one-to-one digit mapping f and the images f(A) and f(B), compute f(A+B) for positive integers A and B up to 10^7.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

The set of digits digit\text{digit} is {0,1,2,…,9}\{0, 1, 2, \dots, 9\}. The function ff has domain digit\text{digit} and range digit\text{digit}, and it is a one-to-one correspondence. Although ff is defined on single digits, for convenience, a positive integer X=x1x2x3…xN‾X = \overline{x_1x_2x_3 \dots x_N} with NN digits is mapped by f(X)=f(x1)f(x2)f(x3)…f(xN)‾f(X) = \overline{f(x_1)f(x_2)f(x_3) \dots f(x_N)}. For example, when f(0)=6f(0)=6, f(1)=5f(1)=5, f(3)=0f(3)=0, and f(4)=1f(4)=1, then f(1340)=5016f(1340)=5016.

Given ff and the positive integers f(A)f(A) and f(B)f(B), write a program that computes f(A+B)f(A+B). The positive integers AA, BB, A+BA+B, f(A)f(A), f(B)f(B), and f(A+B)f(A+B) are never given as numbers that start with 0.

Input

The first line contains f(0)f(0) through f(9)f(9), separated by spaces. The second line contains f(A)f(A) and f(B)f(B), separated by a space.

Output

Print f(A+B)f(A+B) on the first line.

Constraints

1≤a,b≤1071 \le a, b \le 10^7

Examples1

  1. Example 1

    Input
    6 5 4 0 1 3 8 9 2 7
    50 16
    
    Expected output
    30