Harryxun/stf_run huggingface dataset:
def check(X,Y):
    Hs = []
    for x,y,h in xyh:

        if h > 0:
            H = h + abs(X-x) + abs(Y-y)
            Hs.append(H)
        else:
            if abs(X-x) + abs(Y-y) < H:
                return False
    if len(set(Hs)) == 1:
        print(X,Y,Hs[0])
        return True

N = int(input())

xyh = [tuple(map(int,input().split())) for _ in range(N)]

for i in range(101):
    for j in range(101):
        if check(i,j):
            exit()


### FIXED CODE ###

N = int(input())

xyh = []
not_zero = -100
flag_zero = True

for i in range(N):
    x,y,h = map(int,input().split())
    if h > 0 and flag_zero:
        not_zero = i
        flag_zero = False
    xyh.append([x,y,h])

for i in range(101):
    for j in range(101):

        Cx = i
        Cy = j
        H = xyh[not_zero][2] + abs(Cx-xyh[not_zero][0]) + abs(Cy-xyh[not_zero][1])
        ans = True

        for x,y,h in xyh:
            tmp_h = h+abs(Cx-x)+abs(Cy-y)
            if h>0:
                if tmp_h != H:
                    ans = False
                    break
            else:
                if H - abs(Cx-x) -abs(Cy-y) > 0:
                    ans = False
                    break
            
        if ans:
            print(Cx,Cy,H)
            exit()
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
N =n*(n-1)//2

"""
a = [[min(i,int(j)-1)+max(i,int(j)-1)*(max(i,int(j)-1)-1)//2 for j in readline().split()] for i in range(n)]
g = [[] for i in range(N)]
p = [[] for i in range(N)]
for i in range(n):
    for j in range(n-2):
        g[a[i][j]].append(a[i][j+1])
        p[a[i][j+1]].append(a[i][j])
"""

a = [[int(j)-1 for j in readline().split()] for i in range(n)]

g = {(i,j): [] for i in range(n) for j in range(i+1,n)}
p = {(i,j): [] for i in range(n) for j in range(i+1,n)}
for i in range(n):
    for j in range(n-2):
        if i < a[i][j]:
            ij = (i, a[i][j])
        else:
            ij = (a[i][j],i)
        if i < a[i][j+1]:
            ijj = (i, a[i][j+1])
        else:
            ijj = (a[i][j+1],i)
        g[ij].append(ijj)
        p[ijj].append(ij)

print(g)

"""
トポロジカルソート
DAG なら
g: グラフの隣接行列
p: 逆辺の隣接行列

q をheapq にしたりすると、辞書順にとりだしたりとかができる。
"""
def topological_sort_queue(g,p):
#    indegree = [len(v) for v in p] # 流入辺の数を数えた配列
#    q = [i for i, c in enumerate(indegree) if c == 0] #流入辺0の点の集合
    indegree = {v:len(vc) for v,vc in p.items()} # 流入辺の数を数えた配列
    q = [i for i, c in indegree.items() if c == 0] #流入辺0の点の集合
    L = [] #ソート結果をためておく配列

    ans = {i:0 for i in g}
    a = 0
    print(p)
    print(indegree)
    print(q)
    while q:
        v = q.pop()
        L.append(v)
        for c in g[v]: #配る
            ans[c] = max(ans[c],ans[v]+1)
            a = max(a,ans[c])
            indegree[c] -= 1 #辺 node -> child を削除する
            if indegree[c] == 0:
                q.append(c)
    if len(L) != N:
#        print("サイクル検出")
        return -1
    else:
#        return(L)
        return(a+1)        

print(topological_sort_queue(g,p))

assert n!=3

### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
a = [[min(i,int(j)-1)+max(i,int(j)-1)*(max(i,int(j)-1)-1)//2 for j in readline().split()] for i in range(n)]

N =n*(n-1)//2

g = [[] for i in range(N)]
p = [[] for i in range(N)]

for i in range(n):
    for j in range(n-2):
        g[a[i][j]].append(a[i][j+1])
        p[a[i][j+1]].append(a[i][j])
        
#print(g)
#print(p)

ans = [0]*(N)

indegree = [len(v) for v in p] # 流入辺の数を数えた配列
Source = [i for i, c in enumerate(indegree) if c == 0] #流入辺0の点の集合
#L = [] #ソート結果をためておく配列
num = 0
while Source:
    node = Source.pop()
    #L.append(node)
    num += 1
    for child in g[node]:
        indegree[child] -= 1 #辺 node -> child を削除する
        if ans[child] < ans[node]+1: ans[child] = ans[node]+1     
        if indegree[child] == 0:
            Source.append(child)

#print(num)
if num != N:
    print(-1)
else:
    print(max(ans)+1)

#print(ans)
H, W = map(int, input().split())
h, w = map(int, input().split())

List = []
for i in range(H):
    l = []
    for j in range(W):
        l.append(1)
    List.append(l)

for i in range(h):
    del List[i]

for j in range(w):
    for i in range(len(List)):
        del List[i][j]

count = 0
for i in range(len(List)):
    count = count + len(List[i])

print(count)


### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())

List = []
for i in range(H):
    l = []
    for j in range(W):
        l.append(0)
    List.append(l)

for i in range(h):
    for j in range(W):
        List[i][j] = 1
for i in range(H):
    for j in range(w):
        List[i][j] = 1

count = 0
for i in range(H):
    count += List[i].count(0)

print(count)
n=int(input())
string=""

while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n/(-2)
if n==0:
    string="0"
    
print(string)

### FIXED CODE ###

n,k=(int(i) for i in input().split())
if n%k==0:
    print(0)
else:
    print(1)
n = int(input())
for i in range(n):
    if (i+1)**2 > n:
        break
    elif (i+1)**2 < n:
        ans = (i + 1)**2
print(ans)


### FIXED CODE ###

n = int(input())
for i in range(n):
    if (i+1)**2 > n:
        break
    elif (i+1)**2 <= n:
        ans = (i + 1)**2
print(ans)
A1 = int(input())
A2 = int(input())
A3 = int(input())
if A1 + A2 + A3 >= 22:
    print("burst")
else:
    print("win")


### FIXED CODE ###

[A1, A2, A3] = list(map(int,input().split()))
if A1 + A2 + A3 >= 22:
    print("bust")
else:
    print("win")
k = int(input())
a, b = map(int, input().split())
if b < k:
  print("NG")
else:
  i = 1
  while i*k <= b:
    if i*k >= a:
      print("OK")
      break
    else:
      i += 1
if i*k > b:
  print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
i = 1
while k*i < a:
  i += 1
if k*i <= b:
  print("OK")
else:
  print("NG")
N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
Y = [X[i] if X[i][1]<=T for i in range(N)]
print(Y)

### FIXED CODE ###

N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
Y = [x for x in X if x[1]<=T]
Z = [y[0] for y in Y]
print("TLE" if Y==[] else min(Z))
n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
num2 = max([k for k in a if k != num])
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)

### FIXED CODE ###

n = int(input())
a = list(int(input()) for _ in range(n))

max_list = sorted(a,reverse=True)[:2]
num = max_list[0]
num2 = max_list[1]

for i in range(n):
    if a[i] < num:
        print(num)
    else:
        print(num2)
import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

exps = [get_exp_value(i) for i in range(100)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)


### FIXED CODE ###

import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

exps = [get_exp_value(i) for i in range(200001)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def lcm(a, b):
    return int(a * b / gcd(a, b))

n = input()
a_li = list(map(int,input().split()))

lcm_a = 0
for i in range(len(a_li)) :
    if i == 0 :
        lcm_a = a_li[i]
    else :
        lcm_a = lcm(lcm_a, a_li[i])

m = lcm_a - 1
f = 0
for i in range(len(a_li)) :
    f = f + m % a_li[i]

print(f)

### FIXED CODE ###

n = input()
a_li = list(map(int,input().split()))

f = 0
for i in range(len(a_li)) :
    f = f + a_li[i] - 1

print(f)
n, m, c = map(int, input().split())
B = [*map(int, input().split())]
ans = 0

for i in range(n):
    cnt = c
    A = [*map(int, input().split())]
    for j in range(m):
        cnt += A[j] * B[j]
    if cnt > 0:
        ans += 1

print(ans)

### FIXED CODE ###

n, m, c = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for i in range(n):
    cnt = c
    A = list(map(int, input().split()))
    for j in range(m):
        cnt += A[j] * B[j]
    if cnt > 0:
        ans += 1

print(ans)
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)
g2=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g2[i][j]=int(arr[i][j])

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
d=floyd_warshall(g2)
for i in range(n):
  ans=max(ans,int(max(d[i])+1))
print(ans)

### FIXED CODE ###

from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)
g2=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g2[i][j]=int(arr[i][j])

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
d=floyd_warshall(g2)
for i in range(n):
  ans=max(ans,int(max(d[i])+1))
print(ans)
import sys

operators = {
    "+": lambda a, b: a + b,
    "-": lambda a, b: a - b,
    "*": lambda a, b: a * b,
    "/": lambda a, b: a // b,
    }

for line in sys.stdin:
    raw_a, op, raw_b = line.rstrip().split()
    if op == "?":
        break

    a, b = map(int, [raw_a, raw_b])
    result = operators[op](a, b)

    print(result)

### FIXED CODE ###

import math

r = float(input())

area = math.pi * r ** 2
circumference = 2 * math.pi * r

print("%.6f %.6f" % (area, circumference))
def isok(arg):
    x = 0
    for i in a:
        if arg - i >= 0:
            if arg-i <= 10**5:
                x += cs[arg-i]
        else:
            x += n
    if x >= m:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,m = map(int,input().split())
a = list(map(int,input().split()))
cs = [0]*(10**5+1)
for i in a:
    cs[i] += 1
for i in range(10**5):
    cs[10**5-i-1] += cs[10**5-i]
h = bisect(10**5*2+1,0)
count = 0
ans = 0
for i in a:
    num = max(0,h-i)
    if num <= 10**5:
        ans += 2*i*cs[num]
    count += cs[num]
ans -= (count-m)*h
print(ans)


### FIXED CODE ###

def isok(arg):
    x = 0
    for i in a:
        if arg - i >= 0:
            if arg-i <= 10**5:
                x += cs[arg-i]
        else:
            x += n
    if x >= m:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,m = map(int,input().split())
a = list(map(int,input().split()))
cs = [0]*(10**5+1)
for i in a:
    cs[i] += 1
for i in range(10**5):
    cs[10**5-i-1] += cs[10**5-i]
h = bisect(10**5*2+1,0)
count = 0
ans = 0
for i in a:
    num = max(0,h-i)
    if num <= 10**5:
        ans += 2*i*cs[num]
        count += cs[num]
ans -= (count-m)*h
print(ans)
def dfs(num):
    if dp[num] != -1:
        return dp[num]

    res = 0
    for obj in G[num]:
        res = max(res, dfs(obj) + 1)

    dp[num] = res
    return res


N, M = map(int, input().split())

dp = [-1] * (N + 1)
G = {i:[] for i in range(N + 1)}

for _ in range(M):
    x, y = map(int, input().split())
    G[x - 1].append(y - 1)

res = 0
for i in range(N):
    res = max(res, dfs(i))

print(res)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

#import math
#import numpy as np
#= int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
def dfs(num):
    if dp[num] != -1:
        return dp[num]

    res = 0
    for obj in G[num]:
        res = max(res, dfs(obj) + 1)

    dp[num] = res
    return res


N, M = map(int, input().split())

dp = [-1] * N
G = {i:[] for i in range(N)}

for _ in range(M):
    x, y = map(int, input().split())
    G[x - 1].append(y - 1)

res = 0
for i in range(N):
    res = max(res, dfs(i))

print(res)
n=int(input())
l=[int(i) for i in input().split()]
l.sort(reverse=True)
num=0
d=0
ans=1
A=False
while d<n:
  if l[d]==l[d+1]:
    ans*=l[d]
    num+=1
    i
    d=d+2
  if num==2:
    A=True
    break
if A:
  print(ans)
else:
  print(0)
    

### FIXED CODE ###

n=int(input())
l=[int(i) for i in input().split()]
from collections import Counter
lst=list(Counter(l).items())
lst.sort(reverse=True)
num=0
for i in range(n):
    if lst[i][1]>3:
        if num==0:
            ans=lst[i][0]**2
            num+=2
            break
        elif num==1:
            ans*=lst[i][0]
            num+=1
            break
    elif 1<lst[i][1]<=3:
        if num==0:
            ans=lst[i][0]
            num+=1
        elif num==1:
            ans*=lst[i][0]
            num+=1
            break
    else:
        continue
if num==2:
    print(ans)
else:
    print(0)
# coding: utf-8
import numpy as np

a,b,c = map(long,input().split())

# print(a,b,c)
# if np.sqrt(a)+np.sqrt(b)<np.sqrt(c):
#     print("Yes")
# else:
#     print("No")
d = c-a-b
if d>0 and 4*a*b<d*d :
    print("Yes")
else:
    print("No")


### FIXED CODE ###

# coding: utf-8
import numpy as np

a,b,c = map(int,input().split())

# print(a,b,c)
# if np.sqrt(a)+np.sqrt(b)<np.sqrt(c):
#     print("Yes")
# else:
#     print("No")
d = c-a-b
if d>0 and 4*a*b<d*d :
    print("Yes")
else:
    print("No")
n = list(input())
for i in 3:
    if n[i] == "1":
        n[i] = "9"
    elif n[i] == "9":
        n[i] = "1"
for j in 3:
    print(j, end = "")

### FIXED CODE ###

n = list(input())

for i in range(3):
    if n[i] == "1":
        n[i] = "9"
    elif n[i] == "9":
        n[i] = "1"

for j in range(3):
  print(n[j], end="")
def solv():
    s = sorted(input())
    t = sorted(input(),reverse=True)

    if(s<t):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solv()
    

### FIXED CODE ###

import math

def solv():
    a, b = map(int, input().split())
    x = (a + b)/2
    if (math.floor(x * 10) % 10 >= 5):
        print(math.floor(x)+1)
    else:
        print(math.floor(x))

if __name__ == '__main__':
    solv()
import math
N = int(input())
 
print(factrial(N)%(10**9+7))

### FIXED CODE ###

import math
N = int(input())
 
print(math.factorial(N)%(10**9+7))
A, B, C = map(int, input().split())
if A == B and B ==C:
  input('No')
elif A != B and B != C and C != A:
  input('No')
else:
  input('Yes')

### FIXED CODE ###

A, B, C = map(int, input().split())
if A == B and B ==C:
  print('No')
elif A != B and B != C and C != A:
  print('No')
else:
  print('Yes')
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp=[[0]*3 for _  in range(n)]
dp[0]=[a[0],b[0],c[0]]
for i in range(N-1):
    for j in range(2):
        for k in range(2):
            if j!=k:
                dp[i+1][j]=max(dp[i+1][j],dp[i][k] + a[i+1][j])
            else:
                pass

print(max(dp[N-1]))


    

### FIXED CODE ###

N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]

dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))
def calculate_distance(x1, x2):
    l2_norm = (x1[0] - x2[0])**2 + (x1[1] - x2[1])**2
    return math.sqrt(l2_norm)

N = int(input())
point = []
for i in range(N):
    a,b = map(int,input().split())
    point.append([a, b])
    
res = []
for a in itertools.permutations(range(N)):
    distance = 0
    for i in range(N-1):
        distance += calculate_distance(point[i], point[i+1])
    res.append(distance)
np.mean(res)

### FIXED CODE ###

import itertools

def calculate_distance(x1, x2):
    l2_norm = (x1[0] - x2[0])**2 + (x1[1] - x2[1])**2
    return l2_norm**(1/2)

N = int(input())
point = []
for i in range(N):
    a,b = map(int,input().split())
    point.append([a, b])
    

distance = 0
M = 0
for a in itertools.permutations(range(N)):
  M += 1
  
  for i in range(N-1):
        start, end = a[i], a[i+1]
        distance += calculate_distance(point[start], point[end])
print(distance/M)
W, H, x, y = map(int, input().split())
ans = 0
if W/x == H/y == 0:
  ans = 1
print(W*H/2, ans)

### FIXED CODE ###

W, H, x, y = map(int, input().split())
ans = 0
if (2*x == W) and (2*y == H):
  ans = 1
print(W*H/2, ans)
a,b=map(input().split(),int);print(a/b+a%b)

### FIXED CODE ###

a=eval(input().replace(' ', '+'));print(a//2+a%2)
#ABC088C
import sys

c=[map(int,raw_input().split()) for i in xrange(3)]
a=[0,0,0]
b=[0,0,0]
b[0],b[1],b[2]=c[0][0],c[0][1],c[0][2]
a[1],a[2]=c[1][0]-b[0],c[2][0]-b[0]
for i in xrange(3):
 for j in xrange(3):
  if c[i][j]!=a[i]+b[j]:
   print 'No'
   sys.exit()
print 'Yes'


### FIXED CODE ###

#ABC088A

n=int(raw_input())
a=int(raw_input())
if n%500>a:
 print 'No'
else:
 print 'Yes'
a, b = map(int, raw_input().split)
ans = 0
for i in range(2):
  if a >= b:
    ans += a
    a -= 1
  else:
    ans += b
    b -= 1
print(ans)

### FIXED CODE ###

a, b = map(int, input().strip().split(' '))
ans = 0
for i in range(2):
    if a >= b:
        ans += a
        a -= 1
    else:
        ans += b
        b -= 1

print(ans)
a = int(input())
mochi = []
for _ in range(a):
    mochi.append(int(input())

print(len(set(mochi)))

### FIXED CODE ###

a = int(input())
mochi = []
for _ in range(a):
    mochi.append(int(input()))

print(len(set(mochi)))
n = input()
a = [int(value) for value in input()]

def num_two(input_number):
  number = input_number
  count = 0
  while True:
    if number / 2 == 0:
      count += 1
      number = number / 2
    else:
      break
  return count

num_twos = [num_two(ai) for ai in a]
print(min(num_twos))

### FIXED CODE ###

n = input()
a = [int(value) for value in input().split()]

def num_two(input_number):
  number = input_number
  count = 0
  while True:
    if number % 2 == 0:
      count += 1
      number = number / 2
    else:
      break
  return count

num_twos = [num_two(ai) for ai in a]
# print(num_twos)
print(min(num_twos))
def printing(a_start, a_2, n):
    if a_start[1] == 5:
        aaaaaa

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)

    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()



### FIXED CODE ###

def printing(a_start, a_2, n):

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)


    if len(a_3) >= 2:
        if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a_3[1][0] and a_3[1][0] > a_start[0]:
            a_3.pop(0)


    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
            elif n % a_start[1] == 0:
                break
        else:
            n -= a_3[0][1]
            ans += str(a_3[0][0])

    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()