Consider the following formula:
We can obtain many different values by replacing each with an arbitrary number from set , and each with an arbitrary number from set .
Even more, in this problem we are allowed to place parentheses in any way we want. For example, can be a very big number. We don’t like very big numbers.
Output the number of ways we can obtain a result which is at most .
The first line of input contains four numbers: . We have , , . is the number of operands (8 in the formula above, it always starts with ).
The second line contains non-negative integers — these are the elements of . Each of them is different, and in range from to .
The third line contains non-negative integers — these are the elements of . Each of them is different, and in range from to .
Output the number of ways of obtaining at most , modulo 1000003.
Author: Eryk Kopczynski
Generation: 2026-01-25T22:30:02.330Z
© Jutge.org, 2006–2026.
https://jutge.org