Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
ss = []
cc = []
num = []

for _ in range(m):
    s, c = map(int, input().split())
    ss.append(s)
    cc.append(c)

for i in range(1000):
    if len(str(i)) != m:
        continue
    cnt = 0
    for s, c in zip(ss, cc):
        if str(i)[s-1] == str(c):
            cnt += 1
    if cnt == len(ss):
        num.append(i)

if num:
    print(num[0])
else:
    print(-1)


### FIXED CODE ###

n, m = map(int, input().split())
ss = []
cc = []
num = []

for _ in range(m):
    s, c = map(int, input().split())
    ss.append(s)
    cc.append(c)

for i in range(1000):
    if len(str(i)) != n:
        continue
    cnt = 0
    for s, c in zip(ss, cc):
        if str(i)[s-1] == str(c):
            cnt += 1
    if cnt == len(ss):
        num.append(i)

if num:
    print(num[0])
else:
    print(-1)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
v = na()
v.sort()

s = 0
for i in range(n):
    s = s * 0.5 + v[i]
    if i == 0:
        s += v[i]
print(f"{s*0.5:.14f}")

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
v = na()
v.sort()

s = 0
for i in range(n):
    s = s * 0.5 + v[i]
    if i == 0:
        s += v[i]
print("{:.14f}".format(s*0.5))
n = [int(input()) for i in range(5)]
m = 9
#1の位が最も小さいものはそのまま足す・残りは1の位を切り上げて足す

for i in n:
  if int(str(i)[-1]) < m:
    m = int(str(i)[-1])
    x = i

n.remove(x)
    
for i in range(len(n)):
  if n[i]%10 != 0:
    n[i] = n[i] + 10 - int(str(n[i])[-1])

print(sum(n) + x)

### FIXED CODE ###

n = [int(input()) for i in range(5)]
m = 10
x = n[0]
#1の位が最も小さいものはそのまま足す・残りは1の位を切り上げて足す

for i in n:
  if int(str(i)[-1]) < m and int(str(i)[-1]) > 0:
    m = int(str(i)[-1])
    x = i



n.remove(x)
    
for i in range(len(n)):
  if n[i]%10 != 0:
    n[i] = n[i] + 10 - int(str(n[i])[-1])

print(sum(n) + x)
n,k = map(int,input().split())

A = list(map(int,input().split()))
t = 0
c = 0
ans = [0] * n
L = []
s = 0
for _ in range(k):
    if ans[t] == 1:
        temp = t + k%c
        temp %= n
        t = L[temp]
        break
    else:
        ans[t] = 1
        L.append(t)
        t = A[t]-1
        c += 1
print(t+1)

### FIXED CODE ###

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

A = list(map(int,input().split()))
t = 0
c = 0
ans = [0] * n
L = []
s = 0
for _ in range(k):
    if ans[t] == 1:
        n = len(L) - L.index(t)
        temp = (k-c)%n
        t = L[L.index(t):][temp]
        break
    else:
        ans[t] = 1
        L.append(t)
        t = A[t]-1
        c += 1
print(t+1)
N,Y=map(int,input().split())
Y = Y/1000
a,b,c =0,0,0
if 10*N < Y:
  a,b,c = -1,-1,-1
elif Y/10 + Y%5 > float(N):
  a,b,c = -1,-1,-1
else:
    flg = True
    for n in range(int(N/5)+1):
        c = int(Y%5 + 5*n)
        for i in range(N-c+1):
            if (5*i + 5*N) == (Y + 4*c):
                flg = False
                a , b = i , (N-c-i)
                break
        if flg==False:
            break
if flg:
    a,b,c = -1,-1,-1
print(a,b,c)

### FIXED CODE ###

N,Y=map(int,input().split())
Y = Y/1000
a,b,c =0,0,0
flg = True
if 10*N < Y:
  a,b,c = -1,-1,-1
#elif float(Y/10 + Y%5) > float(N):
#  a,b,c = -1,-1,-1
else:
    for n in range(int(N/5)+1):
        c = int(Y%5 + 5*n)
        for i in range(N-c+1):
            if (5*i + 5*N) == (Y + 4*c):
                flg = False
                a , b = i , (N-c-i)
                break
        if not flg:
            break
if flg:
    a,b,c = -1,-1,-1
print(a,b,c)
a,b,c,k=map(int,input().split())
if a-b>10**18:
  print("Unfair")
else:
  if k%2=1:
    print(a-b)
  else:
    print(b-a)
  


### FIXED CODE ###

a,b,c,k=map(int,input().split())
if a-b>10**18:
  print("Unfair")
else:
  if k%2==0:
    print(a-b)
  else:
    print(b-a)
def dia(Node,i,j):
	lst = []
	Node.remove(i)
	if(len(Node) == 0):
		lst.append(1)
	else:
		for n in Node:
			t = dia(A[n],j,n)
			lst.append(t+1)
	return max(lst)
		
N = input()
A = [[] for i in range(N)]
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	A[a2-1].append(b2-1)
	A[b2-1].append(a2-1)
lst = []
for n in A[0]:
	lst.append(dia(A[n],0,n))
m1 = max(lst)
lst.remove(m1)
if(len(lst) == 0):
	m2 = 1
else:
	m2 = max(lst)+1
if((m1 + m2) % 3 == 2):
	print("Second")
else:
	print("First")

### FIXED CODE ###

from collections import deque
def dia(i):
	lst = [-1]*N
	lst[i] = 0
	q = deque([i])
	while q:
		c = q.popleft()
		l = lst[c]
		for i in A[c]:
			if lst[i] != -1:
				continue
			else:
				lst[i] = l+1
				q.append(i)
	return lst.index(max(lst))
def dia2(i):
	lst = [-1]*N
	lst[i] = 0
	q = deque([i])
	while q:
		c = q.popleft()
		l = lst[c]
		for i in A[c]:
			if lst[i] != -1:
				continue
			else:
				lst[i] = l+1
				q.append(i)
	return max(lst)+1
N = input()
A = [[] for i in range(N)]
for i in range(N-1):
	a2,b2 = map(int, raw_input().split())
	A[a2-1].append(b2-1)
	A[b2-1].append(a2-1)
if((dia2(dia(0))) % 3 == 2):
	print("Second")
else:
	print("First")
N= int(input())
count=0
for i in range(N):
	p,q=map(int,input().split(' '))
	if p==q:
		count+=1
	else:
		count=0

if count>=3:
	print('Yes')
else:
  	print('No')

### FIXED CODE ###

S= input()
if S[-1]=='s':
	S+='es'
else:
	S+='s'
print(S)
import numpy as np

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

if k > 10**(18):
    print(-1)
else:
    print(int(np.prod(A)))

### FIXED CODE ###

n = input()
A = list(map(int,input().split()))
s = 1
A.sort()
for a in A:
  s *= a
  if s > 10**18:
    s = -1
    break
print(s)
total,okasi=map(int,input().split())
sunuke=[]

for i in range(okasi):
  di=int(input)
  A=list(map(int,input().split()))
  for a in A:
    sunuke.append(input())
    
print(total-len(set(sunuke)))    

### FIXED CODE ###

total,okasi=map(int,input().split())
sunuke=[]
for i in range(okasi):
  d=int(input())
  A=list(map(int,input().split()))
  for a in A:
    sunuke.append(a)
    
    
ans=total-len(set(sunuke))
 
print(ans)
S = input()
S_rvs = S[::-1]
N = len(S)

if N >= 7 and S == S_rvs and S[:(N-1)/2] == S_rvs[(N+3)/2:] and S[(N+3)/2:] == S_rvs[:(N-1)/2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = input()
S_rvs = S[::-1]
N = len(S)
left = int((N-1)/2)
right = int((N+3)/2-1)

if S == S_rvs and S[:left] == S_rvs[right:] and S[right:] == S_rvs[:left]:
    print("Yes")
else:
    print("No")
# 077a

def atc_077a(input_value: str) -> str:
    C1 = input_value[0]
    C2 = input_value[1]

    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]
        return "YES"
    else:
        return "NO"


C1 = input()
C2 = input()
print(atc_077a([C1, C2]))


### FIXED CODE ###

# 077a

def atc_077a(input_value: str) -> str:
    C1 = input_value[0]
    C2 = input_value[1]

    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
        return "YES"
    else:
        return "NO"


C1 = input()
C2 = input()
print(atc_077a([C1, C2]))
from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=odd//2 +1
else:
  k=(odd+1)//2
tmp=0
for i in range(1,k+1):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)

### FIXED CODE ###

from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=0
else:
  k=1
tmp=0
for i in range(k,odd+1,2):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)
A, B, C, D = map(int, input().split())

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

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

print(a*b // gcd(a, b))

ans_c = (B - A) // C
ans_d = (B - A) // D
i = (B - A) // (C * D // gcd(C, D))

print(B - A - ans_c - ans_d + i)

### FIXED CODE ###

A, B, C, D = map(int, input().split())

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

G = C * D // gcd(C, D)

ans_b = B - B//C - B//D + B//G
ans_a = A - 1 - (A-1)//C - (A-1)//D + (A-1)//G

print(ans_b - ans_a)
K = int(input())
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    N = ((N * 10) + 7) % K

### FIXED CODE ###

K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)
N, X = map(int, input().split())
A = list(map(int,input().split()))
​
B = []
for i in range(N):
    B.append(abs(X- A[i]))
print(min(B))

### FIXED CODE ###

#import math
import fractions
from functools import reduce

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

B = []
for i in range(N):
    B.append(abs(X- A[i]))

#最大公約数    
def gcd_list(numbers):
    #return reduce(math.gcd, numbers)
    return reduce(fractions.gcd, numbers)

print(gcd_list(B))
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()

### FIXED CODE ###

import  fractions

def lcm(x, y):
    return (x * y) //  fractions.gcd(x, y)


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()
import numpy as np
H,W = mmap(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))


### FIXED CODE ###

import numpy as np
H,W = map(int, input().split())
S = [[] for i in range(H)]
for i in range(H):
  S[i] = list(input())
S = np.array(S)
S = np.where(S=="#",0,1)

l = np.zeros((H,W))
l[:,-1] = S[:,-1]
r = np.zeros((H,W))
r[:,0] = S[:,0]
u = np.zeros((H,W))
u[-1] = S[-1]
d = np.zeros((H,W))
d[0] = S[0]

for i in range(W-2,-1,-1):
  l[:,i] = (l[:,i+1]+1)*S[:,i]
for i in range(1,W):
  r[:,i] = (r[:,i-1]+1)*S[:,i]
for i in range(H-2,-1,-1):
  u[i] = (u[i+1]+1)*S[i]
for i in range(1,H):
  d[i] = (d[i-1]+1)*S[i]

print(int(np.max(l+r+u+d-3)))
import sys
read = sys.stdin.read
from itertools import accumulate

n, *A = map(int, read().split())
S = []
now = 0
for a in A:
  if now < a:
    now = a
    S.append(a)
l = len(S)
C = [0]*l
D = {e:i for i, e in enumerate(S)}
K = [-1]*l
for i, a in enumerate(A):
  idx = D[a]
  if K[idx] == -1:
    K[idx] = i
  C[idx] += 1
S = [0] + S
C = list(accumulate(C[::-1]))[::-1]
L = [0]*n
for i, k in enumerate(K):
  L[k] = (S[i+1]-S[i]) * C[i]
print(*L, sep="\n")

### FIXED CODE ###

import sys
read = sys.stdin.read

n, *A = map(int, read().split())
S = sorted([(a, i) for i, a in enumerate(A)], reverse=True)
X, Y = zip(*S)
m = 10**9
L = [0]*n
for i, y in enumerate(Y):
  m = min(m, y)
  if i == n-1:
    L[m] += (i+1) * X[i]
  else:
    L[m] += (i+1) * (X[i] - X[i+1])
print(*L, sep="\n")
S = input()

S[3] = '8'
print(S)

### FIXED CODE ###

S = input()
 
print(S[0:3] + '8' + S[4:])
import sys
import math

def main():
    input = sys.stdin.readline
    
    L = [int(input()) for i in range(5)]
    
    #最後の注文を決める
    last_orders = [10 - (i % 10) for i in L if i % 10 != 0]
    last_order = max(last_orders)
    
    #一の位を切り上げ
    all_order = sum([math.ceil(i / 10) * 10 for i in L])
    
    print(all_order - last_order)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import math

def main():
    input = sys.stdin.readline
    
    L = [int(input()) for i in range(5)]
    
    #最後の注文を決める
    last_orders = [10 - (i % 10) for i in L if i % 10 != 0]
    last_order = 0 if not last_orders else max(last_orders)
    
    #一の位を切り上げ
    all_order = sum([math.ceil(i / 10) * 10 for i in L])
    
    print(all_order - last_order)
    
if __name__ == '__main__':
    main()
S = int(input())
h = S // 3600
m = S // 60 -S // 3600
s = S // 60
print(h:m:s)
 


### FIXED CODE ###

S = int(input())
h = S//3600
m = (S//60)-60*(S//3600)
s = S%60
print('{}:{}:{}'.format(h,m,s))
a = input()
b = input()
print(6-a-b)

### FIXED CODE ###

number1 = int(input())
number2 = int(input())
choices = [1,2,3]
choices.remove(number1)
choices.remove(number2)
print(*choices)
import sys, os, re
from pprint import pprint
from math import sin, cos, sqrt, radians

n, m = list(map(int, sys.stdin.readline().strip().split()))
g = [[] for x in range(n)]

for i in range(n):
    x, y = list(map(int, sys.stdin.readline().strip().split()))
    x -= 1
    y -= 1
    g[x].append(y)
    g[y].append(x)

ans = {0: -1}

print("Yes")
for i in range(1, n):
    print(ans[i]+1)

### FIXED CODE ###


import sys, os, re
from pprint import pprint
from math import sin, cos, sqrt, radians

n, m = list(map(int, sys.stdin.readline().strip().split()))
g = [[] for x in range(n)]

for i in range(m):
    x, y = map(int, sys.stdin.readline().strip().split())
    x -= 1
    y -= 1
    g[x].append(y)
    g[y].append(x)

if [] in g:
    print("No")
    exit(0)

ans = {0: -1}
tmp = [0]

while len(ans) < n:
    tmp_next = []
    for k in tmp:
        for node in g[k]:
            if node not in ans:
                ans[node] = k
                tmp_next.append(node) 
                flag = True

        tmp = tmp_next
        if flag == False:
            break

    """
    flag = False    
    for k, v in list(ans.items()):
        for node in g[k]:
            if node not in ans:
                ans[node] = k
                flag = True
    if flag == False:
        break
    """

print("Yes")
for i in range(1, n):
    print(ans[i]+1)
from collections import defaultdict
N, M = map(int, input().split())
in_path = defaultdict(lambda: [])
out_path = defaultdict(lambda: [])

for m in range(M):
    x, y = map(int, input().split())
    in_path[y].append(x)
    out_path[x].append(y)

check = [False]*(N+1)
memo = [0]*(N+1)

def dp(i):
    if check[i] == True:
        return memo[i]
    else:
        check[i] = True
        if not out_path[i]:
            memo[i] = 0
            return 0
        else:
            max_path = 0
            for node in out_path[i]:
                max_path = max(dp(node), max_path)
            max_path += 1
            memo[i] = max_path
            return max_path


ans = 0
for i in range(1, N+1):
    ans = max(ans, dp(i))

print(ans)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())
in_path = defaultdict(lambda: [])
out_path = defaultdict(lambda: [])

for m in range(M):
    x, y = map(int, input().split())
    in_path[y].append(x)
    out_path[x].append(y)

check = [False]*(N+1)
memo = [0]*(N+1)


def dp(i):
    if check[i]:
        return memo[i]
    else:
        check[i] = True
        if not out_path[i]:
            return 0
        else:
            max_path = 0
            for node in out_path[i]:
                max_path = max(dp(node), max_path)
            max_path += 1
            memo[i] = max_path
            return max_path


ans = 0
for i in range(1, N+1):
    ans = max(ans, dp(i))

print(ans)
n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

left=0
right=n-p-1

while  right -left >1:
    mid =(left+right)//2
    if a[mid]+m < a[n-p]:
        left=mid
    else:
        j=v-(mid+1+p-1)
        if j <= 0:
            right=mid
        else:
            sum=0
            for k in range(mid+1,n-p+1,1):
                if m+a[mid]-a[k] < 0:
                    left = mid
                    break
                sum+=a[mid]+m-a[k]
                if sum >= j*m:
                    right=mid
                    break
                if k==n-p:
                    left=mid


p1 = 0
mid = left
if a[mid] + m < a[n - p]:
        p1 = 0
else:
        j = v - (mid + 1+p-1)
        if j <= 0:
            p1 = 1
        else:
            sum = 0
            for k in range(mid + 1, n+p+1, 1):
                if m + a[mid] - a[k] < 0:
                    p1 = 0
                    break
                sum += a[mid] + m - a[k]
                print("s", sum, j * m, a[k])
                if sum >= j * m:
                    p1 = 1
                    break
                if k == n-p:
                    p1 = 0
p2 = 0
mid = right
if a[mid] + m < a[n - p]:
        p1 = 0
else:
        j = v - (mid + 1 + p - 1)
        if j <= 0:
            p2 = 1
        else:
            sum = 0
            for k in range(mid + 1, n + p + 1, 1):
                if m + a[mid] - a[k] < 0:
                    p2 = 0
                    break
                sum += a[mid] + m - a[k]
                print("s", sum, j * m, a[k])
                if sum >= j * m:
                    p2 = 1
                    break
                if k == n - p:
                    p2 = 0

if left==right:
    if p1==1:
        print(n-left)
    else:
        print(n-left-1)
else:
    if p1==1:
        print(n-left)
    elif p2==1:
        print(n-left-1)
    else:
        print(n-left-2)

### FIXED CODE ###

n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

left = 0
right = n - p -1

while right - left >=0:
    mid = (left + right) // 2
    if a[mid] + m < a[n - p]:
        left = mid + 1
    else:
        j = v - (mid + 1 + p - 1)
        if j <= 0:
            right = mid-1
        else:
            sum = 0
            for k in range(mid + 1, n - p + 1, 1):
                if m + a[mid] - a[k] < 0:
                    left = mid + 1
                    break
                sum += a[mid] + m - a[k]
                if sum >= j * m:
                    right = mid-1
                    break
                if k == n - p:
                    left = mid + 1

print(n-left)
N = int(input())
S = input()
SS = list(S)
n = 0
for i in range(N):
  for j in range(N):
    for k in range(N):
      kk = []
      kk.append(i)
      kk.append(j)
      kk.append(k)
      kk.sort()
      if SS[int(kk[0])] != SS[int(kk[1])] and SS[int(kk[1])] != SS[int(kk[2])] and SS[int(kk[2])] != SS[int(kk[0])]:
        if int(kk[1]) - int(kk[0]) != int(kk[2]) - int(kk[1]):
            n+=1
ans = int(n / 6)
print(ans)

### FIXED CODE ###

a = int(input())
aa = list(str(a))
n = 0
for i in range(len(aa)):
    b = int(aa[i])
    if b == 7:
        n +=1
    else:
        n = n
if n > 0:
    print("Yes")
else:
    print("No")
class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(100)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top]


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main()

### FIXED CODE ###

class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top]


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main()
import sys

args = sys.argv

print(int(args[0])*int(args[0]) - int(args[1]))


### FIXED CODE ###

x, y = [int(input()) for i in range(2)]
print(x*x - y)
import sys;n=sys.stdin.readline();a=map(int,sys.stdin.readline().strip().split());print " ".join(reversed(a))

### FIXED CODE ###

import sys;n=sys.stdin.readline();a=map(int,sys.stdin.readline().strip().split());print " ".join(map(str, reversed(a)))
import numpy as np

N,W = list(map(int,input().split()))
w_l = []
v_l = []
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    w,v = list(map(int,input().split()))
    w_l.append(w)
    v_l.append(v)
for i in range(N):
    dp[w_l[i]:] = np.maximum(dp[w_l[i]:],dp[:-w_l[i]] + v_l[i])
print(dp[W])

### FIXED CODE ###

import numpy as np

N,W = list(map(int,input().split()))
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    w,v = list(map(int,input().split()))
    dp[w:] = np.maximum(dp[w:],dp[:-w] + v)
print(dp[-1])
import numpy as np
n=int(input())
cnt=np.zeros(n+1,dtype = int)
for i in range(1,n+1):
    cnt[i::i]+=1
ans=cnt*np.arrange(n+1)
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(1,n+1):
    k=n//i
    ans+=i*k*(k+1)//2
print(ans)
from itertools import permutations
import heapq

def dijkstra(N, G, s):
    INF = 10**40
    d = [INF] * N
    d[s] = 0
    q = [(0, s)]
    while q:
        c, v = heapq.heappop(q)
        if d[v] < c:
            continue
        for t, co in G[v]:
            if d[v] + co < d[t]:
                d[t] = d[v] + co
                heapq.heappush(q, (d[t], t))
    return d


def main():
    N, M, _ = map(int, input().split())
    R = list(map(int, input().split()))
    R = [r - 1 for r in R]
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a - 1].append((b - 1, c))
        G[b - 1].append((a - 1, c))
    RM = []
    for r in R:
        d = dijkstra(N, G, r)
        RM.append([d[rr] for rr in R])
    m = 10 ** 40
    for i in permutations(range(R)):
        t = i[0]
        c = 0
        for r in i[1:]:
            c += RM[t][r]
            t = r
        m = min(m, c)
    return m


print(main())


### FIXED CODE ###

from itertools import permutations
import heapq

def dijkstra(N, G, s):
    INF = 10**40
    d = [INF] * N
    d[s] = 0
    q = [(0, s)]
    while q:
        c, v = heapq.heappop(q)
        if d[v] < c:
            continue
        for t, co in G[v]:
            if d[v] + co < d[t]:
                d[t] = d[v] + co
                heapq.heappush(q, (d[t], t))
    return d


def main():
    N, M, _ = map(int, input().split())
    R = list(map(int, input().split()))
    R = [r - 1 for r in R]
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a - 1].append((b - 1, c))
        G[b - 1].append((a - 1, c))
    RM = []
    for r in R:
        d = dijkstra(N, G, r)
        RM.append([d[rr] for rr in R])
    m = 10 ** 40
    for i in permutations(range(len(R))):
        t = i[0]
        c = 0
        for r in i[1:]:
            c += RM[t][r]
            t = r
        m = min(m, c)
    return m


print(main())