Teddies

No attempts yetTime limit1sMemory limit128 MB

Problem

A well-known toy company makes teddy bears for children. There are four models: A1, A2, B1, and B2. Each model name consists of one letter (A or B) and one digit (1 or 2).

The company recently found a latent defect. If three teddies whose model names share the same letter, or three teddies whose model names share the same digit, are placed next to one another in a row, all three are damaged beyond repair.

A row of teddies is safe if no three consecutive teddies share the same letter and no three consecutive teddies share the same digit.

Byteasar has collected these teddies and loves lining them up. Given how many teddies he owns of each model, count how many different safe rows he can form. Teddies of the same model are indistinguishable. Since the count can be large, output it modulo 1,000,000.

Input

One line with four non-negative integers nA1n_{A1}, nA2n_{A2}, nB1n_{B1}, nB2n_{B2}, separated by single spaces (0nA1,nA2,nB1,nB2380 \le n_{A1}, n_{A2}, n_{B1}, n_{B2} \le 38). They are the numbers of teddies of models A1, A2, B1, and B2, respectively. The total number of teddies is always at least 1.

Output

Print, on a single line, the number of safe rows modulo 1,000,000.

Hint

When nA1=0n_{A1}=0, nA2=1n_{A2}=1, nB1=2n_{B1}=2, nB2=1n_{B2}=1, the six safe rows are: B1 A2 B1 B2, B1 A2 B2 B1, B2 A2 B1 B1, B2 B1 A2 B1, B1 B2 A2 B1, and B1 B1 A2 B2.