13723 - Cookie Monster   

Description

Today, as usual, the cookie monster is picking the cookies to eat for this meal. He is so tired and unable to select the cookies he wants since he was busy preparing for his midterm and didn’t sleep last night. As his good friend, you decided to help him so he doesn’t need to worry about his lunch.

There are n cookies in the shop. For each cookie, there is a number di, representing how yummy the ith cookie is. In general, the larger di is, the more delicious the ith cookie is. However, due to some unknown reasons, the cookie monster especially loves cookies that contain the digit 7 in their di. For example, the digit ‘7’ appears twice in 7927 and appears once in 70. If there are more digits ‘7’ appearing in di for a cookie, the cookie monster would tend to choose that cookie first.

Moreover, here’s your cookie-choosing strategy:

  • For any two cookies, always choose the one that with more ‘7’ appears in di first.
  • If there are two cookies containing the same amount of ‘7’ in their di, choose the one with larger di.

However, the number di does not directly be marked on the wrapper of the cookie. Instead, there is a string si printed on each wrapper, specifying the value of di. The format of si would be like this:
t1|t2|...|tm, where ti is a number shown in hexadecimal.
And the value of di is the concatenate of all decimal notations of ti, for i = 1, 2, …, m. For example, if si = 2C|4|A, then di = 44410.

Now the cookie monster wants to choose k cookies at most for this meal, help him choose the cookies he is going to eat.

Input

The first line contains two integers nk, representing the number of cookies in the shop and the amount cookies you are going to choose, respectively.
The next n lines each contains a string, The 1+ith line specifies the value of si.

Constraints:
≤ ≤ 1000
≤ d≤ 10300
≤ ≤ n
≤ t≤ 7FFFFFFF16 (214748364710)
≤ |si≤ 250

Output

Output k lines, the value of di for each cookie you choose, in the order that the smaller value prints first.

Sample Input  Download

Sample Output  Download

Tags

FlyHighHigh



Discuss