Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
l=["0"]*n
n,m=map(int,input().split())
l=["0"]*n
f=[0]*n
frag=0
for i in range(m):
    s,c=map(int,input().split())
    if f[s-1]==0 or l[s-1]==str(c):
        l[s-1]=str(c)
        f[s-1]=1
    else:
        frag=1
        break
if frag==1 or (l[0]=="0" and n!=1):
    print(-1)
else:
    for j in l:
        
        print(j,end="")

### FIXED CODE ###


n,m=map(int,input().split())
l=["0"]*n
l[0]="1"
l[-1]="0"
f=[0]*n
frag=0
for i in range(m):
    s,c=map(int,input().split())
    if f[s-1]==0 or l[s-1]==str(c):
        l[s-1]=str(c)
        f[s-1]=1
    else:
        frag=1
        break
if frag==1 or (l[0]=="0" and n!=1):
    print(-1)
else:
    for j in l:
        print(j,end="")
S = input()
O = ['R','U','D']
E = ['L','U','D']
ng = False
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] not in O:
      ng = True
      break
  else:
    if S[i] not in E:
      ng = True
      break
print('No') if ng print('Yes')

### FIXED CODE ###

S = input()
O = ['R','U','D']
E = ['L','U','D']
ng = False
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] not in O:
      ng = True
      break
  else:
    if S[i] not in E:
      ng = True
      break
print('No') if ng else print('Yes')
def resolve():
    from collections import deque
    x = input()
    final = deque([])
    final.append(x[0])
    for i in range(1, len(x)):
        if x[i] == "S":
            final.append("S")
        else:
            last = final.pop()
            if last == "S":
                continue
            else:
                final.append("T")
                final.append("T")
    print(len(final))

resolve()

### FIXED CODE ###

def resolve():
    from collections import deque
    x = input()
    final = deque([])
    final.append(x[0])
    for i in range(1, len(x)):
        if x[i] == "S":
            final.append("S")
        else:
            if not final:
                final.append("T")
            else:
                last = final.pop()
                if last == "S":
                    continue
                else:
                    final.append("T")
                    final.append("T")
    print(len(final))
resolve()
a,b=map(int,input().split())
     
    if((a*b)%2 == 0):
        print('Even')
    else:
        print('Odd')

### FIXED CODE ###

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

if((a*b)%2 == 0):
	print('Even')
else:
	print('Odd')
import numpy as np
import collections
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def naive(s):
	cnt = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			k = int(s[i:j])
			if k % 2019 == 0 and k != 0:
				#print(i, j)
				cnt += 1
	return cnt

def main(s):
	nums = [0]
	cur = 0
	p = 0.1
	for i in range(len(s)):
		p = int(p * 10) % 2019
		cur = (cur + int(s[len(s) - 1 - i]) * p) % 2019
		nums.append(cur)
	d = dict(collections.Counter(nums))
	a = [val for key, val in d.items() if val >= 2]
	return sum([comb(x, 2) for x in a])	

s = input()
print(main(s))

### FIXED CODE ###

import collections
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def naive(s):
	cnt = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			k = int(s[i:j])
			if k % 2019 == 0 and k != 0:
				#print(i, j)
				cnt += 1
	return cnt

def main(s):
	nums = [0]
	cur = 0
	p = 0.1
	for i in range(len(s)):
		p = int(p * 10) % 2019
		cur = (cur + int(s[len(s) - 1 - i]) * p) % 2019
		nums.append(cur)
	d = dict(collections.Counter(nums))
	a = [val for key, val in d.items() if val >= 2]
	return sum([comb(x, 2) for x in a])	

s = input()
print(main(s))
a = int(input())
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u==s:
    a-=1
if u==t:
    b-=1
print(a,b)

### FIXED CODE ###

s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u==s:
    a-=1
if u==t:
    b-=1
print(a,b)
n, q = [int(i) for i in input().split()]

ab = []
for i in range(n-1):
    ab.append([int(i) for i in input().split()])

px = []
for i in range(q):
    px.append([int(i) for i in input().split()])

tree = {}
for a, b in ab:
    if a in tree.keys():
        tree[a].append(b)
    else:
        tree[a] = [b]

counter = [0] * (n+1)

def count(p, x):
    counter[p] += x
    if p in tree.keys():
        for leaf in tree[p]:
            count(leaf, x)

for p, x in px:
    count(p, x)

for counter_i in counter[1:]:
    print(counter_i, end=" ")


### FIXED CODE ###

from collections import deque

n, q = [int(i) for i in input().split()]

tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b = [int(i) for i in input().split()]
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * (n+1)
for _ in range(q):
    p, x = [int(i) for i in input().split()]
    counter[p] += x

queue = deque([[0,1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])

print(*counter[1:])
n, m = map(int, input().split())
# S = [None] * m
# C = [None] * m
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ans = '0' * n
for k, v in dic.items():
    ans = ans[:k - 1] + str(v) + ans[k:]

if (dic[1] == 0 and ans[0] == '0'):
    print(-1)
    exit()
elif (dic[1] == 0):
    ans = '1' + ans[1:]

print(ans)


### FIXED CODE ###

# n, m = map(int, input().split())
# if (m == 0):
#     print('1' + '0' * (n - 1))
#     exit()
# dic = {}
# for i in range(m):
#     s, c = map(int, input().split())
#     try:
#         _ = dic[s]
#     except KeyError:
#         if (s == 1 and c == 0):
#             print(-1)
#             exit()
#         dic[s] = c
#     else:
#         if (dic[s] != c):
#             print(-1)
#             exit()

# ans = '0' * n
# for k, v in dic.items():
#     ans = ans[:k - 1] + str(v) + ans[k:]

# try:
#     digit1 = dic[1]
# except KeyError:
#     digit1 = 1

# if (digit1 == 0):
#     ans = '1' + ans[1:]

# print(ans)
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    for k, v in dic.items():
        print(v)
        exit()
else:
    for i in range(10 ** (n - 1), 10 ** n):
        for k, v in dic.items():
            if (str(i)[k - 1] == str(v)):
                ok = True
            else:
                ok = False
                break
        else:
            if (ok):
                print(i)
                exit()
n = 0;

n = x*x*x;

printf(n);

### FIXED CODE ###

n = input()

print n*n*n;
n, k = map(int, input().split())
ans = max((n - k + 1) / n, 0)
for a in range(1, min(k, n + 1)):
    ans += 0.5 ** (k // a).bit_length() / n
print(f'{ans:.12f}')

### FIXED CODE ###

n, k = map(int, input().split())
ans = max((n - k + 1) / n, 0)
for a in range(1, min(k, n + 1)):
    cnt = 0
    while k > a:
        a *= 2
        cnt += 1
    ans += 0.5 ** cnt / n
print('{:.12f}'.format(ans))
import math

p=math.pi
r=int(input())

a=r*r*p
b=2*r*p

c=round(a,5)
d=round(b,5)

print(str(c)+" "+str(d))


### FIXED CODE ###

import math

p=math.pi
r=float(input())

a=r*r*p
b=2*r*p

c=round(a,5)
d=round(b,5)

print(str(c)+" "+str(d))
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    permitted = 'ACGT'
    continuous_count = []
    count = 0

    for i in range(len(s)):
        char = s[i]
        if char in permitted:
            count += 1
        else:
            continuous_count.append(count)
            count = 0
    
    print(max(continuous_count))



if __name__ == "__main__":
    main()


### FIXED CODE ###

# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    all_words = []
    for i in range(1, len(s) + 1):
        for letters in itertools.product('ATCG', repeat=i):
            word = ''.join(letters)
            all_words.append(word)
    
    for i in range(len(all_words)-1, 0-1, -1):
        if all_words[i] in s:
            print(len(all_words[i]))
            sys.exit()
    print(0)




if __name__ == "__main__":
    main()
# -*- coding: utf-8 -*-
a, b = map(int,input().split())
x = (a + b) / 2
if x > 0:
	return x + 1
else:
	return x


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math

a, b = map(int, input().split())
x = (a + b) / 2
print(math.ceil(x))
n = int(input())
a, b, c = 1, 1, 1
for i in range(n):
  a, b, c = a * 10, b * 9, c * 8
  a, b, c = a % (10**9+7), b % (10**9+7), , c % (10**9+7)
print(0 if n==1 else (a - b*2 + c) % (10**9+7))

### FIXED CODE ###

n = int(input())
a, b, c = 1, 1, 1
for i in range(n):
  a, b, c = a * 10, b * 9, c * 8
  a, b, c = a % (10**9+7), b % (10**9+7), c % (10**9+7)
print(0 if n==1 else (a - b*2 + c) % (10**9+7))
str1 = list(input())
str2 = list(input())

n = len(str1)

str1 = ''.join(str1)
str2 = ''.join(str2) 
if (str1 == str2):
    print("No")
    exit(0)
for i in range(n):
    if str1[i]==str2[i]:
        continue
    for j in range(i+1,n):
        if str1[j]==str1[i]:
            tmp = str2[i]
            str2[i] = str1[j]
            str1[j] = tmp
            break
        elif str2[j] == str1[i]:
            tmp = str2[j]
            str2[j] = str1[i+1]
            str1[i+1] = str2[i]
            str2[i] = tmp
            break
str1 = ''.join(str1)
str2 = ''.join(str2) 

if(str1 == str2):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

str1 = input()
str2 = input()

n = len(str1)
d1 = dict()
d2 = dict()
for i in range(26):
    d1[chr(97+i)] = ''
    d2[chr(97+i)] = ''
res = "Yes"
for i in range(n):
    if d1[str1[i]] != '' and d1[str1[i]]!=str2[i]:
        res = "No"
        break
    if d2[str2[i]] != '' and d2[str2[i]]!=str1[i]:
        res = "No"
        break
    if d1[str1[i]] == '':
        d1[str1[i]] = str2[i]
    if d2[str2[i]] == '':
        d2[str2[i]] = str1[i]
print(res)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
s_A = sum(A)
if N >= s_A:
    print(N - s_A)
if N < s_A:
    print(-1)



### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in a:
    n-=i
    if n<0: #宿題の総日数が夏休みの日数を上回った場合
        print(-1)
        exit()
print(n)
def main():
    import numpy as np

    H, W = map(int, input().split())
    A = np.array([[int(x) for x in input().split()] for _ in range(H)])
    B = np.array([[int(x) for x in input().split()] for _ in range(H)])
    D = np.abs(A - B)

    MAX_BIAS_PER_CELL = 80
    UPPER_BOUND_TOTAL_BIAS = MAX_BIAS_PER_CELL * (H + W - 1) + 1

    dp = np.zeros(shape=(H, W, UPPER_BOUND_TOTAL_BIAS * 2 + 1), dtype=np.bool_)
    d = D[0][0]
    dp[0, 0, UPPER_BOUND_TOTAL_BIAS - d] = 1
    dp[0, 0, UPPER_BOUND_TOTAL_BIAS + d] = 1

    for r in range(H):
        for c in range(W):
            d = D[r][c]
            if r > 0:
                dp[r, c, d:] |= dp[r - 1, c, :-d]
                dp[r, c, :-d] |= dp[r - 1, c, d:]
            if c > 0:
                dp[r, c, d:] |= dp[r, c - 1, :-d]
                dp[r, c, :-d] |= dp[r, c - 1, d:]

    indices = np.where(dp[H - 1, W - 1, :] == 1)
    t = tuple(abs(idx - UPPER_BOUND_TOTAL_BIAS) for idx in indices)
    print(np.min(t))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc147/submissions/8871745
# 写経
# bitset 高速化

def main():
    import numpy as np

    H, W = map(int, input().split())
    A = np.array([[int(x) for x in input().split()] for _ in range(H)])
    B = np.array([[int(x) for x in input().split()] for _ in range(H)])
    D = np.abs(A - B)

    MAX_BIAS_PER_CELL = 80
    UPPER_BOUND_TOTAL_BIAS = MAX_BIAS_PER_CELL * (H + W - 1) + 1

    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 << UPPER_BOUND_TOTAL_BIAS
    # dp[r][c]:(r,c)で値の加減を行った後、
    # 達成可能なbiasに該当するbitを立てたbit表現
    # 2**UPPER_BOUND_TOTAL_BIASの位をbias=0とみなす

    # -UPPER_BOUND_TOTAL_BIAS, ..., 0, ...UPPER_BOUND_TOTAL_BIAS [意味するbias]
    # 0, ..., UPPER_BOUND_TOTAL_BIAS, ..., UPPER_BOUND_TOTAL_BIAS*2 [dpに代入されるbit表現の桁]

    # numpyのndarrayを使用しなかった理由
    # dtypeでuint64を採用しても、
    # 2**(UPPER_BOUND_TOTAL_BIAS*2)は収まらない
    # pythonのintなら収まる

    for r in range(H):
        for c in range(W):
            x = dp[r][c]
            if r > 0:
                x |= dp[r - 1][c]
            if c > 0:
                x |= dp[r][c - 1]
            # x:(r,c)到達可能なbiasのbit表現

            d = D[r][c]
            dp[r][c] = (x << d) | (x >> d)
            # (r,c)マスでのbias変化を加味したbit表現

    ret = min(
        abs(UPPER_BOUND_TOTAL_BIAS - shift)
        for shift in range(UPPER_BOUND_TOTAL_BIAS * 2)
        if (dp[H - 1][W - 1] & (1 << shift)) > 0)

    print(ret)


if __name__ == '__main__':
    main()
h,w = map(int,input().split())
for _ in range(w):
    s = input()
    print (s)
    print (s)

### FIXED CODE ###

h,w = map(int,input().split())
pic = []
for _ in range(h):
    pic.append(input())
for line in pic:
    print (line)
    print (line)
import numpy as np

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

### FIXED CODE ###

import numpy as np
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)
from sys import exit
from collections import deque
# import copy
# import numpy as np
# from collections import deque

n, m, k = map(int, input().split())
a = deque(list(map(int, input().split())))
b = deque(list(map(int, input().split())))

cnt = 0

while k >= a[0] or k >= b[0]:
    if a[0] < b[0]:
        k -= a.popleft()
        cnt += 1

    elif a[0] > b[0]:
        k -= b.popleft()
        cnt += 1

    else:
        for i in range(1, min(len(a), len(b))+1):
            if a[i] < b[i]:
                for t in range(0, i+1):
                    k -= a[0]
                    a.popleft()
                    cnt += 1
                    if k < a[0]:
                        break
                break
            elif a[i] > b[i]:
                for t in range(0, i+1):
                    k -= b[0]
                    b.popleft()
                    cnt += 1
                    if k < a[0]:
                        break
                break
        else:
            if len(a) > len(b):
                for i in range(len(a)):
                    k -= a[0]
                    a.popleft()
                    if k < a[0]:
                        break
            else:
                for i in range(len(b)):
                    k -= b[0]
                    b.popleft()
                    cnt += 1
                    if k < b[0]:
                        break
    if a == deque([]):
        a = [float("inf")]
    if b == deque([]):
        b = [float("inf")]

print(cnt)


### FIXED CODE ###

from sys import exit
import copy
# import numpy as np
from collections import deque

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0


a.insert(0, 0)
b.insert(0, 0)


for i in range(1, n+1):
    a[i] += a[i-1]

for i in range(1, m+1):
    b[i] += b[i-1]

tmp = m
for i in range(n+1):
    for j in range(tmp, -1, -1):
        if a[i] + b[j] <= k:
            cnt = max(cnt, i + j)
            tmp = j
            break


print(cnt)
import numpy as np
import pandas as pd

n, m = map(int, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))

### FIXED CODE ###

import sys
import numpy as np

n, m = map(float, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
lines.sort()
price = 0
for line in lines:
    if m - line[1] > 0:
        price += line[0] * line[1]
        m -= line[1]
    else:
        price += line[0] * m
        break
print(int(price))
N, K = map(int, input().split())
A = list(map(int, input().split()))

ok = 10 ** 9  # 解が存在する値
ng = -1  # 解が存在しない値


def solve(x):
    """
    一番長いのをx以下にできるか
    → 全部をx以下にするのに切る回数 <= K
    """
    res = 0
    for i in range(N):
        res += (A[i] - 1) // x

    return res <= K


while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)

### FIXED CODE ###

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

ok = 10 ** 9  # 解が存在する値
ng = 0  # 解が存在しない値


def solve(x):
    """
    一番長いのをx以下にできるか
    → 全部をx以下にするのに切る回数 <= K
    """
    res = 0
    for i in range(N):
        res += (A[i] - 1) // x

    return res <= K


while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)
import heapq


def dijkstra(n, s, g):
    h = [(0, s)]
    heapq.heapify(h)
    cost = [float("Inf")] * (n + 1)  # cost: i -> j
    cost[s] = 0

    while h:
        c, v = heapq.heappop(h)
        if c > cost[v]:
            continue
        for d, u in g[v]:
            d_s_u = d + cost[v]
            if d_s_u < cost[u]:
                cost[u] = d_s_u
                heapq.heappush(h, (d_s_u, u))

    return cost


def main():
    n, m, *abc = map(int, open(0).read().split())
    g = [[] for _ in range(n + 1)]

    for a, b, c in zip(*[iter(abc)] * 3):
        g[a].append([c, b])
        g[b].append([c, a])

    ans = 0
    checkd = [[False] * (n + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        cost = dijkstra(n, i, g)
        for j, k in g[i]:
            if checkd[i][j]:
                continue
            if j > cost[k]:
                ans += 1
            checkd[i][j] = True
            checkd[j][i] = True
    
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m, *abc = map(int, open(0).read().split())
    d = [[float("Inf")] * (n + 1) for _ in range(n + 1)]

    for i in range(1, n + 1):
        d[i][i] = 0

    for a, b, c in zip(*[iter(abc)] * 3):
        d[a][b] = c
        d[b][a] = c

    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    ans = 0
    for a, b, c in zip(*[iter(abc)] * 3):
        if d[a][b] < c:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  for idx in range(lim_b):
    if k >= cum_a[-l] + cum[idx]:
      ans = max(ans, lim_a - l + idx + 2)
print(ans)


### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  while idx < lim_b:
    if k >= cum_a[-l] + cum_b[idx]:
      ans = max(ans, lim_a - l + idx + 2)
    else:
      break
    idx += 1
ans = max(ans, lim_b)
print(ans)
#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(W):
	s = input()
	s_list = list(s)
	S.append(s_list)

#枠外を白に塗りつぶす
for  i in range(H+2):
	p.append(".")

S.insert(0,p)
S.insert(W+1,p)

for i in range(1,W+1,1):
	S[i].insert(0,".")
	S[i].insert(H+2,".")

#計算
for i in range(1, W+2, 1):
	for j in range(1, H+2, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "." and S[i+1][j+1] == "." and S[i-1][j] == "." and S[i][j-1] == "." and S[i-1][j-1] == ".":
			flag = False

#出力
if flag == True:
	print("Yes")

else:
	print("No")

### FIXED CODE ###

#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(H):
	s = input()
	s_list = list(s)
	S.append(s_list)

#計算
for i in range(0, H-1, 1):
	for j in range(0, W-1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		

#出力
if flag == True:
	print("Yes")

else:
	print("No")
# -*- coding: utf-8 -*-
import sys

N,Q=map(int, sys.stdin.readline().split())
s=raw_input()
q=[ sys.stdin.readline().split()  for i in range(Q) ]


def leftout(cur):
	for x,y in q:
		if s[cur]==x:
			if y=="L":
				cur-=1
			elif y=="R":
				cur+=1
		if cur<0:
			return True
			break
		elif cur>N-1:
			return False
			break			

	else:
		return False


def rightout(cur):
	for x,y in q:
		if s[cur]==x:
			if y=="L":
				cur-=1
			elif y=="R":
				cur+=1
		if cur>N-1:
			return True
			break
		if cur<0:
			return False
			break
	else:
		return False


if N==1:
	for x,y in q:
		if s==x:
			print 1
			quit()
	else:
		print 0


#左側から落ちるゴーレム
l=-1
r=N
while l!=r:
	m=(l+r)/2+1
	if leftout(m):
		l=m
	else:
		r=m-1
sl=l

#右側から落ちるゴーレム
l=-1
r=N
while l!=r:
	m=(l+r)/2
	if rightout(m):
		r=m
	else:
		l=m+1
sr=r


if sr>sl:
	print sr-sl-1
else:
	print N

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N,Q=map(int, sys.stdin.readline().split())
s=raw_input()
q=[ sys.stdin.readline().split()  for i in range(Q) ]

def leftout(cur):
	for x,y in q:
		if s[cur]==x:
			if y=="L":
				cur-=1
			elif y=="R":
				cur+=1
		if cur<0:
			return True
			break
		elif cur>N-1:
			return False
			break			

	else:
		return False


def rightout(cur):
	for x,y in q:
		if s[cur]==x:
			if y=="L":
				cur-=1
			elif y=="R":
				cur+=1
		if cur>N-1:
			return True
			break
		if cur<0:
			return False
			break
	else:
		return False


l=-1
r=N
while r-l!=1:
	m=(l+r)/2
	if leftout(m):
		l=m
	else:
		r=m
sl=l

l=-1
r=N
while r-l!=1:
	m=(l+r)/2
	if rightout(m):
		r=m
	else:
		l=m

sr=r


ans=N
if sl>=0:
	ans-=(sl+1)
if sr<N:
	ans-=(N-sr)

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

k=max(a,b,c)

print(int(10k+a+b+c-k))

### FIXED CODE ###

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

m=max(a,b,c)

print(int(9*m+a+b+c))