Harryxun/stf_run huggingface dataset:
[n,x]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
sum=int(0)
count = int(1)

while sum+l[count-1]<=x:
    sum=sum+l[count-1]
    count=count+1
    print(sum)
    print(count)


print(count)


### FIXED CODE ###

[n,x]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
sum=int(0)
count = int(0)

while count<n and sum+l[count]<=x:
    sum=sum+l[count]
    count=count+1

print(count+1)
input()

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

s = 0

for i in len(a):
    s = s + i

print(min(a), max(a), s)


### FIXED CODE ###

input()

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

s = 0

for i in a:
    s = s + i

print(min(a), max(a), s)
while 1:
    dd = raw_input()
    d = int(dd)
    i = 1
    ans = 0
    while i * d < 600:
        ans += (i * d) * (i * d) * d
        i += 1
    print ans

### FIXED CODE ###

while 1:
    try:
        dd = raw_input()
        d = int(dd)
        i = 1
        ans = 0
        while i * d < 600:
            ans += (i * d) * (i * d) * d
            i += 1
        print ans
    except:
        break
inputs = input().split(" ")

print(math.ceil(inputs[2]/(inputs[0]+(inputs[1]/7))))



### FIXED CODE ###

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

days = int(C/(A+(B/7)))

while 1:
    coins = A* days + B * (days//7)

    if ( coins >= C):
        break
    else:
        days += 1

print(days)
n, k = map(int, input().split())
s = input()
c = s[k]
s = s[:k] + chr(ord(c) - ord('A') + ord('a')) + s[k + 1:]
print(s)

### FIXED CODE ###

n, k = map(int, input().split())
k -= 1
s = input()
c = s[k]
s = s[:k] + chr(ord(c) - ord('A') + ord('a')) + s[k + 1:]
print(s)
import math
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = int (math.log10(x + y) + 1)
		print(a)

### FIXED CODE ###

import math
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = int (math.log10(x + y) + 1)
		print(a)
a=int(input())
c=list(input())
d=''
b=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
for i in range(len(c)):
  if b.index(c[i])+a<=23+a:
    
    c[i]=b[b.index(c[i])+a]
  else:
    c[i]=b[27-(b.index(c[i])+a)]
for i in range(len(c)):
  d+=c[i]
print(d)


### FIXED CODE ###

N=int(input())
S=list(input())
a=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
res=''

for s in S:
  code=a.index(s)+N
  if code>a.index('Z'):
    code-=26
  res+=a[code]
print(res)
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

### FIXED CODE ###

N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)
import math

[N, M] = list(map(int, input().split()))
num = math.ceil(M / N)
if N ==1:
    print(M)
for i in range(num+1)[::-1]:
    if M % i == 0:
        print(i)
        break

### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
print(t)
print(l)
print(sum(t)-t[l[0][0]-1]+l[0][1])
print(sum(t)-t[l[1][0]-1]+l[1][1])
print(sum(t)-t[l[2][0]-1]+l[2][1])

### FIXED CODE ###

n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int, input().split())) for i in range(m)]
for j in range(m):
    print(sum(t)-t[l[j][0]-1]+l[j][1])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s, t = read().decode().split()
a, b = map(int, read().split())
u = read().decode()

if u == s:
    a -= 1
else:
    b -= 1

print(a, b)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

s, t = readline().decode('utf-8').split()
a, b = map(int, readline().split())
u = read().decode('utf-8').rstrip()

if u == s:
    a -= 1
else:
    b -= 1

print(a, b)
import math
 
N = int(input())
 
count = 0
for i in range(1, N+1):
  if math.floor(math.log10(i)) % 2 == 0:
    count += 1
print(count)

### FIXED CODE ###

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

if A - B <= C:
  print(C - A + B)
else:
  print(0)
using namespace std;
 
int main() {
 int s;
 
 cin >> s;
 
 int h = s / 3600;
 s -= h * 3600;
 int m = s / 60;
 s -= m * 60;
 
 cout << h << ":" << m << ":" << s << endl;
 
 return 0;
}

### FIXED CODE ###

s = int(input())
h = s / 3600
i = s % 3600
m = i / 60
j = i % 60
 
print(str(int(h)) + ":" + str(int(m)) + ":" + str(int(j)))
X = int(input())

bekijosu=[]

for i in range(2, 1001):
    for j in range(2,10):
        if i ** j <= 1000:
            bekijosu.append(i ** j)

print(max([n for n in bekijosu if n <= X]))

### FIXED CODE ###

X = int(input())

bekijosu=[1]

for i in range(2, 1001):
    for j in range(2,10):
        if i ** j <= 1000:
            bekijosu.append(i ** j)

print(max([n for n in bekijosu if n <= X]))
from collections import Counter as c

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

f=lambda n,x:sum(1 for i in p(d.values(),n) if all(map(lambda x,y:x>=y,i,x)))
print(f(3,(2,4,4))//2+f(2,(2,24))+f(2,(4,14))+f(1,(74,)))

### FIXED CODE ###

from collections import Counter as c
from itertools import permutations as p

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

v=sum(1 for i,j,k in p(d.values(),3) if i>=2 and j>=4 and k>=4)//2
v+=sum(1 for i,j in p(d.values(),2) if i>=2 and j>=24)
v+=sum(1 for i,j in p(d.values(),2) if i>=4 and j>=14)
v+=sum(1 for i in d.values() if i>=74)

print(v)
s = input()
print(s.translate(str.maketrans({"A":"T","T":"A","C":"G","G":"C"})

### FIXED CODE ###

s = input()
print(s.translate(str.maketrans({"A":"T","T":"A","C":"G","G":"C"})))
N, K = map(int, input().split())
D = list(map(int, input().split()))
for
ans = ""
for n in str(N):
  a = 0
  while True:
    if int(n) in D:
      n = int(n) + 1
      a = int(n)+1
    else:
      a = int(n)
      ans += str(a)
      break

print(ans)



### FIXED CODE ###

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

i = N
while True:
  flg = True
  for j in str(i):
    if int(j) in D:
      flg = False
      break

  if flg == True:
    print(i)
    exit()

  i += 1
import math
from functools import reduce
N=int(input())
A=set(map(int,input().split()))
l=[]
for i in A:
    l.append(reduce(math.gcd,A-{i},0))
print(max(l))

### FIXED CODE ###

from  fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N-1):
    R.append(gcd(R[-1], A[-1-i]))
    L.append(gcd(L[-1], A[i]))
print(max(gcd(l,r)for l,r in zip(L,R[::-1])))
import math
import numpy as np

N = int(input())
A = list(map(int,input().split()))
ans = 1
A_log = list(map(math.log10,A))

if sum(A_log) >= 18:
    print(-1)
else:
    for i in A:
        ans *= i
    print(ans)

### FIXED CODE ###

import math
import numpy as np

N = int(input())
A = list(map(int,input().split()))
ans = 1
A_log = A
try:
    A_log = list(map(math.log10,A))
except ValueError:
    print(0)
else:
    if sum(A_log) > 18:
        print(-1)
    else:
        for i in A:
            ans *= i
        if ans <= 1e18:
            print(ans)
        else:
            print(-1)
s=input()
s1="ATGC"
l=[]
count=0
for i in range(len(s)):
  if s[i] not in s1:
    l.append(count)
    count=0
  else:
    count=count+1
print(max(l))

### FIXED CODE ###

s=input()
s1="ATGC"
l=[]
count=0
for i in range(len(s)):
  if s[i] not in s1:
    l.append(count)
    count=0
  else:
    count=count+1
  if i==len(s)-1 and s[i] in s1:
    l.append(count)
    
print(max(l))
import math

# 最小公倍数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)



### FIXED CODE ###

import fractions

# 最小公倍数
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


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

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)
N=input().split()
if N[0]==7 or N[1]==7 or N[2]==7:
    print(Yes)
else:
    print(No)

### FIXED CODE ###

N=input()
if N[0]=='7' or N[1]=='7' or N[2]=='7':
    print('Yes')
else:
    print('No')
N, X = map(int, input().split())

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  "[-1]は末尾の要素を取得。layer_sizeで、合計"
  layer_size.append(layer_size[-1]*2+3)

  "[-1]は末尾の要素を取得。P_cntはパティの枚数
  P_cnt.append(P_cnt[-1]*2+1)

print(layer_size)
print(P_cnt)

def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)

### FIXED CODE ###

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

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  #[-1]は末尾の要素を取得。layer_sizeで、合計
  layer_size.append(layer_size[-1]*2+3)

  #[-1]は末尾の要素を取得。P_cntはパティの枚数
  P_cnt.append(P_cnt[-1]*2+1)


def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)
a,b,c=map(int(input().split())
A=[a,b,c]
sorted(A)
print(abs(A[0]-A[1])+abs(A[1]-A[2]))

          

### FIXED CODE ###

a,b,c=map(int,input().split())
A=[a,b,c]
A=sorted(A)
print(abs(A[0]-A[1])+abs(A[1]-A[2]))
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

time = 0
cont_a = 0
cont_b = 0

while time <= k:
    if a[cont_a] > b[cont_b]:
        if a[cont_a] < k:
            time += a[cont_a]
            cont_a += 1
        else:
            break
    else:
        if b[cont_b] < k:
            time += b[cont_b]
            cont_b += 1
        else:
            break
print(cont_a + cont_b)

### FIXED CODE ###

n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0],[0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])


ans, j = 0, m

for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))


### FIXED CODE ###

import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))
N,K = map(int,input().split())
s = 0
a = 0
b = N

for i in range(1,K):
    s += b - a + 1
    a += i
    b += N - i

u = 0
a = 0
b = N
for i in range(1,N+2):
    u += b - a + 1
    a += i
    b += N - i
print(u-s)

### FIXED CODE ###

import math
R = int(input())
p = math.pi
print(2*R*p)
n = int(input())
s = [str(input()) for i in range(n)]
print(len(set(s)))


### FIXED CODE ###

s,w=map(int,input().split())
if s>w:
  print('safe')
else:
  print('unsafe')
import sys

def main():
	input = sys.stdin.readline

	s = list(input())

	dp = [[0 for _ in range(13)]for _ in range(len(s)+1)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[1][i] = 1
	else:
		dp[1][int(s[-1])] = 1

	for i in range(1,len(s)):
		if s[-i-1] != '?':
			num = (int(s[-i-1]) * (10**i)) % 13
			for j in range(13):
				dp[i+1][j] = dp[i][(13-num+j)%13]
				dp[i+1][j] % MOD
		else:
			for j in range(10):
				num = j * (10**i) % 13
				for k in range(13):
					dp[i+1][k] += dp[i][(13-num+k)%13]
					dp[i+1][k] % MOD

	print(dp[len(s)][5] % MOD)

if __name__ == '__main__':
	main()

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
import sys

args = sys.argv

n = args[1]
a = args[2]
b = args[3]

if n*a > b:
    print("b")
else:
    print("a")



### FIXED CODE ###

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

if N*A < B:
    print(N*A)
else:
    print(B)
A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, min([A,B])):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

if warikiru == []:
    print(1)
else:
    print(warikiru[-1::-1][K-1])

### FIXED CODE ###

A, B, K = [int(x) for x in input().split(" ")]

warikiru = []
for i in range(1, min([A,B])+1):
    if A % i == 0 and B % i == 0:
        warikiru.append(i)

warikiru.reverse()
print(warikiru[K-1])
import math
N, M = map(int, input().split())
max = int(math.sqrt(M))
mod = 7 + 10**9
F = []
for i in range(1, max+1):
    if M%i == 0:
        F.append(i)
        F.append(M//i)

def DP(i, n, memo = {}): 
    if i == 1 or n==1:
        return 1
    try:
        return memo[(i, n)]
    except KeyError:
        ans = 0
        for j in F:
            if n//j >= 1 and n%j == 0:
                ans += DP(i-1, n//j, memo)
                ans %= mod
        memo[(i, n)] = ans
        return ans

memo = {}
print(DP(N, M, memo))

### FIXED CODE ###

import math

def InvMod(i, pow, mod): #階乗のmodを計算
    if pow == 1:
        return i % mod
    else:
        if pow % 2 == 0:
            return InvMod((i**2) % mod, pow//2, mod) % mod
        else:
            return InvMod((i**2) % mod, pow//2, mod) * i % mod

def Prime(i): #素数であればTrueを返す
    root = math.sqrt(i)
    j, div = 2, True
    while j <= root:
        if i % j == 0:
            div = False
            break
        j += 1
    return div

N, M = map(int, input().split())
max = int(math.sqrt(M))
mod = 7 + 10**9

Pinv = [0]
Pfact = 1
for i in range(1, 31): #(階乗)^-1の計算, 2^31 > 10^9なので階乗は高々30乗まで
    Pfact *= i
    Pfact %= mod
    Pinv.append(InvMod(Pfact, mod-2, mod))

P = []
for i in range(2, max+1): #素因数の列挙
    if M % i == 0:
        if Prime(i):
            P.append(i)
        if Prime(M//i) and i**2 != M:
            P.append(M//i)

ans = 1
for p in P:
    C, pow = M, 0
    while C % p == 0: 
        pow += 1
        C //= p
    comb = Pinv[pow]  #(N-1)!/pow!(N-1)!
    for i in range(pow): #comb * (N-1+1)(N-1+2)…(N-1+pow)
        comb *= (N+i)
        comb %= mod
    ans *= comb
    ans %= mod

print(ans)
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
s.append(min(a) + min(b))

for i in range(M):
    x_i, y_i, c_i = map(int, input().split())
    minus = a[x_i - 1] + a[y_i - 1] - c_i
    s.append(minus)

print(min(s))


### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
s.append(min(a) + min(b))

for i in range(M):
    x_i, y_i, c_i = map(int, input().split())
    minus = a[x_i - 1] + b[y_i - 1] - c_i
    s.append(minus)

print(min(s))
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
def f(L):
    if A[L[-1]-1] not in L:
        L.append(A[L[-1]-1])
        return f(L)
    else:
        return L
P = f(L)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j
if k <= j-1:
  print(P[k])
else:
  print(P[j + (k-j)%l])
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

def f(L, S):
    last = L[-1]-1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j

if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])
n = int(input())
a = [0] + list(map(int, input().split())) #index alliginment
b = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
bp, cp = 1, 1
cana, canb = [0], [0] # a[i]に対して条件を満たすbの要素数と
                      # b[i]に対して条件を満たすcの要素数を保管
sumb = [0] # canbの末尾からn個の累積和
ans = 0
for i in range(1,n+1): # aの1~nまで
    while b[bp] <= a[i] and bp != n+1:
        bp += 1
    appending = n+1-bp if bp != n+1 else 0
    cana.append(appending)
for i in range(1,n+1):
    while c[cp] <= b[i] and cp != n+1:
        cp += 1
    appending = n+1-cp if cp != n+1 else 0
    canb.append(appending)
for i in range(1,n+1):
    sumb.append(sumb[-1]+canb[-i])
for i in range(1,n+1):
    ans += sumb[cana[i]]
print(ans)

### FIXED CODE ###

n = int(input())
a = [0] + list(map(int, input().split())) #index alliginment
b = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
bp, cp = 1, 1
cana, canb = [0], [0] # a[i]に対して条件を満たすbの要素数と
                      # b[i]に対して条件を満たすcの要素数を保管
sumb = [0] # canbの末尾からn個の累積和
ans = 0
for i in range(1,n+1): # aの1~nまで
    if bp != n+1:
        while b[bp] <= a[i] and bp != n+1:
            bp += 1
            if bp == n+1:
                break
    appending = n+1-bp if bp != n+1 else 0
    cana.append(appending)
for i in range(1,n+1):
    if cp != n+1:
        while c[cp] <= b[i] and cp != n+1:
            cp += 1
            if cp == n+1:
                break
    appending = n+1-cp if cp != n+1 else 0
    canb.append(appending)
for i in range(1,n+1):
    sumb.append(sumb[-1]+canb[-i])
for i in range(1,n+1):
    ans += sumb[cana[i]]
print(ans)
from collections import deque

n, m = list(map(int, input().split()))
AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n)]
for a, b in AB:
    a -= 1
    b -= 1
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [set() for i in range(n)]
visited = [True] + [False] * (n - 1)
q = deque([(0, 0)]) # (vertex, depth)

while q:
    u, d = q.pop()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].add(v)
        tree[v].add(u)
        q.append((v, d + 1))


# define directions of the edges other than that of MST
degree = [0] * n
ans = []

for a, b in AB:
    a -= 1
    b -= 1
    if b in tree[a]:
        continue
    ans.append([a, b])
    degree[a] += 1


# defining orientations
def dfs(u = 0, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append([u, v])
            degree[u] += 1
        else:
            ans.append([v, u])
            degree[v] += 1

dfs()


# output answer
if degree[0] % 2 == 1:
    print(-1)
else:
    for pair in ans:
        c, d = pair
        c += 1
        d += 1
        print(' '.join(map(str, [c, d])))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

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

if m % 2 == 1:
    print(-1)
    exit()



AB = [[int(x) for x in input().split()] for _ in range(m)]

# representation matrix
repn = [[] for j in range(n + 1)]
for a, b in AB:
    repn[a].append(b)
    repn[b].append(a)


# Minimum Spanning Tree
tree = [set() for i in range(n + 1)]
visited = [False] * (n + 1)
visited[1] = True
q = deque([1])

while q:
    u = q.popleft()
    for v in repn[u]:
        if visited[v]:
            continue
        visited[v] = True
        tree[u].add(v)
        tree[v].add(u)
        q.append(v)


# define directions of the edges other than that of MST
degree = [0] * (n + 1)
ans = []

for a, b in AB:
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a, b))
    degree[a] += 1


# defining orientations
def dfs(u = 1, parent = None):
    for v in tree[u]:
        if v == parent:
            continue
        dfs(v, u)
        if degree[v] % 2 == 0:
            ans.append('{} {}'.format(u, v))
            degree[u] += 1
        else:
            ans.append('{} {}'.format(v, u))
            degree[v] += 1

dfs()

print('\n'.join(ans))
a=input().split()
b=int(a[0])
c=int(a[1])
a.sort(b,c)
if c==0:
  print(b[0],c[0]) 


### FIXED CODE ###

while True :    
    b = list(map(int,input().split()))
    b.sort()
    if b[1]==0:
        break
    print(b[0],b[1])
N = input()
flag = False
for i in range(N//4 + 1):
    for j in range(N//7 + 1):
        if 4 * i + 7 * j == N:
            flag = True
            break
if flag:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
flag = False
for i in range(N//4+1):
    for j in range(N//7+1):
        if 4 * i + 7 * j == N:
            flag = True
if flag:
    print("Yes")
else:
    print("No")
a,b,c=map(int,input().split())
moda=a%k
keep=0
for i in range(0,10**8):
  if (moda*i)%k==c:
    keep=1
    print("YES")
    break
if keep==0:
  print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
moda=a%b
keep=0
for i in range(1,10**6):
  if (moda*i)%b==c:
    keep=1
    print("YES")
    break
if keep==0:
  print("NO")
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [1, 2, 3, 4, 5, 6, 7, 8]
conbination = list(itertools.permutations(N_list, 8))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))


### FIXED CODE ###

import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

N_list = [i for i in range(1,N+1)]
conbination = list(itertools.permutations(N_list, N))

a = conbination.index(tuple(P))
b = conbination.index(tuple(Q))

print(abs(a-b))
n,a,b=[int(i) for i in input().split()]
s=''
s+='b'*a
s+='r'*b
s*=n//(a+b)+1
print(s[:n].count('b'))


### FIXED CODE ###

n,a,b=map(int,input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans+=min(a,rem)
print(ans)