loj#P3480. 「ROIR 2021 Day 2」A+B

「ROIR 2021 Day 2」A+B

Description

Translated from ROIR 2021 Day2 T4 A+B on this website.

There are three integers a, b, ca,~b,~c with length nn which may consist of prefix zeros with the following layout that has three lines and nn columns.

a
b
c

Your task is to find the number of ways arranging the columns in which the three integers x, y, zx,~y,~z horizontally read satisfies that x+y=zx+y=z and that all those numbers have no prefix zeros.

Since it is possible that large amount of solutions exist, it is only required to output the number of solutions mod109+7\bmod 10^9+7.

Input Format

Three lines with each line consists of an integer of length nn.

Output Format

The number of solutions mod109+7\bmod 10^9+7.

123
123
246
6
01
02
03
1
01211
12099
23300
4
121
214
999
0

Constraints

For all test data, it is guaranteed that 2n2×1052\le n\le 2\times 10^5.

Subtask # Additional Constraints Score
11 n6n\le 6 77
22 n18n\le 18 1414
33 n200n\le 200, with no 00 in numbers 1515
44 n200n\le 200 55
55 n750n\le 750, with no 00 in numbers 1717
66 n750n\le 750 55
77 There are no 00 in numbers 2020
88 No Additional Constraints 1717