Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer. 

The poor boy was very upset because of that. He was so sad that he punched some kind of scoreboard with numbers. The numbers are displayed in the same way as on an electronic clock: each digit position consists of $7$ segments, which can be turned on or off to display different numbers. The picture shows how all $10$ decimal digits are displayed: 

 [Image] 

After the punch, some segments stopped working, that is, some segments might stop glowing if they glowed earlier. But Denis remembered how many sticks were glowing and how many are glowing now. Denis broke exactly $k$ segments and he knows which sticks are working now. Denis came up with the question: what is the maximum possible number that can appear on the board if you turn on exactly $k$ sticks (which are off now)? 

It is allowed that the number includes leading zeros.


-----Input-----

The first line contains integer $n$ $(1 \leq n \leq 2000)$  — the number of digits on scoreboard and $k$ $(0 \leq k \leq 2000)$  — the number of segments that stopped working.

The next $n$ lines contain one binary string of length $7$, the $i$-th of which encodes the $i$-th digit of the scoreboard.

Each digit on the scoreboard consists of $7$ segments. We number them, as in the picture below, and let the $i$-th place of the binary string be $0$ if the $i$-th stick is not glowing and $1$ if it is glowing. Then a binary string of length $7$ will specify which segments are glowing now.

 [Image] 

Thus, the sequences "1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011" encode in sequence all digits from $0$ to $9$ inclusive.


-----Output-----

Output a single number consisting of $n$ digits  — the maximum number that can be obtained if you turn on exactly $k$ sticks or $-1$, if it is impossible to turn on exactly $k$ sticks so that a correct number appears on the scoreboard digits.


-----Examples-----
Input
1 7
0000000

Output
8
Input
2 5
0010010
0010010

Output
97
Input
3 5
0100001
1001001
1010011

Output
-1


-----Note-----

In the first test, we are obliged to include all $7$ sticks and get one $8$ digit on the scoreboard.

In the second test, we have sticks turned on so that units are formed. For $5$ of additionally included sticks, you can get the numbers $07$, $18$, $34$, $43$, $70$, $79$, $81$ and $97$, of which we choose the maximum  — $97$.

In the third test, it is impossible to turn on exactly $5$ sticks so that a sequence of numbers appears on the scoreboard.

Difficulty: interview

Starter code:

Solutions:
class Solution:
    def __init__(self):
        self.n, self.k = list(map(int, input().split()))
        self.s = [input() for i in range(0, self.n)]
        self.state = [
            (119, 6),
            (36, 2),
            (93, 5),
            (109, 5),
            (46, 4),
            (107, 5),
            (123, 6),
            (37, 3),
            (127, 7),
            (111, 6),
        ]
        self.p = []
        self.dp = [[False for j in range(0, self.k + 1)] for i in range(0, self.n)]

    def solve(self):
        for a in self.s:
            state = int(a[::-1], 2)
            stick = a.count("1")
            v = []
            for i, (dState, dStick) in enumerate(self.state):
                if dState & state == state:
                    v.append((i, dStick - stick))
            self.p.append(v)

        for i in range(self.n - 1, -1, -1):
            for j, stick in self.p[i]:
                if i == self.n - 1:
                    if stick <= self.k:
                        self.dp[i][stick] = True
                else:
                    for d in range(stick, self.k + 1):
                        self.dp[i][d] |= self.dp[i + 1][d - stick]
        if not self.dp[0][self.k]:
            return "-1"

        result = ""

        for i, v in enumerate(self.p):
            for j, stick in v[::-1]:
                ok = (self.k == stick) if i == self.n - 1 else (self.k >= stick and self.dp[i + 1][self.k - stick])
                if ok:
                    self.k -= stick
                    result += str(j)
                    break
        return result
            

print(Solution().solve())



from collections import deque

nums = [0b1110111, 0b0010010, 0b1011101, 0b1011011, 0b0111010, 0b1101011, 0b1101111, 0b1010010, 0b1111111, 0b1111011]
n, k = list(map(int, input().split()))
innums = []
for i in range(n):
    innums.append(int(input(), 2))

sdp = [[30000]*10 for i in range(1<<7)]

for i in range(1<<7):
    for j in range(10):
        # possible to append
        if (i & nums[j]) == i:
            raw = nums[j] - i
            count = 0
            while raw:
                count += 1
                raw -= raw & (-raw)
            sdp[i][j] = count

dp = [[False] * (k + 1) for i in range(n + 1)]

dp[n][0] = True
for idx, num in reversed(list(enumerate(innums))):
    for cost in sdp[num]:
        for k_ in range(cost, k + 1):
            dp[idx][k_] |= dp[idx+1][k_- cost]
if not dp[0][k]:
    print(-1)
else:
    cur_k = k
    ans = []
    for idx, num in enumerate(innums):
        for i, cost in reversed(list(enumerate(sdp[num]))):
            if cost > cur_k:
                continue

            if dp[idx+1][cur_k - cost]:
                cur_k -= cost
                ans.append(i)
                break
    print(''.join(map(str, ans)))