Harryxun/stf_run huggingface dataset:
import sys

N, M = map(int, sys.stdin.readline().split())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

tree = [[] for _ in range(N + 1)]
for a, b in AB:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

# 深さ優先探索
sign_list = [[] for _ in range(N)]
visited = [0] * N
visited[0] = 1

def dfs(tree, pos):
    visited[pos] = 1
    children = []
    for r in tree[pos]:
        if visited[r] == 0:
            children.append(r)
    for c in children:
        sign_list[c] = pos + 1
        dfs(tree, c)

dfs(tree, 0)

for i in range(1, N):
  print('Yes')
  print(sign_list[i])


### FIXED CODE ###

import sys
from collections import deque

N, M = map(int, sys.stdin.readline().split())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]

for a, b in AB:
    graph[a - 1].append(b)
    graph[b - 1].append(a)
    
queue = deque()
visited = [0] * N
sign_list = [0] * N 

queue.append(1)
visited[0] = 1

while queue:
    room = queue.popleft()
    next_rooms = graph[room - 1]
    for r in next_rooms:
        if visited[r - 1] == 0:
            queue.append(r)
            sign_list[r - 1] = room
            visited[r - 1] = 1

yes = True
for s in sign_list[1:]:
    if s == 0:
        yes = False

if yes:
    print("Yes")
    for s in sign_list[1:]:
        print(s)
else:
    print("No")
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input, split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)

### FIXED CODE ###

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

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)
s = bytearray(raw_input())
N = int(raw_input())
dis = [ord('z')-c for c in s]

for idx, d in enumerate(dis[:-1]):
    if d+1 <= N:
        s[idx] = 'a'
        N -= (d+1)
if N > 0:
    N %= 26
    t = (dis[-1]-N) % 26
    s[-1] = chr(ord('z') - t)
print s

### FIXED CODE ###

txt = raw_input()
print txt[:4], txt[4:]
def a():
    r = int(input())
    print(2 * 3.141592653589 * r)
##########
if __name__ == "__main__":
    b()


### FIXED CODE ###

def a():
    r = int(input())
    print(2 * 3.141592653589 * r)


##########
if __name__ == "__main__":
    a()
N, M = map(int, input().split())
A = list(map(int, input().split()))

need_matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

max_num_dict = {}
for a in A:
    if need_matches[a] in max_num_dict:
        if a > max_num_dict[need_matches[a]]:
            max_num_dict[need_matches[a]] = a
    else:
        max_num_dict[need_matches[a]] = a

useful_num_list = list(max_num_dict.values())
dp = [-1] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    max_scale = -1
    for num in useful_num_list:
        if need_matches[num] <= i:
            scale = dp[i-need_matches[num]] + 1
            if max_scale < scale:
                max_scale = scale
    dp[i] = max_scale

useful_num_list.sort(reverse=True)
ans =""
n = N
while n > 0:
    ans_scale = ""
    for num in useful_num_list:
        if dp[n] - 1 == dp[n - need_matches[num]]:
            ans_scale = str(num)
            n -= need_matches[num]
            break
    ans += ans_scale
print(ans)


### FIXED CODE ###

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

need_matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    max_scale = -1
    for num in useful_num_list:
        if need_matches[num] <= i:
            scale = dp[i-need_matches[num]] + 1
            if max_scale < scale:
                max_scale = scale
    dp[i] = max_scale

useful_num_list.sort(reverse=True)
ans = 0
n = N
while n > 0:
    for num in useful_num_list:
        if n < need_matches[num]:
            continue
        if dp[n] - 1 == dp[n - need_matches[num]]:
            ans += num * (10**(dp[n]-1))
            n -= need_matches[num]
            break
print(ans)
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else
  print('Yes')


### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No\n')
else:
  print('Yes\n')
a, b, c = map(int, input().split())
d = max(a, b)
l = []
for i in range(d+1):
  if a % i == 0 and b % i == 0:
    l.append(i)
print(l[len(l)-c+1])

### FIXED CODE ###

a, b, c = map(int, input().split())
d = max(a, b)
l = []
for i in range(1,d+1):
  if a % i == 0 and b % i == 0:
    l.append(i)
print(l[len(l)-c])
n = int(input())
l = list(map(int, input().split())).sort()
a = l[n//2]
b = l[n//2 + 1]

print(b-a)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
a = l[n//2 - 1]
b = l[n//2]
 
print(b-a)
input_data = input()
data = split(int(input_data))
d = data[0]
t = data[1]
s = data[2]
print("Yes") if d / s > t else print("No")

### FIXED CODE ###

data = input()
data = data.split()
print("Yes") if int(data[0]) / int(data[2]) <= int(data[1]) else print("No")
N,T=map(int,input().split())
min=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<(T+1):
        if c<min:
            min=c           
if min==1001:
    print("TLE")
else:
    print(min)


### FIXED CODE ###

a=int(input())
if a==1:
    print("Hello World")
elif a==2 :
    b=int(input())
    c=int(input())
    print(b+c)
n, m = map(int, input().split())
a = {int(input()) for _ in range(m)}

dp = [0] * 10000
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, n + 1):
    if  (i - 1) not in a:
        dp[i] = dp[i] + dp[i - 1]
    if (i - 2) not in a:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
issafe = [True] * (n +1)
for _ in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * (n + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if  issafe[i - 1]:
        dp[i] = dp[i] + dp[i - 1]
    if issafe[i -  2]:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])
W,H,x,y = map(int, input().split())
answer = W*H/2
print(answer)
if W/2 == x && H/2 == y:
  print(1)
else:
  print(0)

### FIXED CODE ###

W,H,x,y = map(int, input().split())
answer = W*H/2
print(answer)
if W/2 == x and H/2 == y:
  print(1)
else:
  print(0)
n = int(raw_input())

card = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
 
for i in range(n):
  mark, nums = raw_input().split()
  deck[mark][nums-1] = 1
 
for i in ["S", "H", "C", "D"]:
  for j in range(13):
    if deck[i][j] == 0:
      print "%s %d" % (i, j+1)

### FIXED CODE ###

n = int(raw_input())

card = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
 
for i in range(n):
  mark, nums = raw_input().split()
  card[mark][int(nums)-1] = 1
 
for i in ["S", "H", "C", "D"]:
  for j in range(13):
    if card[i][j] == 0:
      print "%s %d" % (i, j+1)
import math
import fractions
import copy
import numpy as np

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
n = ip()
s = input()
scut = [s[i] for i in range(len(s))]
scut.sort()
for i in range(n-1):
	s = input()
	sncut = [s[i] for i in range(len(s))]
	sncut.sort()
	nextline = []
	while len(sncut) and len(scut):
	  if sncut[0] == scut[0]:
	  	nextline.append(sncut[0])
	  	scut.pop(0)
	  	sncut.pop(0)
	  elif sncut[0] > scut[0]:
	  	scut.pop(0)
	  else: sncut.pop(0)
	scut = copy.copy(nextline)
print(''.join(nextline))

### FIXED CODE ###

import math
import fractions
import copy
import numpy as np

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
n = ip()
s = input()
scut = [s[i] for i in range(len(s))]
scut.sort()
if n == 1:
	print(''.join(scut))
	exit(0)
for i in range(n-1):
	s = input()
	sncut = [s[i] for i in range(len(s))]
	sncut.sort()
	nextline = []
	while len(sncut) and len(scut):
	  if sncut[0] == scut[0]:
	  	nextline.append(sncut[0])
	  	scut.pop(0)
	  	sncut.pop(0)
	  elif sncut[0] > scut[0]:
	  	scut.pop(0)
	  else: sncut.pop(0)
	scut = copy.copy(nextline)
print(''.join(nextline))
list_len = int(input())
input_list = map(int, input().split)
even_list_len = list_len
count = 0
 
while:
	even_list = filter(lambda num: num % 2 , input_list)
    even_list_len = len(even_list)
	if list_len != even_list_len:
      break
    count += 1
    
print(count)

### FIXED CODE ###

input_list_len = int(input())
input_list = map(int, input().split())
even_list = input_list
even_list_len = input_list_len
count = 0

while True:
    even_list = list(filter(lambda num: num % 2 == 0, even_list))
    even_list_len = len(even_list)
    if input_list_len != even_list_len:
        break
    even_list = map(lambda num: num / 2, even_list)
    count += 1

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

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


dict_odd = {}
dict_even = {}

for i in range(n):
  #リストの奇数番目、０始まりなのであまりは０
  if i %2 == 0:
    dict_odd[a[i]] = dict_odd.get(a[i], 0) + 1
  else:
    dict_even[a[i]] = dict_even.get(a[i], 0) + 1
    
#print(dict_odd, dict_even)    

v_odd_sorted = sorted(dict_odd.values())
v_even_sorted = sorted(dict_even.values())

odd_sorted = sorted(dict_odd.items(), key=lambda x : x[1])
even_sorted = sorted(dict_even.items(), key=lambda x : x[1])

#print(v_odd_sorted, v_even_sorted)    
ans = 0
#数字が一種類しかない場合は、一方を置き換える必要がある
if len(set(a)) == 1:
  for i in range((n//2)-1):
    ans += odd_sorted[i][1]
  #print(sum(v_odd_sorted))
else:
  #偶数列と奇数列について、書き換えた後が同じ数字なら成立しないので、一方の書き換える先を次に多い数字にする
  if odd_sorted[-1][0] == even_sorted[-1][0]:
    if odd_sorted[-1][1] >= even_sorted[-1][1]:
      #偶数列を変更したほうが少ない場合
      ans = sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-2]) + v_even_sorted[-1]
    else:
      #奇数列を変更したほうが少ない場合
      ans = sum(v_even_sorted[:-1]) + sum(v_odd_sorted[:-2]) + v_odd_sorted[-1]
  else:
    ans = sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-1])
  #print(sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-1]))
print(ans)

### FIXED CODE ###

n = int(input())

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


dict_odd = {}
dict_even = {}

for i in range(n):
  #リストの奇数番目、０始まりなのであまりは０
  if i %2 == 0:
    dict_odd[a[i]] = dict_odd.get(a[i], 0) + 1
  else:
    dict_even[a[i]] = dict_even.get(a[i], 0) + 1
    
#print(dict_odd, dict_even)    

v_odd_sorted = sorted(dict_odd.values())
v_even_sorted = sorted(dict_even.values())

odd_sorted = sorted(dict_odd.items(), key=lambda x : x[1])
even_sorted = sorted(dict_even.items(), key=lambda x : x[1])

#print(v_odd_sorted, v_even_sorted)    
ans = 0
#数字が一種類しかない場合は、一方を置き換える必要がある
if len(set(a)) == 1:
  ans = sum(v_odd_sorted)
  #print(sum(v_odd_sorted))
else:
  #偶数列と奇数列について、書き換えた後が同じ数字なら成立しないので、一方の書き換える先を次に多い数字にする
  if odd_sorted[-1][0] == even_sorted[-1][0]:
    comp1 = ans = sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-2]) + v_even_sorted[-1]
    comp2 = ans = sum(v_even_sorted[:-1]) + sum(v_odd_sorted[:-2]) + v_odd_sorted[-1]
    ans = min([comp1, comp2])
    """
    if odd_sorted[-1][1] >= even_sorted[-1][1]:
      #偶数列を変更したほうが少ない場合
      ans = sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-2]) + v_even_sorted[-1]
    else:
      #奇数列を変更したほうが少ない場合
      ans = sum(v_even_sorted[:-1]) + sum(v_odd_sorted[:-2]) + v_odd_sorted[-1]
      """
  else:
    ans = sum(v_odd_sorted[:-1]) + sum(v_even_sorted[:-1])
print(ans)
N,X=map(int,input().split(" "))
L=[int(s) for s in input().split(" ")]

Sum=0
Count=0
while Sum<=X and Count<=N+1:
    Sum+=L[Count]
    Count+=1
    
print(Count)

### FIXED CODE ###

N,X=map(int,input().split(" "))
L=[int(s) for s in input().split(" ")]

bound_List=[0]
for i in range(N):
    bound_List.append(L[i]+bound_List[i])

count=0
for i in bound_List:
    if i<=X:
        count+=1
        
print(count)
from collections import Counter

# print('input >>')

S = input()
S = S[::-1]

mods = [0] * (len(S)+1)
mods[0] = int(S[0]) % 2019

for i in range(len(mods)-1-1):
    mods[i+1] = (int(S[i+1]) * 10 ** (i+1) + mods[i]) % 2019

# print(mods)

# ans = 0

# counter = Counter(mods)

# for n in counter.values():
#     if n > 1:
#         ans += (n * (n-1)) // 2

# print('-----output-----')

print(ans)

### FIXED CODE ###

from collections import Counter

# print('input >>')

S = input()
S = S[::-1] + '0'

mod = 0
mods = [0] * 2019
mods[0] += 1

i_mod = 1

for i in range(len(S)-1):
    # mods[i+1] = (int(S[i+1]) * 10 ** (i+1) + mods[i]) % 2019
    i_mod %= 2019
    mod = (int(S[i]) * i_mod + mod) % 2019
    # print(mod)
    mods[mod]+=1
    i_mod *= 10

# print(mods)

ans = 0

# counter = Counter(mods)

# for n in counter.values():
#     if n > 1:
#         ans += (n * (n-1)) // 2

# print('-----output-----')

for m in mods:
    if m > 1:
        ans += (m * (m-1)) // 2

print(ans)
A,B,C = map(int,input(),split())
print(C,A,B)

### FIXED CODE ###

a, b, c = map(int, input().split())
print(c, a, b)
def change_str(moto_str):
    global Nnew
    global str_list
    global change_list

    for i in range(len(change_list)):
       if change_list[i] == moto_str:
            num = i+Nnew
            if num > 25:
                num = num - 25
    return change_list[num]

Nnew = int(input())
str = input()
str_list = list(str)
change_list = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i in range(len(str_list)):
    str_list[i] = change_str(str_list[i])


print(*str_list,sep='')



### FIXED CODE ###

def change_str(moto_str):
    global Nnew
    global str_list
    global change_list

    for i in range(len(change_list)):
       if change_list[i] == moto_str:
            num = i+Nnew
            if num > 25:
                num = num - 26
    return change_list[num]

Nnew = int(input())
str = input()
str_list = list(str)
change_list = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i in range(len(str_list)):
    str_list[i] = change_str(str_list[i])


print(*str_list,sep='')
N, K = map(int, input().split())
V = list(map(int, input().split()))

for pick in range(min(K+1, N+1)):
    for right in range(pick+1):
        left = pick - right
        pick_list = V[:right] + V[N-left:]

        pick_list = sorted(pick_list)
        tmp_ans = sum(pick_list)
        rem = min(K - pick, len(pick_list))
        for i in range(rem):
            if pick_list[i] < 0:
                tmp_ans -= pick_list[i]
            else:
                break
        ans = max(tmp_ans, ans)
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for pick in range(min(K+1, N+1)):
    for right in range(pick+1):
        left = pick-right
        pick_list = V[:right]+V[N-left:]

        pick_list = sorted(pick_list)
        tmp_ans = sum(pick_list)
        rem = min(K-pick, len(pick_list))
        for i in range(rem):
            if pick_list[i] < 0:
                tmp_ans -= pick_list[i]
            else:
                break
        ans = max(tmp_ans, ans)
print(ans)
def gcd(a, b):
  if a == 0:
    return b
  if b == 0:
    return a
  if a > b:
    return gcd(a%b, b)
  return gcd(a, b%a)

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

### FIXED CODE ###

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

a, b = input().split()
a, b = int(a), int(b)
print(a * b // gcd(a, b))
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) == 0:
        print(min(candidates))
    else:
        print(n//2)


### FIXED CODE ###

from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) != 0:
        print(min(candidates))
    else:
        print(n//2)
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
N,A,B,K=map(int,input().split())
p=998244353
fracmod=[1]*(N+1)
fracmodinv=[1]*(N+1)
ans=0
i=0
j=0
for i in range(1,N+1):
    fracmod[i]=(fracmod[i-1]*i)%p
#print(fracmod[:6])
for i in range(N+1):
    fracmodinv[i]=modinv(fracmod[i],p)
for i in range(N+1):
    forb=K-i*A      #bに割く得点
    if forb%B==0:
        j=forb//B
        #print(i,j)
        ans=(ans+((((fracmod[N]*fracmodinv[N-i]*fracmodinv[i])%p)*(fracmod[N]*fracmodinv[N-j]*fracmodinv[j]))%p))%p
print(ans)



### FIXED CODE ###

def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
N,A,B,K=map(int,input().split())
p=998244353
fracmod=[1]*(N+1)
fracmodinv=[1]*(N+1)
ans=0
i=0
j=0
for i in range(1,N+1):
    fracmod[i]=(fracmod[i-1]*i)%p
#print(fracmod[:6])
for i in range(N+1):
    fracmodinv[i]=modinv(fracmod[i],p)
for i in range(N+1):
    forb=K-i*A      #bに割く得点
    if (forb%B==0)and(0<=(forb//B)<=N):
        j=forb//B
        #print(i,j)
        ans=(ans+((((fracmod[N]*fracmodinv[N-i]*fracmodinv[i])%p)*(fracmod[N]*fracmodinv[N-j]*fracmodinv[j]))%p))%p
print(ans)
# -*- coding: utf-8 -*-
def  inpl(): return list(map(int, input().split()))
N, M = inpl()
A = sorted(inpl())
cost = [1e9, 2, 5, 5, 4, 5, 6, 3, 7, 6]
mincost = min([cost[a] for a in A])
maxcost = max([cost[a] for a in A])

DP = [0]*N
for a in A:
    if N - cost[a] >= 0:
        DP[N-cost[a]] = a

ans = DP[0]
for j in range(N//2 + 1):
    DP2 = [0]*N
    for i in range(max(0, N-maxcost*(j+1)), N-mincost*j):
        v = DP[i]
        if v == 0:
            continue
        for a in A:
            nk = i - cost[a]
            if nk >= 0:
                DP2[nk] = max(DP2[nk], 10*v + a)
    ans = max(ans, DP2[0])
    DP = DP2
    if sum(DP) == 0:
        break

print(ans)


### FIXED CODE ###

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

A, B = inpl()

if B%A == 0:
    print(A+B)
else:
    print(B-A)
n=input()
n=int(n)
m=input()
m=int(m)
d=input()
d=int(d)
if(d!=0):
    d=2
if(d==0):
    d=1
print(d*(m-1)*(n-1)/(n*n))


### FIXED CODE ###

n,m,d = map(int,input().split())
if(d==0):
    ans=(m-1)/n
elif(n/d<2):
    ans=2*(m-1)*(n-d)/n
else:
    ans=2*(m-1)*(n-d)/(n*n)
print(ans)
int A = int(input())
int B = int(input())

if A = 1:
    if B = 2:
        print(3)
    else if B = 3:
        print(2)

if A = 2:
    if B = 1:
        print(3)
    if B = 3:
        print(1)

if A = 3:
    if B = 1:
        print(2)
    if B = 2:
        print(1)

### FIXED CODE ###

A = int(input())
B = int(input())

if A == 1:
    if B == 2:
        print(3)
    if B == 3:
        print(2)

if A == 2:
    if B == 1:
        print(3)
    if B == 3:
        print(1)

if A == 3:
    if B == 1:
        print(2)
    if B == 2:
        print(1)
L, R, d = input()
count = 0
for i in range(int(L)+1, int(R)+1):
  if i % int(d) == 0:
    count = count + 1
print(count)

### FIXED CODE ###

L, R, d = input().split()
count = 0
for i in range(int(L), int(R)+1):
  if i % int(d) == 0:
    count = count + 1
print(count)
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    num = int(stdin.readline())
 
    y = []
    for _ in xrange(num):
        it = iter(int(s) for s in stdin.readline().split()[1:])
        y.append([(next(it), next(it)) for _ in xrange(next(it))])
 
    weight = [maxint] * num
    weight[0] = 0
    t = set(xrange(1, num))
    index = 0
 
    while t:
        for v, cost in y[index]:
            if v not in t:
                continue
            weight[v] = min(weight[v], cost + weight[index])

        index = min(t, key=lambda i: weight[i])
        t.remove(index)
 
    for i, d in enumerate(weight):
        print(i, d)
 
 
main()

### FIXED CODE ###

from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    x = int(stdin.readline())
 
    y = []
    for _ in xrange(x):
        y.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, x+1))
    index = g.pop()
    h = {index}
    leng = 0
 
    while g:
        minimum = maxint

        for j in h:
            mj = y[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]

        h.add(index)
        g.remove(index)
        leng += minimum
 
    print(leng)
 
 
main()
わからん

### FIXED CODE ###

#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    N,M = map(int,input().split())
    count_list = [0]*(N+1)
    for _ in range(M):
        a,b = map(int,input().split())
        count_list[a] += 1
        count_list[b] += 1
    for c in count_list:
        if c% 2 == 1:
            print('NO')
            return
    print('YES')
    return

    

if __name__ == '__main__':
    main()
a = int(input())
b = int(input())

print(a*b -(a+b-1))


### FIXED CODE ###

a,b = map(int,input().split())
print(a*b -(a+b-1))
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

tmp=[0,abs(a[0])]
for i in range(n):
    if tmp[1]<abs(a[i]):
        tmp[0]=i
        tmp[1]=abs(a[i])
# print(tmp)

lst=[]

for i in range(n):
    a[i]+=tmp[1]
    lst.append([tmp[0]+1,i+1])

if a[tmp[0]]<0:
    for i in range(n-1):
        a[-2-i]-=a[-1-i]
        lst.append([n-i,n-i-1])
else:
    for i in range(n-1):
        a[i+1]+=a[i]
        lst.append([1+i,2+i])
# print(a)
# print(lst)
print(len(lst))
for i in lst:
    print(*i)

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

tmp=[0,abs(a[0])]
for i in range(n):
    if tmp[1]<abs(a[i]):
        tmp[0]=i
        tmp[1]=abs(a[i])
# print(tmp)

lst=[]

for i in range(n):
    a[i]+=a[tmp[0]]
    lst.append([tmp[0]+1,i+1])

# print(a[tmp[0]])
if a[tmp[0]]<0:
    for i in range(n-1):
        a[-2-i]+=a[-1-i]
        lst.append([n-i,n-i-1])
else:
    for i in range(n-1):
        a[i+1]+=a[i]
        lst.append([1+i,2+i])
# print(a)
# print(lst)
print(len(lst))
for i in lst:
    print(*i)
n=int(input)
sum=0
cnt=n

while cnt>0:
  sum+=cnt%10
  cnt/=10
  
if n%sum==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
sum=0
cnt=n

while cnt>0:
  sum+=cnt%10
  cnt//=10
  
if n%sum==0:
  print("Yes")
else:
  print("No")