You want to choose a room number for an office. To form the number, you must buy digit cards, and you can spend at most M won.
The available digit cards are 0 through N-1, and digit i costs P_i won. You may buy the same digit multiple times, and there is always enough stock. If the room number is not 0, it may not start with 0.
Find the largest room number X that can be made using at most M won. Since X can be very long, print its length and only the front and back parts of the number.