Harryxun/stf_run huggingface dataset:
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
V_c =V.copy()
C = [int(_) for _ in stdin.readline().rstrip().split()]
C_c =C.copy()
for i in range(N):
    if V[i]<C[i]:
        V_c.pop(i)
        C_c.pop(i)
print(sum(V_c)-sum(C_c))

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
C = [int(_) for _ in stdin.readline().rstrip().split()]
ans=0
for i in range(N):
    if V[i]-C[i] > 0:
        ans+=V[i]-C[i]
print(ans)
N, H = [int(i) for i in input().split()]
ken_a = 0
ken_b = []
for _ in range(N):
    a,b = input().split()
    if a >= H or b >= H:
        print(1)
        quit()
    if ken_a < int(a):
        ken_a = int(a)
    ken_b.append(int(b))
res = 0
for b_ in ken_b:
    if b_ > ken_a:
        H = H - b_
        res += 1

res = res + (H//ken_a)
if H%ken_a != 0:
    res += 1
print(res)

### FIXED CODE ###

N, H = [int(i) for i in input().split()]
ken_a = 0
ken_b = []
for _ in range(N):
    a,b = input().split()
    if int(a) >= H or int(b) >= H:
        print(1)
        quit()
    if ken_a < int(a):
        ken_a = int(a)
    ken_b.append(int(b))
res = 0
for b_ in sorted(ken_b,reverse=True):
    if b_ > ken_a:
        H = H - b_
        res += 1
        if H <= 0:
            print(res)
            quit()

res = res + (H//ken_a)
if H%ken_a != 0:
    res += 1
print(res)
s=input()
 
if s=='SSS':
  print(0)
elif s=='SRS' or s=='RSS' or s=='SSR':
  print(1)
elif s=='RRR':
  print(3)
else:
  print(2)
s=input()

if s=='SSS':
  print(0)
elif s=='SRR' or s=='RRS':
  print(2)
elif s=='RRR':
  print(3)
else:
  print(1)


### FIXED CODE ###

s=input()
 
if s=='SSS':
  print(0)
elif s=='SRR' or s=='RRS':
  print(2)
elif s=='RRR':
  print(3)
else:
  print(1)
n, k = map(int,input().split())
a = list(map(int, input().split()))
t = [1]
d = 1
for i in range(k):
    t.append(a[t[i]-1])

    if len(t) != len(set(t)):

        l = [m for m, x in enumerate(t) if x == t[i+1]]
        b = [t[i+1]]
        break

d = l[1] - l[0]
if d != 0:
    r = (k - (l[0]+1)) % d
else:
    r = (k - (l[0]+1))

for i in range(r+1):
    b.append(a[b[i]-1])

print(b[r+1])


### FIXED CODE ###

n, k = map(int,input().split())
a = list(map(int, input().split()))
t = [1]
x = [0]*n
x[0] = 1
y = 1
z = 0
d = 0
flag = False
for i in range(k):
    t.append(a[t[i]-1])
    if x[a[t[i]-1]-1] != 0:
        y = x[a[t[i]-1]-1]
        z = i+2
        b = [a[t[i]-1]]
        break
    else:
        x[a[t[i]-1]-1] += i+2
        z = i+2
        b = [a[t[i]-1]]
    if i == k - 1:
        flag = True

if flag:
    print(a[t[k-1]-1])
    exit()

d = z-y


if d != 0:
    r = (k - y) % d
else:
    r = k - y

for i in range(r+1):
    b.append(a[b[i]-1])

print(b[r+1])
a = int(input())
b = int(input())

plus = a+b
minus = a-b
multipiled_by = a*b
ans = max([plus, minus, multipiled_by])
print(ans)

### FIXED CODE ###

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

plus = a+b
minus = a-b
multipiled_by = a*b
ans = max([plus, minus, multipiled_by])
print(ans)
import sys
sys.setrecursionlimit(100000)


def rootedTree(node,parent,root,point):
    B.append([node,parent,root,point])
    for i in root:
        rootedTree(i,node,tree[i],point+C[i])


n,q=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n-1)]
B=[]
C=[0 for j in range(n+1)]
for i in range(q):
    add,point=map(int,input().split())
    C[add] +=point

tree=[[] for i in range(n+1)]
for i,j in A:tree[i] +=[j]

rootedTree(1,-1,tree[1],C[1])
ans=[0]*n
for i in B:
    ans[i[0]-1]=i[3]
print(*ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

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

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

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

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)
a, b, c = map(int, input().split())
ans = (a[0]+b[0]+c[0]).upper()
print(ans)

### FIXED CODE ###

a, b, c = input().split()
ans = (a[0]+b[0]+c[0]).upper()
print(ans)
n = input()
maxv = -1 * 10**9
minv = input()

for j in range(1:n-1):
  v = input()
  maxv = max(maxv, v-minv)
  minv = min(v, minv)

print maxv

### FIXED CODE ###

n = input()
minv = input()
maxv = -1 * 10**9

for j in range(n-1):
  v = input()
  if maxv < v - minv:
    maxv = v - minv
  if minv > v:
    minv = v

print maxv
import queue

H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
moveRow = [0, 1, -1, 0]
moveCol = [1, 0, 0, -1]
ilst = []
index = 1
for i in range(H):
    for j in range(W):
        if c[i][j] == '#':
            c[i][j] = index
            index += 1
            ilst.append([i, j])

for i in range(K - 1):
    if ilst[i][0] == ilst[i + 1][0]:
        cindex = 0
        if c[ilst[i][0]][0] != '.':
            cindex = ilst[i][1]
        for j in range(cindex, ilst[i + 1][1]):
            c[ilst[i][0]][j] = i + 1
        for j in range(ilst[i + 1][1], W):
            c[ilst[i + 1][0]][j] = i + 2
    else:
        if c[ilst[i][0]][0] == '.':
            for j in range(W):
                c[ilst[i][0]][j] = i + 1
for i in range(H - 1):
    for j in range(W):
        if c[i][j] == '.':
            c[i][j] = c[i + 1][j]

for i in range(W):
    if c[-1][i] == '.':
        c[-1][i] = c[-2][i]


for i in range(H):
    for j in range(W):
        if j != W - 1:
            print(c[i][j], end = ' ')
        else:
            print(c[i][j])

### FIXED CODE ###

H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

index = 0
for i in range(H):
    cnt = 0
    for j in range(W):
        if c[i][j] == '#':
            index += 1
            cnt = index
            c[i][j] = cnt
        if c[i][j] == '.' and cnt != 0:
            c[i][j] = cnt

for i in range(H):
    for j in reversed(range(W - 1)):
        if c[i][j] == '.':
            c[i][j] = c[i][j + 1]

for i in range(H - 1):
    for j in range(W):
        if c[i][j] != '.' and c[i + 1][j] == '.':
            c[i + 1][j] = c[i][j]

for i in reversed(range(1, H)):
    for j in range(W):
        if c[i][j] != '.' and c[i - 1][j] == '.':
            c[i - 1][j] = c[i][j]


for i in range(H):
    for j in range(W):
        if j != W - 1:
            print(c[i][j], end=' ')
        else:
            print(c[i][j])
W:int
S:int

if W >= S:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

S, W = [int(x) for x in input().split()]
 
if W >= S:
  print('unsafe')
else:
  print('safe')
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

d = []
for i in range(n-1):
  d.append(x[i+1]-x[i])

f = 0
for i in range(n-1):
  if d[i]*a <= b:
    f += d*a
  else:
    f += b
    
print(f)

### FIXED CODE ###

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

d = []
for i in range(n-1):
  d.append(x[i+1]-x[i])

f = 0
for i in range(n-1):
  if d[i]*a <= b:
    f += d[i]*a
  else:
    f += b
    
print(f)
def datasets(n):
    for i in range(n):
        type, rank = input().split()
        yield type, rank
db = {'S' : [False] * 13, 'H' : [False] * 13, 'C' : [False] * 13, 'D' : [False] * 13 }
n = int(input())
for type, rank in datasets(n):
    db[type][int(rank)-1] = True
print(db.keys())
for type in ['S', 'H', 'C', 'D']:
    for num, card in enumerate(db[type]):
        if card == False:
            print(type, (num+1))

### FIXED CODE ###

def datasets(n):
    for i in range(n):
        type, rank = raw_input().split()
        yield type, rank
db = {'S' : [False] * 13,
      'H' : [False] * 13,
      'C' : [False] * 13,
      'D' : [False] * 13 }

n = int(raw_input())

for type, rank in datasets(n):
    db[type][int(rank)-1] = True

for type in ['S', 'H', 'C', 'D']:
    for num, card in enumerate(db[type]):
        if card == False:
            print type, (num+1)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = map(int, input().split())
print(n-k+1)
for i in range(2, k+1):
    a = cmb(k-1, i-1)
    b = cmb(n - k + 1, i)
    print(a*b%(10**9+7))

### FIXED CODE ###

from scipy.misc import comb

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k + 1):
    a = comb(k-1, i-1, exact=True) % mod
    b = comb(n - k + 1, i, exact=True) % mod
    print((a*b)%mod)
s = input()
t = input()
flag = False
for i in range(len(i)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")


### FIXED CODE ###

s = input()
t = input()
flag = False
for i in range(len(s)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")
K=int(input())
N=int(K**0.5)+2
print(N)
print(*([N*K]+[0]*(N-1)))

### FIXED CODE ###

# K回の操作
# N = 50とする
# 0,1,2,3,4...N - 1の数列に対して左からi番目にNを足し、それ以外から1を引く操作
# K // N回の操作をすると、1回あたり全項目に1が足される。

import sys
readline = sys.stdin.readline

K = int(readline())
N = 50

A = [i for i in range(N)]
A = list(map(lambda x:x + (K // N),A))
rest = K % N
for i in range(rest):
  A[i] += N
  for j in range(N):
    if i != j:
      A[j] -= 1

print(N)
print(*A)
input_x = input()
print(x ** 3)

### FIXED CODE ###

x = input()
print(x ** 3)
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int,input().split()))
q=[0]*10


ans=0
for k in range(2*11):
    for i in range(n+1):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)



### FIXED CODE ###

n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int, input().split()))
q=[0]*11


ans=0
while(True):
    for i in range(n):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)
s=input()
if len(set(s))=2 and count(s[0])=2:
    print('Yes')
else:
    print('No')
    


### FIXED CODE ###

s=input()
if len(set(s))==2 and s.count(s[0])==2:
    print('Yes')
else:
    print('No')
n = int(input())
ans = 'AB'
if n <= 999:
  ans += 'C'
else:
  ans += 'D'
  n -= 999
print(ans+'{03}'.format(n))

### FIXED CODE ###

n = int(input())
ans = 'AB'
if n <= 999:
  ans += 'C'
else:
  ans += 'D'
print(ans)
str = input()
max = 0
count = 0
for chr in str:
  if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
    count += 1
   	if count > max:
      max = count
  else:
  	count = 0
print({}.format(max))


### FIXED CODE ###

str = input()
max = 0
count = 0
for chr in str:
    if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
        count += 1
        if count > max:
            max = count
    else:
        count = 0
print('{}'.format(max))
def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = (input())
res = (input())
while n > 1:
	x = (input())
	res = (res * x) // gcd(res, x);
	n -= 1
print(res)

### FIXED CODE ###

import fractions
import functools

def lcm(a,b):
	return a*b//fractions.gcd(a,b)

n=int(input())
t=[]
for i in range(n):
	t.append(int(input()))
ans=functools.reduce(lcm,t)
print(ans)
while True:
	x,y = sorted(map(raw_input().split()))
	if x==y==0:
		break
	print x,y

### FIXED CODE ###

while True:
	x,y = sorted(map(int,raw_input().split()))
	if x==y==0:
		break
	print x,y
A=input()
B=input()
C=input()
X=input()
total = 0
cnt = 0
 
for a in A+1:
  for b in B+1:
    for c in C+1:
      total = 500*a+100*b+50*c
      if total=X:
        cnt +=1
        
        
print(cnt)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
X=int(input())
total = 0
cnt = 0
 
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      total = 500*a+100*b+50*c
      if total==X:
        cnt +=1
             
print(cnt)
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.num = [1 for i in range(n)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.parent[x] = y
            self.num[y] += self.num[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def count(self, x):
        return self.num[self.root(x)]

N, M = map(int, input().split())
un = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    un.unite(a, b)
ans = 0
for i in range(N):
    ans = max(ans, un.count(i))
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.num = [1 for i in range(n)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.parent[x] = y
            self.num[y] += self.num[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def count(self, x):
        return self.num[self.root(x)]

N, M = map(int, input().split())
un = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    un.unite(a, b)
ans = 0
for i in range(N):
    ans = max(ans, un.count(i))
print(ans)
A,B=input().split
if A<B:
  print("<")
elif A>B:
  print(">")
else:
  print("=")


### FIXED CODE ###

A,B=input().split()
if A < B:
  print("<")
elif A > B:
  print(">")
else:
  print("=")
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

primeTable = sieve_of_erastosthenes(13*(10**5))

while True:
    k = int(input())
    if k == 0:
        break
    if primeTable[k]:
        print(0)
    else:
        i = 0
        while i < k or primeTable[i] == False:
            if primeTable[i]:
                prevPrime = i
            i+= 1
        print(i-prevPrime)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

primeTable = sieve_of_erastosthenes(13*(10**5))

while True:
    k = int(input())
    if k == 0:
        break
    if primeTable[k]:
        print(0)
    else:
        i = k
        while primeTable[i] is False: i += 1
        j = i-1
        while primeTable[j] is False: j -= 1
        print(i-j)
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
N = True
while N == True:
N = False
if S == 'SSS':
	print(0)
elif S == 'SSR':
	print(1)
elif S == 'SRR':
	print(2)
elif S == 'SRS':
	print(1)
elif S == 'RSS':
	print(1)
elif S == 'RRS':
	print(2)
elif S == 'RRR':
	print(3)
elif S == 'RSR':
	print(1)
else:
	N = True

### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
#include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string com;
    int key;
    list<ll> lst;
    list<ll>::iterator it,i=lst.end();
    while(n--){
        cin>>com;
        if(com=="insert"){
            cin>>key;
            lst.push_front(key);
        }
        else if(com=="delete"){
            cin>>key;
            for(it=lst.begin();it!=i;it++){
                if(*it==key){
                    lst.erase(it);
                    break;
                }
            }
        }
        else if(com=="deleteFirst") lst.pop_front();
        else                        lst.pop_back();
         
    }
    i--;
    for(it=lst.begin();it!=i;it++)  cout<<*it<<" ";
    cout<<*i<<"\n";
    return 0;
}





### FIXED CODE ###


import sys
     
A=[]
fp =0
bp =0
 
n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1
 
for e in A[bp:fp+1][::-1]:
    print int(e),
import math
N = int(input())
D = [int(x) for x in input().split()]

if D[0] != 0:
    print(0)
    exit()

num = [0] * 10000

for d in D:
    num[d] += 1

if num[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(1, max(num)):
    ans *= int(math.pow(num[i], num[i+1])) % 998244353
    if ans == 0:
        print(0)
        exit()
print(ans)


### FIXED CODE ###

import math
N = int(input())
D = [int(x) for x in input().split()]

num = [0] * 100000

maxd = 0
for d in D:
    num[d] += 1
    maxd = max(d, maxd)

if D[0] != 0 or num[0] != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, maxd):
        for _ in range(num[i+1]):
            ans *= num[i]%998244353
        ans %= 998244353
        if ans == 0:
            break
print(ans%998244353)
N=int(input())
A=[int(x) for x in input().split()]
B=[x for x in A if x<0]

if len(B)%2==0:
  minus=0
else:
  minus=max(B)
  
print(sum(A)+B)

### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
B=[x for x in A if x<0]
absA=[abs(x) for x in A]
if len(B)%2==0:
  minus=0
else:
  minus=min(absA)
  
print(sum(absA)-minus*2)
ans = input()
n = int(input())
for i in range(n):
    query = input()
    if query == "1":
        ans = ''.join(list(ans).reverse())
    else:
        _,option,str = query.split()
        if option == "1":
            ans = str + ans
        else:
            ans += str
print(ans)

### FIXED CODE ###

from collections import deque

def main():
    ans = deque(input())
    n = int(input())
    vec = 1
    for i in range(n):
        q = input()
        if q == "1":
            vec *= -1
        else:
            _,o,s = q.split()
            if ((o == "1") and (vec == 1)) or ((o == "2") and (vec == -1)):
                ans.appendleft(s)
            else:
                ans.append(s)
    if vec == -1:
        ans.reverse()
    ans = ''.join(ans)
    print(ans)

if __name__ == '__main__':
    main()
cou = int(input())
bars = input().split()
two = [0, 0]
i = 0
ca = len(bars)
while i < ca:
    if bars[i] in two:
        pass
    else:
        now = bars[i]
        if bars.count(now) > 3:
            two.extend(now)
            two.extend(now)
        elif bars.count(now) > 1:
            two.extend(now)
        else:
            pass
    i += 1
two.sort(key=int)
ans = int(two[-1]) * int(two[-2])
print(ans)


### FIXED CODE ###

a = input().split()
if (max(int(a[0]), int(a[1])) - min(int(a[0]), int(a[1]))) > (max(int(a[0]), int(a[2])) - min(int(a[0]), int(a[2]))):
    print("B")
elif (max(int(a[0]), int(a[1])) - min(int(a[0]), int(a[1]))) < (max(int(a[0]), int(a[2])) - min(int(a[0]), int(a[2]))):
    print("A")
N = int(input())
print(N*(N-1)//2))

### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
s = input()
s[3] = 8
print(s)

### FIXED CODE ###

s = input()
s = s.replace('2017', '2018')
print(s)
k, x = map(int, input().split())
print(' '.join(list(range(x-k+1, x+k))))

### FIXED CODE ###

k, x = map(int, input().split())
print(' '.join(map(str, list(range(x-k+1, x+k)))))
a = (1,3,5,7,8,10,12)
b = (4,6,9,11)
c = (2)
abc = [a,b,c]
x,y = map(int,input().split())
for i, checker in enumerate(abc):
    if x in checker:
        checker2 = checker
if y in checker2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = (1,3,5,7,8,10,12)
b = (4,6,9,11)
c = set([2])
abc = [a,b,c]
x,y = map(int,input().split())
for i, checker in enumerate(abc):
    if x in checker:
        checker2 = checker
if y in checker2:
    print("Yes")
else:
    print("No")
while True:
  [x, y] = map(int(input().split()))
  if x == y == 0:
    break
  print(min(x, y) max(x, y))

### FIXED CODE ###

while True:
  [x, y] = map(int, input().split())
  if x == y == 0:
    break
  print(min(x, y), max(x, y))
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math

N,M = map(int,input().split())
S = input()
N = len(S)-1
if "1"*M in S:
  print(-1)
  exit()  

max_n = [0 for i in range(N+1)]

for i in range(1,N+1):
  s = S[max(0,i-M):i]
  l = len(s)
  if l == 0:
    continue
  mask = (1<<l) -1
  b = (~int(s, 2)) & mask
  max_n[i] = math.floor(math.log(b)/math.log(2))+1
  
now = N
deme = []
while now != 0:
  x = max_n[now]
  now = now-x
  deme.append(x)
print(*deme[::-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline

import math
import bisect

N,M = map(int,input().split())
S = input()

if "1"*M in S:
  print(-1)
  exit()  

S = [int(S[i]) for i in range(N+1)]

L = [(1<<i) -1 for i in range(1,M+1)]

max_n = [0]
mask = (1<<M) -1
b = 0
for i in range(N):
  b = ((b<<1) + (1- S[i])) & mask
  max_n.append(bisect.bisect_left(L,b)+1)

now = N
deme = []
while now != 0:
  x = max_n[now]
  now -= x
  deme.append(x)
print(*deme[::-1])
n = int(input())
G = [[-1] * n] * n
d = [0] * n
 
for i in range(n):
    v = map(int, input().split())
    for j in range(v[1]):
        G[v[0]][v[2+2*j]] = int(v[3+2*j])
 
flag = [0] * n
tn = [1]
r = 0
while True:
    for i in range(n):
        if flag[i] == 0 and i in tn:
            flag[i] = 1
            d[i] = r
            for j in range(n):
                if G[i][j] != -1 and flag[j] == 0:
                    tn.append(j)
    if len(tn) == n:
        break
    r += 1
 
for i in range(1, n+1):
    print(str(i) + " " + str(d[i]))

### FIXED CODE ###

n = int(input())
G = [[-1 for i in range(n)] for j in range(n)]
d = [999999 for i in range(n)]
  
for i in range(n):
    v = input().split()
    for j in range(int(v[1])):
        G[int(v[0])][int(v[2+2*j])] = int(v[3+2*j])

flag = [0] * n
tn = [0]
d[0] = 0
for k in range(n):
    for i in range(n):
        if i in tn:
            for j in range(n):
                if G[i][j] != -1:
                    if d[j] > d[i] + G[i][j]:
                        d[j] = d[i] + G[i][j]
                    if j not in tn:
                        tn.append(j)
  
for i in range(n):
    print(str(i) + " " + str(d[i]))