Participants of the International Summer School on Programming in Sevastopol might recall a unique institution where document numbers are assigned in an unusual manner. In this system, one set of digits is used for odd positions and another set for even positions (positions are counted from right to left, starting at zero). This institution adheres to two strict rules:
Numbers within the specified constraints are not skipped.
Numbers are listed in ascending order in the usual numerical sense.
For instance, if the digits , , are used for even positions and and for odd positions, the sequence of numbers begins as follows: , , , , , , , , , , , , , ...
Reportedly, several other organizations have decided to implement this style of document numbering.
The Regional Corporate Development Service is preparing for such changes. They have logically deduced that an organization might extend these numbering rules to the pagination of its publications, specifically for numbering pages in a report.
Your task is to write a program that, given the sets of digits for even and odd positions and the known count of each digit used in the pagination of this report (assuming ALL pages are numbered starting from ), calculates the total number of pages in the report. If the information provided does not allow for determining the total number of pages, output NO.
The first line of the input contains two numbers and , representing the number of digits used in even and odd positions, respectively. The second line lists the digits used for even positions, and the third line lists the digits used for odd positions (2 \le L, K \le 10). The fourth line contains ten numbers separated by spaces. Each number indicates the count of zeros, ones, and so on, up to nines, used in numbering the pages of the report. These counts do not exceed 10^{10}.
The output should be a single line containing the answer.
Example 1