Harryxun/stf_run huggingface dataset:
#!usr/bin/env python3

def string_two_numbers_spliter():
    a, b = [int(i) for i in input('Enter two numbers concatenated ' +
    'by a single space between two numbers, e.g. \'1 2\': ').split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()

    if a < b:
        print('a < b')
    elif a > b:
        print('a > b')
    else:
        print('a == b')


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!usr/bin/env python3

def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()

    if a < b:
        print('a < b')
    elif a > b:
        print('a > b')
    else:
        print('a == b')


if __name__ == '__main__':
    main()
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

SUM=0
num=[0]*100000
for i in range(N):
    a=A[i]
    num[a]+=1
    SUM+=a

B=[0] * Q
C=[0] * Q
for i in range(Q):
    B[i],C[i]  = list(map(int, input().split()))

for i in range(Q):
    b = B[i]
    c = C[i]

    SUM = SUM - b * num[b]
    SUM = SUM + c * num[c]
    num[c] += num[b]
    num[b] = 0
    print(SUM)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

SUM=0
numbers=[0]*100001
for i in range(N):
    a=A[i]
    numbers[a]+=1
    SUM+=a

B=[0] * Q
C=[0] * Q
for i in range(Q):
    B[i],C[i]  = list(map(int, input().split()))

for i in range(Q):
    b = B[i]
    c = C[i]

    SUM = SUM - b * numbers[b]
    SUM = SUM + c * numbers[b]
    numbers[c] += numbers[b]
    numbers[b] = 0
    print(SUM)
import sys
f = sys.stdin

vlines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

for line in f:
    result = 'd'
    for v in vlines:
        if 's' != a and line[v[0]]== line[v[1]] == line[v[2]]:
            result = line[v[0]]
            break
    print(result)

### FIXED CODE ###

import sys
f = sys.stdin


vlines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

for line in f:
    result = 'd'
    for v in vlines:
        if 's' !=  line[v[0]] and line[v[0]]== line[v[1]] == line[v[2]]:
            result = line[v[0]]
            break
    print(result)
# coding=utf-8
# Date: 2020-04-07 00:38

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

n = get()
G = [set() for i in xrange(n + 1)]
for i in xrange(n - 1):
    i, j = gets()
    G[i].add(j)
    G[j].add(i)


def dfs(i):
    G[i], A = None, G[i]
    black, white = 1, 1
    for j in A:
        G[j].remove(i)
        b, w = dfs(j)
        black *= w
        white *= b + w
    return [black, white]
print sum(dfs(1))


### FIXED CODE ###

# coding=utf-8
# Date: 2020-04-07 00:38

import sys
sys.setrecursionlimit(10**6)

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

n = get()
G = [[] for i in xrange(n + 1)]
for i in xrange(n - 1):
    i, j = gets()
    G[i].append(j)
    G[j].append(i)
mod = 10**9 + 7


def dfs(i, pre=0):
    black, white = 1, 1
    for j in G[i]:
        if j == pre: continue
        b, w = dfs(j, i)
        black = black * w % mod
        white = white * (b + w) % mod
    return [black, white]
print sum(dfs(1)) % mod
A = map(int, input().split())
if len(set(A) ) == 2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A = map(int,input().split())
if len(set(A)) == 2:
    print("Yes")
else:
    print("No")
n,m=map(int,input().split())
a=[True]*n
for i in range(m):
    a[int(input())]=False

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if a[1]:
    dp[1]=1
else:
    dp[1]=0
for nn in range(2,n):
    if a[nn]:
        dp[nn]=(dp[nn-1]+dp[nn-2])%mod
    else:
        dp[nn]=0
dp[n]=(dp[n-1]+dp[n-2])%mod

print(dp[n])


### FIXED CODE ###

n,m=map(int,input().split())
a=set()
for i in range(m):
    ai=int(input())
    a.add(ai)


mod=10**9+7

t=[0]*(n+1)
t[0]=1

if 1 in a:
    t[1]=0
else:
    t[1]=1

for i in range(2,n+1):
    if i in a:
        t[i]=0
    else:
        t[i]=(t[i-1]+t[i-2])%mod

print(t[n])
GNU nano 4.8                                                                a.py                                                                 変更済み  
def read():
    D, T, S = map(int, input().split(' '))
    return D, T, S

def func(D, T, S):
    return D / S <= T


if __name__ == '__main__':
    D, T, S = read()
    print('Yes' if func(D, T, S) else 'No')


### FIXED CODE ###

def read():
    D, T, S = map(int, input().split(' '))
    return D, T, S

def func(D, T, S):
    return D / S <= T


if __name__ == '__main__':
    D, T, S = read()
    print('Yes' if func(D, T, S) else 'No')
n,m=map(int,input().split())
path=[[[0]*(n+1)]*(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    path[a][b]=1
    path[b][a]=1#隣接グラフを作成
visited=[[0]*(n+1)]#どこを通ったか記憶
visited[1]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(1,n+1):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(1,n+1):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[i]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(1,n,visited)

### FIXED CODE ###

n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1#隣接グラフを作成
visited=[0]*n#どこを通ったか記憶
visited[0]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(n):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(n):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[i]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(dfs(0,visited,n))
import itertools
a= list(map(int, input().split()))
result = []
test = list(itertools.permutations(a, 2))
for i in range(test):
    result.append(test[i][0] + test[i][1])
print(min(result))

### FIXED CODE ###

import itertools
a= list(map(int, input().split()))
result = []
test = list(itertools.permutations(a, 2))
for i in range(len(test)):
    result.append(test[i][0] + test[i][1])
print(min(result))
W, H, N = map(int, input().split())
z = [list(map(int, input().split())) for _ in range(N)]
one, two, three, four = [], [], [], []
for i in range(N):
	if z[i][2] == 1:
		one.append(z[i][0])
	elif z[i][2] == 2:
		two.append(z[i][0])
	elif z[i][2] == 3:
		three.append(z[i][1])
	else:
		four.append(z[i][1])
w = W - max(one) - (W - min(two))
h = H - max(three) - (H - min(four))
if w > 0 and h > 0:
	print(w * h)
else:
	print(0)


### FIXED CODE ###

W, H, N = map(int, input().split())
z = [list(map(int, input().split())) for _ in range(N)]
one, two, three, four = [0], [W], [0], [H]
for i in range(N):
	if z[i][2] == 1:
		one.append(z[i][0])
	elif z[i][2] == 2:
		two.append(z[i][0])
	elif z[i][2] == 3:
		three.append(z[i][1])
	else:
		four.append(z[i][1])
w = W - max(one) - (W - min(two))
h = H - max(three) - (H - min(four))
if w > 0 and h > 0:
	print(w * h)
else:
	print(0)
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
print(N_lis)
no_sweet=N_lis==0
print(no_sweet)
print(no_sweet.sum()))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())
# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 0:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)


### FIXED CODE ###

# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 2:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)
print(48 - input())

### FIXED CODE ###

print(48 - int(input()))
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(cnt))

### FIXED CODE ###

n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [False] * (n)
ball[0] = True
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = True
    if ans[x-1] == 0:
      ball[x-1] = False
      
cnt = 0
for i in ball:
  if i:
    cnt += 1

print(cnt)
print(x**3)

### FIXED CODE ###

x =int(input())
print(x ** 3)
a,b = map(int,input().split())

if a > b:
  print("GREATER")
else :
  print("LESS")


### FIXED CODE ###

a = int(input())
b = int(input())

if a > b:
  print("GREATER")
elif a < b:
  print("LESS")
else :
  print("EQUAL")
import math
from functools import reduce
k = int(input())
l = [a,b,c]
gcd = []
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
for l[0] in range(1,k+1):
    for l[1] in range(1,k+1):
        for l[2] in range(1,k+1):
            gcd.append(gcd_list(l))
print(sum(gcd))

### FIXED CODE ###

import math
 
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        tmp = math.gcd(i, j)
        for k in range(1, K+ 1):
            ans += math.gcd(k, tmp)
 
print(ans)
S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 2:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))

### FIXED CODE ###

S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 1:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))
a,b=input().split()
c=a+b
a=int.input(a)
if(c==a*a):
  print("Yes")
  else:
    print("No")
          
        
            


### FIXED CODE ###

a,b=input().split()
c=a+b
c=int(c)
flag=0
for i in range(1,c+1):
    if(c==i*i):
      flag=flag+1
      break
if(flag>0):
    print("Yes")
else:
    print('No')
n, k = map(int , input().split())
e = []
cnt = 0
for i in range(n):
    a, b = map(int, input().split())
for j in range(b):
    e.append(a)
    e.sort()
print(e[k-1])

### FIXED CODE ###

n, k = map(int , input().split())
a = []
b = []
cnt = 0
for i in range(n):
    atem, btem = map(int , input().split())
    a.append(atem)
    b.append(btem)
c = list(zip(a, b))
c.sort()
a, b = zip(*c)
for i in range(n):
    cnt += b[i]
    if cnt >= k:
        print(a[i])
        break
n,m = map(int,input().split())

if 2*n <= m:
  print(n+(m-2*n)//4)
elif 2*n > m:
  print(c//2)


### FIXED CODE ###

n,m = map(int,input().split())

if 2*n <= m:
  print(n+(m-2*n)//4)
elif 2*n > m:
  print(m//2)
R = input()
G = input()
print(2 * G - R)

### FIXED CODE ###

R = int(input())
G = int(input())
print(2 * G - R)
K = input()

try:
   if 0 > int(K) or int(K) >= 100:
      print("K's value must be over 1 and under 100")
      exit()
except ValueError:
   print("K's value must be integer")
   exit() 

S = input()
  if 1 > len(S) or 100 < len(S):
    print("S's length must be over 1 and under 100")
    exit()
   
  if len(S) <= int(K):
    print(S)
  else:
    S = S[:int(K)]
    S += '...'
    print(S)


### FIXED CODE ###

K = input()
S = input()

   
if len(S) <= int(K):
  print(S)
else:
  S = S[:int(K)]
  S += '...'
  print(S)
A, B, C, K = map(int, input().split())
if((K-A)>0):
    Y = K-A
else:
    Y = 0
if((Y-B)>0):
    Z = Y-B
else:
    Z = 0

X = 1 * K + 0 * Y + (-1) * Z
print(X)











	



### FIXED CODE ###

S = input()
T = input()

if(S==T[0:len(S)]):
  print('Yes')
else:
    print('No')
s = input()
a = 0

sf = s[:1]  #'sf' is the formar part of the S
sl = s[2:]  #'sl' is the latter part of the S

for i in range(1:9):
  if sf[0] == 0:
    if sf[1] == i:
      a += 1
    else:
  else:
for j in range(0:2):
  if sf[0] == 1:
      if sf[1] == j:
        a += 1
      else:
  else:

for i in range(1:9):
  if sl[0] == 0:
    if sl[1] == i:
      a += 1
    else:
  else:
for j in range(0:2):
  if sl[0] == 1:
      if sl[1] == j:
        a += 1
      else:
  else:
    
if a == 0:
  print('NA')
elif a == 2:
  print('AMBIGUOUS')
elif a == 2:
  print('YYMM')

### FIXED CODE ###

s = input()
x = 0

sf = s[:2]
sl = s[2:]

if (int(sf[0]) == 0 and int(sf[1]) != 0):
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 0:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 1:
    x += 1
if int(sf[0]) == 1 and int(sf[1]) == 2:
    x += 1


if (int(sl[0]) == 0 and int(sl[1]) != 0):
    x += 2

if int(sl[0]) == 1 and int(sl[1]) == 0:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 1:
    x += 2
if int(sl[0]) == 1 and int(sl[1]) == 2:
    x += 2

b = x

if b == 0:
  print('NA')
elif b == 3:
  print('AMBIGUOUS')
elif b == 1:
  print('MMYY')
elif b == 2:
  print('YYMM')
import sys
sys.setrecursionlimit(1000000)
def watering(l,a,b):
  if b-a <= 1:
    return l[a]
  
  c = 0
  t = a
  
  mi = min(l[a:b])
  for i in range(a,b):
    l[i] -= mi
    
  for i in range(a,b):
    if l[i]==0:
      c += watering(l,t,i)
      t=i+1
  c += watering(l,t,b)
      
  return c+mi

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

print(watering(h,0,n))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def watering(l,a,b):
  if b==a:
    return 0
  if b-a <= 1:
    return l[a]
  
  c = 0
  t = a
  
  mi = min(l[a:b])
  for i in range(a,b):
    l[i] -= mi
    
  for i in range(a,b):
    if l[i]==0:
      c += watering(l,t,i)
      t=i+1
  c += watering(l,t,b)
      
  return c+mi

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

print(watering(h,0,n))
from sys import stdin
import numpy as np
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
data=np.array(data)
ans=0
cnt=0
for i in data[data > 0]:
    ans+=i
for j in data[data < 0][0:-1]:
    ans+=abs(j)
if len(data[data<0]) %2 ==0:
    ans+=abs(data[data<0][-1])
print(ans)

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 0
abs_sum = 0
for i in A:
    abs_sum += abs(i)
    if i < 0:
        cnt += 1
mi = min([abs(i) for i in A])
if cnt % 2 == 0:
    print(abs_sum)
else:
    print(abs_sum-(mi*2))
a,b,c=input().split()
if b=="+":
print(int(a)+int(c))
else:
print(int(a)-int(c))


### FIXED CODE ###

a,b,c=input().split()
if b=="+":
    print(int(a)+int(c))
else:
    print(int(a)-int(c))
import io
import sys
from math import ceil


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
4
0
0
0
0
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()

  l = [IN_I()]

  for i in range(0, n - 1):
    num = IN_I()

    # print(l)
    # print(num)
    if l[0] >= num:
      l.insert(0, num)
      continue

    inl = 0
    inr = len(l) - 1
    # 1, 2, 3, 4, 5
    for j in range(0, len(l)):
      mid = (inr - inl) // 2
      if mid == inl:
        l.pop(0)
        break
      elif l[mid] == num:
        inr = mid - 1
      elif l[mid] > num:
        inr = mid
      else:
        inl = mid + 1

    inl = 0
    inr = len(l) - 1
    # print(l)
    for j in range(0, len(l)):
      mid = ceil((inr - inl) / 2)
      if mid == inl:
        if l[mid] >= num:
          l.insert(mid, num)
        else:
          l.insert(mid + 1, num)
        break
      elif l[mid] == num:
        l.insert(mid, num)
      elif l[mid] > num:
        inr = mid - 1
      else:
        inl = mid + 1


  # print(l)
  print(len(l))
  return None


def B():
  return None


def C():
  return None


MAIN()


### FIXED CODE ###

import io
import sys
from bisect import bisect_right, bisect_left
from collections import deque


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
7
1
0
3
4
1
2
1
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()

  l = deque([IN_I()])

  for i in range(0, n - 1):
    num = IN_I()

    idx = bisect_left(l, num)
    if idx == 0:
      l.appendleft(num)
    else:
      l[idx - 1] = num
    # print(l)

  print(len(l))
  return None


def B():
  return None


def C():
  return None


MAIN()
r = input()
if r == 'RRR':
    print(3)
elif r == 'RRS' or r == 'SRR':
    print(2)
elif r == 'RSR' or r == 'RSS' or r =='SSR' or r =='SRS':
    print(1)
else rainy_days == 'SSS':
    print(0)


### FIXED CODE ###

r = input()
if r == 'RRR':
    print(3)
elif r == 'RRS' or r == 'SRR':
    print(2)
elif r == 'RSR' or r == 'RSS' or r =='SSR' or r =='SRS':
    print(1)
elif r == 'SSS':
    print(0)
n = int(input())
mochi = [int(input()) for i in range(n)]
mochi.sort(reverse=True)

size = 0
max = 9999999999

for m in mochi:
    //print(m)
    if m < max:
        size += 1
        max = m
# 出力
print(size)


### FIXED CODE ###

n = int(input())
mochi = [int(input()) for i in range(n)]
mochi.sort(reverse=True)

size = 0
max = 9999999999

for m in mochi:
    # print(m)
    if m < max:
        size += 1
        max = m
# 出力
print(size)
n = input()
int_list = [int(i) for i in input()]
count = 0
while True:
    isOdd = False
    for i in range(n):
        if(int_list[i] % 2 != 0):
            isOdd = True
    if isOdd:
        break
    for i in range(n):
        int_list[i] = int_list[i]/2
    count = count + 1

print(count)


### FIXED CODE ###

str_list = input()
count = 0
if str_list[0] == '1':
  count = count + 1
if str_list[1] == '1':
  count = count + 1
if str_list[2] == '1':
  count = count + 1
print(count)
import sys

def chk(i,j):
    tmp=[p[i][k] for k in range(M)]
    tmp[j]=p[i][j]+1
    for k in range(M-1,-1,-1):
        if tmp[k] > p[i+x[j]][k] :
            p[i+x[j]]=[tmp[k] for k in range(M)]

N,M=map(int,input().split())
x=[0,2,5,5,4,5,6,3,7,6]
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(M):
    for j in range(M):
        if x[a[j]]==x[a[i]]: tmp=j
    b.append(a[tmp]) 

a=list(set(b))
a.sort()
M=len(a)
x=[ x[a[i]] for i in range(M) ]


p=[-100 for i in range(N+10)]
p[0]=0
for i in range(N):
    if p[i]>-1:
        for j in range(M):
            p[i+x[j]]=max(p[i+x[j]],p[i]+1)

ans=""
while N>0:
    for j in range(M-1,-1,-1):
        if p[N]==p[N-x[j]]+1:
            ans+=str(a[j])
            N-=x[j]
            break
print(ans)




### FIXED CODE ###

N,K=map(int,input().split())
print(N+K if K%N==0 else K-N)
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a, b = invr()
res = "Negative"


if a > 0 and b > 0:
    res = "Positive"
if a < 0 and b < 0:
    temp = abs(abs(a)-abs(b)) + 1
    if temp % 2 == 0:
        res = "positive"
    else:
        res = "Negative"
if a == b:
    res = "Positive"
if a <= 0 and b = > 0:
    res = "Zero"

print(res)


### FIXED CODE ###

# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a, b = invr()
res = "Negative"

if 0 < a and a <= b:
    res = "Positive"
if a <= b and b < 0:
    temp = (b-a)+1
    if temp % 2 == 0:
        res = "Positive"
    else:
        res = "Negative"
if a <= 0 and b >= 0:
    res = "Zero"

print(res)
r, g, b = map(int(), input().split())

A = 100*r + 10*g + b

if(A % 4 == 0):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

r, g, b = map(int, input().split())

A = 100*r + 10*g + b

if(A % 4 == 0):
	print("YES")
else:
	print("NO")
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
town = list(map(int, input().split()))

for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X

print(gcd_list(town))
  
  

### FIXED CODE ###

import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)