ABABABAB X76690


Statement
 

pdf   zip

Consider the following formula:

A+B*A+B*A+B*A+BA + B * A + B * A + B * A + B

We can obtain many different values by replacing each AA with an arbitrary number from set π’œ\mathcal A, and each BB with an arbitrary number from set ℬ\mathcal B.

Even more, in this problem we are allowed to place parentheses in any way we want. For example, (A+B)*(A+B)*(A+B)*(A+B)(A+B)*(A+B)*(A+B)*(A+B) 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 MM.

Input

The first line of input contains four numbers: N,M,QA,QBN, M, Q_A, Q_B. We have 1≀N≀161 \leq N \leq 16, 1≀M≀10001 \leq M \leq 1000, 1≀QA,QB≀10001 \leq Q_A, Q_B \leq 1000. NN is the number of operands (8 in the formula above, it always starts with AA).

The second line contains QAQ_A non-negative integers β€” these are the elements of π’œ\mathcal A. Each of them is different, and in range from 00 to 1000010000.

The third line contains QBQ_B non-negative integers β€” these are the elements of ℬ\mathcal B. Each of them is different, and in range from 00 to 1000010000.

Output

Output the number of ways of obtaining at most MM, modulo 1000003.

Public test cases
  • Input

    8 1000 1 1
    1
    1
    

    Output

    429
    
  • Input

    8 1000 2 2
    1 2
    1 2
    

    Output

    109824
    
  • Input

    2 1000 3 3
    400 500 600
    400 500 600
    

    Output

    6
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++