Report 2
Participants of the International Summer School on Programming in Sevastopol (2011) are already acquainted with a unique institution where documents are numbered in an unusual manner. Specifically, 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). Additionally, this institution strictly follows two rules:
Numbers within the specified range are not skipped.
Numbers are arranged in ascending order in the usual sense.
For instance, if the digits 0, 5, 6 are used for even positions and 0 and 7 for odd positions, the initial sequence of numbers would be: 0, 5, 6, 70, 75, 76, 500, 505, 506, 570, 575, 576, 600, ...
It is known that several other organizations have chosen to adopt this style of document numbering.
The Regional Corporate Development Service has decided to prepare for such changes. They have reasonably concluded that a similar organization would apply these document numbering rules to the numbering of pages in its publications, particularly for report pages.
The service requests you to develop a program that, given the sets of digits for even and odd positions and the number of report pages, calculates how many times each digit is used in numbering the pages of the report, assuming that ALL pages are numbered.
Input
The first line of the input file contains three numbers: N, L, and K. N is the number of report pages, while L and K are the number of digits used for even and odd positions, respectively. The second line lists the digits used for even positions, separated by spaces, and the third line lists the digits used for odd positions. Constraints are 1 ≤ N ≤ 10^10, and 2 ≤ L, K ≤ 10.
Output
The output file should contain a single line with exactly ten numbers, each separated by a single space. The first number represents the count of zeros, the second the count of ones, and so on, with the last number representing the count of nines. It is guaranteed that the numbers in the output will be within 10^18.