Harryxun/stf_run huggingface dataset:
def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    a = []
    for i in range(N):
        b = input().split()
        if len(b[0]) > 10 or len(b[0]) < 1:
            print("input S error")
            exit()

        if int(b[1]) < 0 or int(b[1]) > 100:
            print("input P error")
            exit()

        b.append(i + 1)
        a.append(b)
        
    a.sort()
    c = []
    answer = []
    
    for i in range(len(a) - 1):
        c.append(a[i])
        
        if a[i][0] != a[i+1][0] and i != len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            c = []

        elif a[i][0] != a[i+1][0] and i == len(a) - 2:
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
            answer += a[i + 1]

        elif a[i][0] == a[i+1][0] and i == len(a) - 2:
            c.append(a[i + 1])
            c.sort(key=lambda x: int(x[1]), reverse=True)
            answer += c
    
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()

    


### FIXED CODE ###

def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    answer = []
    for i in range(N):
        s, p = input().split()
        answer.append([s, -int(p), i+1])

    answer.sort()
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()
s=list(input())
s[3]=8
for in in s:
  print(s,end="")


### FIXED CODE ###

s=input()
print("2018"+s[4:])
#!/usr/bin/env python3
import math
from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: v - X, x))

    g = reduce(math.gcd, y)

    print(g)


if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python3
from functools import reduce

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while 0 < b:
        a, b = b, a % b
    return a


def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: abs(v - X), x))

    a = reduce(gcd, y)

    print(a)


if __name__ == '__main__':
    main()
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(n)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=1
        else:
            w[y]=x
            s[x]+=1
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])

### FIXED CODE ###

n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(m)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=s[x]
        else:
            w[y]=x
            s[x]+=s[y]
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])
N,M=map(int,input().split())
par=[[] for _ in range(N)]
for _ in range(N-1+M):
  a,b=map(int,input().split())
  par[b-1].append(a)

dep=[-1]*N
def depth(n):
  if dep[n-1]!=-1:
    return dep[n-1]
  else:
    if len(par[n-1])==0:
      dep[n-1]=0
      return 0
    else:
      dep[n-1]=max([depth(i) for i in par[n-1]])+1
      return dep[n-1]

for i in range(N):
  if len(par[i])==0:
    print(0)
  elif len(par[i])==1:
    print(par[i][0])
  else:
    m=-1
    a=par[i][0]
    for j in par[i]:
      d=depth(j)
      if m<d:
        m=d
        a=j
    print(a)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
N,M=map(int,input().split())
par=[[] for _ in range(N)]
for _ in range(N-1+M):
  a,b=map(int,input().split())
  par[b-1].append(a)

dep=[-1]*N
def depth(n):
  if dep[n-1]!=-1:
    return dep[n-1]
  else:
    if len(par[n-1])==0:
      dep[n-1]=0
      return 0
    else:
      dep[n-1]=max([depth(i) for i in par[n-1]])+1
      return dep[n-1]

for i in range(N):
  if len(par[i])==0:
    print(0)
  elif len(par[i])==1:
    print(par[i][0])
  else:
    m=-1
    a=par[i][0]
    for j in par[i]:
      d=depth(j)
      if m<d:
        m=d
        a=j
    print(a)
N, X, Y = map(int, input().split())

counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        # i -> x 直接
        d1 = abs(j-i)
        # i -> X -> Y -> j
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2, d3)
        counts[d] += 1


for i in range(1, N):
    print(counts[i])

### FIXED CODE ###

N, X, Y = map(int, input().split())


counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        # i -> x 直接
        d1 = abs(j-i)
        # i -> X -> Y -> j
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2)
        counts[d] += 1


for i in range(1, N):
    print(counts[i])
n, m = map(int, input().split())
x = list(set(map(int, input().split())))
l = [x[i+1]-x[i] for i in range(n-1)]
l.sort(reverse=True)
print(sum(l[n-1:]))

### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
l = [x[i+1]-x[i] for i in range(m-1)]
l.sort(reverse=True)
print(sum(l[n-1:]))
import sys

# A - Connection and Disconnection
import string

S = input()
K = int(input())
T = S + S[0]

lower = string.ascii_lowercase
ans = 0
is_specila_case = False

for c in lower:
	key = c * 2
	ans += T.count(key)

	if T.endswith(key):
		is_specila_case = True

ans *= K

if is_specila_case:
	print(ans - 1)
else:
	print(ans)import sys

# A - Connection and Disconnection
import string

S = input()
K = int(input())
T = S + S[0]

lower = string.ascii_lowercase
ans = 0
is_specila_case = False

for c in lower:
	key = c * 2
	ans += T.count(key)

	if T.endswith(key):
		is_specila_case = True

ans *= K

if is_specila_case:
	print(ans - 1)
else:
	print(ans)

### FIXED CODE ###

# A - Connection and Disconnection
def count(s, c):
	count_ = s.count(c*2)
	
	while c*3 in s:
		s = s.replace(c*3, c+'_'+c)
	
	while c*2 in s:
		s = s.replace(c*2, c+'_')
	
	return min(count_, s.count('_'))


def get_startswith(s, c):
	key = c
	
	while s.startswith(key+c):
		key += c
	
	return len(key)
	
	
def get_endswith(s, c):
	key = c
	
	while s.endswith(key+c):
		key += c
	
	return len(key)


import string

S = input()
K = int(input())

lower = string.ascii_lowercase
ans = 0

if S[0] == S[-1:]:
	start = get_startswith(S, S[0])
	end = get_endswith(S, S[0])	
	
	if start == end == len(S):
		print(len(S) * K // 2)
	else:
		ans = 0
		
		ans += start // 2
		ans += end // 2
		ans += ((start + end) // 2) * (K - 1)
		
		for c in lower:
			ans += count(S[start:len(S)-end], c) * K

		print(ans)	
else:
	for c in lower:
		ans += count(S, c)

	print(ans * K)
mystring = raw_input()
string_arr = []
q = int(raw_input())
for char in mystring:
	string_arr.append(char)
for i in range(0,len(string_arr)):
	val = ord('z') - ord(string_arr[i]) + 1
	if val <= q:
		string_arr[i] = 'a'
		q = q-val
if q!=0:
	q=q%26
	string_arr[len(string_arr)-1] = chr(ord('a')+(ord(string_arr[i])+q)%ord('a'))
print "".join(string_arr)

### FIXED CODE ###

mystring = raw_input()
print mystring[0:4] + " " + mystring[4:]
O = input().strip()
E = input().strip()

end = 0
if len(O)-len(E)=1:
  end = 1
ans = ''
for i in range(len(O)-end):
  ans += O[i] + E[i]
if end==1:
  ans += O[-1]
print(ans)

### FIXED CODE ###

O = input().strip()
E = input().strip()

end = 0
if len(O)-len(E)==1:
  end = 1
ans = ''
for i in range(len(O)-end):
  ans += O[i] + E[i]
if end==1:
  ans += O[-1]
print(ans)
Z,X,Y =int(input().split())
print(X,Y,Z)

### FIXED CODE ###

Y, Z, X =map(int, input().split())
print(X,Y,Z)
n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)

##
## Template
##

## map, filter, reduce

# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]


### FIXED CODE ###

import math
n, m = list(map(int, input().split()))
print(m*pow(m-1,n-1))
from math import ceil
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=5 else 4 +ceil(N/min(L))


### FIXED CODE ###

N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=N else 4 -((-N)//min(L)))
import sympy
n=int(input())
ans=0
for i in range(n):
    ans+=(i+1)*(sympy.divisor_count(i+1))
print(ans)
    

### FIXED CODE ###

n=int(input())
x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
while i<=10**7+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**7+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1
def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
s=0
for i in range(1,n+1):
    s+=i*f(i)
print(s)
red = int(input())
blue = int(input())
ans = input()
if ans=="blue":
  blue--
else:
  red--
print(red)
print(blue)

### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, B)
s=input()
t=input()
a=int(input())
b=int(input())
u=input()
if(u==s):
    print(a-1,b)
elif(u==t):
    print(a,b-1)
    


### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()
if(u==s):
    print(a-1,b)
elif(u==t):
    print(a,b-1)
N = int(input())
ans = [0]*(N+1)
for x in range(1,80):
    for y in range(1,80):
        for z in range(1,80):
            tmp = x**2 + y**2 + z**2 +x*y + y*z + z*x
            if tmp > N:
                continue
            ans[tmp]+=1
for i in range(1,N+1):
    print(ans[i])


### FIXED CODE ###

#template
def inputlist(): return [int(j) for j in input().split()]
#template
L,R,d = inputlist()
count = 0
for i in range(L,R+1):
    if i % d == 0:
        count +=1
print(count)
a,b,h = map(int,input().split())
print((a + b) * h // 2)


### FIXED CODE ###

a,b,h = [int(input()) for i in range(3)]
print((a + b) * h // 2)
N, M = map(int, input().split())
MOD = 10**9+7


# 繰り返し二乗法
# 普通の pow() より高速
def pow2(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans


# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow2(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


# M を素因数分解
m_nokori = M
ans = 1
for i in range(2, M+1):
    if m_nokori == 1:
        break
    cnt = 0
    while m_nokori % i == 0:
        cnt += 1
        m_nokori //= i
    # cnt が 2^X とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)


### FIXED CODE ###

# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-k)/(k-1)+1))


### FIXED CODE ###

k=[]
k=list(map(str,input()))
n=0
for i in range(4):
    if k[i]=='+':
        n+=1
    else:
        n-=1
print(n)
MOD = 10**9+7
N, K = map(int, input().split())
*A, = map(int, input().split())

allm = True
for a in A:
    if a > 0:
        allm = False
        break

if N == K:
    ans = 1
    for a in A:
        ans = (ans*a) % MOD
    print(ans)
elif allm and K % 2 == 1:
    A.sort()
    A.reverse()
    ans = 1
    for a in A[:K]:
        ans = (ans*a) % MOD
    print(ans)
else:
    p, m = [], []
    for a in A:
        if a > 0:
            p.append(a)
        if a < 0:
            m.append(-a)
    p.sort(key=lambda k: -k)
    m.sort(key=lambda k: -k)

    pi, mi = 0, 0
    ans = 1
    while K > 0:
        if K == 1:
            ans = (ans*p[pi]) % MOD
            break
        elif pi < len(p)-1 or mi < len(m)-1:
            pv, mv = 0, 0
            if pi < len(p)-1:
                pv = p[pi]*p[pi+1]
            if mv < len(m)-1:
                mv = m[mi]*m[mi+1]

            if pv > mv:
                ans = (ans*pv) % MOD
                pi += 2
            else:
                ans = (ans*mv) % MOD
                mi += 2
            K -= 2
        else:
            ans = 0
            break
    print(ans)


### FIXED CODE ###

MOD = 10**9+7
N, K = map(int, input().split())
*A, = map(int, input().split())

allm = True
for a in A:
    if a > 0:
        allm = False
        break

if N == K:
    ans = 1
    for a in A:
        ans = (ans*a) % MOD
    print(ans)
elif allm and K % 2 == 1:
    A.sort()
    A.reverse()
    ans = 1
    for a in A[:K]:
        ans = (ans*a) % MOD
    print(ans)
else:
    p, m = [], []
    for a in A:
        if a > 0:
            p.append(a)
        if a < 0:
            m.append(-a)
    p.sort(key=lambda k: -k)
    m.sort(key=lambda k: -k)

    pi, mi = 0, 0
    ans = 1
    while K > 0:
        if K == 1:
            ans = (ans*p[pi]) % MOD
            break
        elif pi < len(p)-1 or mi < len(m)-1:
            pv, mv = 0, 0
            if pi < len(p)-1:
                pv = p[pi]*p[pi+1]
            if mi < len(m)-1:
                mv = m[mi]*m[mi+1]

            if pv > mv:
                ans = (ans*pv) % MOD
                pi += 2
            else:
                ans = (ans*mv) % MOD
                mi += 2
            K -= 2
        else:
            ans = 0
            break
    print(ans)
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False
reali = 0 #tの文が始まるときのi
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
    break
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

### FIXED CODE ###

sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False  
reali = 0 #tの文が始まるときのi
if lt > ls:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")
from collections import defaultdict
from heapq import heappop, heappush
from math import isinf

V, E, r = map(int, input())

e = defaultdict(list)
for i in range(E):
    s, t, length = map(int, input())
    e[s].append((length, t))

distance = [float('inf')] * v          # 各頂点への距離の初期値
distance[r] = 0                        # 始点への距離は 0

# ダイクストラ
heap = [(distance[r], r)]
while heap:
    du, u = heappop(heap)
    for length, v in e[u]:
        if distance[v] > e[u] + length:
            distance[v] = e[u] + length
            heappush(heap, (distance[v], v))

for d in distance:
    print('INF' if math.isinf(di) else di)

### FIXED CODE ###

#!/usr/bin/env python
from collections import defaultdict
from heapq import heappop, heappush
from math import isinf

V, E, r = map(int, input().split())

e = defaultdict(list)
for i in range(E):
    s, t, length = map(int, input().split())
    e[s].append((length, t))

distance = [float('inf')] * V          # 各頂点への距離の初期値
distance[r] = 0                        # 始点への距離は 0

# ダイクストラ
heap = [(distance[r], r)]
while heap:
    du, u = heappop(heap)
    for length, v in e[u]:
        if distance[v] > distance[u] + length:
            distance[v] = distance[u] + length
            heappush(heap, (distance[v], v))

for d in distance:
    print('INF' if isinf(d) else d)
import random
S = input()

A = random.randint(0, len(S) - 2)

print(S[A] + S[A + 1] + S[A + 2])


### FIXED CODE ###

import random
S = input()

A = random.randint(0, len(S) - 3)

print(S[A] + S[A + 1] + S[A + 2])
import numpy as np

H, W, M = map(int, input().split())
h = np.zeros(H)
w = np.zeros(W)
m = np.zeros(H, W)
ans = 3
'''
for _ in range(M):
    tmp_h, tmp_w = map(int, input().split())
    h[tmp_h-1] += 1
    w[tmp_w-1] += 1
    m[tmp_h-1, tmp_w-1] = 1.

h_max = np.max(h)
h_max_index = list(zip(*np.where(h == h_max)))
w_max = np.max(w)
w_max_index = list(zip(*np.where(w == w_max)))

for i in h_max_index:
    for j in w_max_index:
        if m[i[0]][j[0]] == 1.:
            tmp = h_max + w_max -1
        else:
            tmp = h_max + w_max
        if ans < tmp:
            ans = tmp
'''
print(int(ans))


### FIXED CODE ###

import numpy as np

H, W, M = map(int, input().split())
h = np.zeros(H)
w = np.zeros(W)
m = {}
flag = 0

for _ in range(M):
    tmp_h, tmp_w = map(int, input().split())
    h[tmp_h-1] += 1
    w[tmp_w-1] += 1
    m[(tmp_h-1, tmp_w-1)] = 1.

h_max = np.max(h)
h_max_index = list(zip(*np.where(h == h_max)))
w_max = np.max(w)
w_max_index = list(zip(*np.where(w == w_max)))

for i in h_max_index:
    for j in w_max_index:
        if (i[0], j[0]) not in m.keys():
            flag = 1
            break

if flag == 1:
    print(int(h_max + w_max))
else:
    print(int(h_max + w_max - 1))
N = int(input())
S, T = input("Enter a two value: ").split(' ') 
if((len(S)==N)&&(len(T)==N)):
  print(S+T)

### FIXED CODE ###

n = int(input())
s,t = input().split()
 
ans = []
 
for i in range(n):
    ans.append(s[i])
    ans.append(t[i])
    
print("".join(ans))
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = []
    count = 0
    if N > 2:
        for i in range(1, N):
            j = i + 1
            if H[-i] <= H[-j]:
                count += 1
            else:
                ans.append(count)
                count = 0
    elif N == 2:
        if H[0] >= H[1]:
            ans.append(1)
    elif N == 1:
        ans.append(1)

    print(max(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = 0
    count = 0

    if N == 2:
        if H[0] >= H[1]:
            ans = 1
    elif N > 2:
        for i in range(1, N):
            j = i + 1
            if H[-i] <= H[-j]:
                count += 1
                if j == N:
                    if ans <= count:
                        ans = count
            else:
                if ans <= count:
                    ans = count
                count = 0
    print(ans)


if __name__ == "__main__":
    main()
S = int(input())
W = int(input())

if S < W:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

S, W = map(int,input().split())

if S <= W:
    print('unsafe')
else:
    print('safe')
n,m=map(int,input().split())
if n==1 and m==1:
  ans=0
if n==1 and m>=2:
  ans=m*(m-1)//2
if m==1 and n>=2:
  ans=n*(n-1)//2
if m>=2 and n>=2:
  ans= n*(n-1)//2+m*(m-1)//2
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
if n<=1 and m<=1:
  ans=0
if n<=1 and m>=2:
  ans=m*(m-1)//2
if m<=1 and n>=2:
  ans=n*(n-1)//2
if m>=2 and n>=2:
  ans= n*(n-1)//2+(m*(m-1)//2)
print(ans)
N, Q = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
C = [0] * (N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x

Ans = [0] * (N+1)
def dfs(v, p, a):
    global ans
    a += C[v]
    Ans[v] = a
    for u in E[v]:
        if u!=p:
            dfs(u, v, a)
dfs(1, 0, 0)
print(" ".join(map(str, Ans[1:])))


### FIXED CODE ###

import sys
input = sys.stdin.readline

import sys
sys.setrecursionlimit(500000)
N, Q = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
C = [0] * (N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x
Ans = [0] * (N+1)
def dfs(v, p, a):
    a += C[v]
    Ans[v] = a
    for u in E[v]:
        if u!=p:
            dfs(u, v, a)
dfs(1, 0, 0)
print(" ".join(map(str, Ans[1:])))
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(a+"+"+b+"+"+c+"+"+d+"="+7)
  exit()
if a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"="+7)
  exit()
if a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"="+7)
  exit()
if a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"="+7)
  exit()
if a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"="+7)
  exit()
if a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"="+7)
  exit()
if a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"="+7)
  exit()
if a-b-c-d==7:
  print(a+"-"+b+"-"+c+"-"+d+"="+7)
  exit()

### FIXED CODE ###

N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c+d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b-c+d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b+c-d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c+d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c-d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a+b-c-d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c-d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()