eolymp
bolt
Try our new interface for solving problems
Problems

Electronic lock

Electronic lock

Kowalski decided to make an electronic lock on his new invention. The lock is a sequence of 7-segment indicators. However, he did not add a full panel for entering numbers, so not all numbers can be used in the password. For the password on the lock, Kowalski wants to use some integer without leading zeros.

Kowalski can't read, but he can count. Therefore, he wants exactly n segments (single segments that make up 7-segment indicators) to light up when entering a password. Also, Kowalski does not want his password to be picked up too quickly, so among all the suitable passwords, he wants to find the one that matches the maximum number.

prb11119.gif

Help Kowalski find the right number. It is guaranteed that at least one suitable password exists.

Input

The first line contains two integers n and m (2n105, 1m10) - the required number of burning segments when displaying the number and the number of available digits. The next line contains m digits in ascending order that can be used.

Output

Print one number - the desired password. It must not contain leading zeros. It is guaranteed that at least one suitable password always exists.

Time limit 1 second
Memory limit 128 MiB
Input example #1
7 8
0 2 3 4 5 6 8 9
Output example #1
8
Input example #2
6 1
0
Output example #2
0
Source 2020 Cycle of Internet Olympiads for schoolchildren, Fifth team contest, Novemver 28, Problem B