Harryxun/stf_run huggingface dataset:
# https://atcoder.jp/contests/agc028/tasks/agc028_a

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

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

l = n * m // gcd(n, m)
x = [''] * (l)
ans = l
for i in range(n):
    p = i * (l // n)
    x[p] = s[i]
for i in range(m):
    p = i * (l // m)
    if x[p] == '':
        x[p] = t[i]
    else:
        if x[p] == t[i]:
            continue
        else:
            ans = -1
            break
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/agc028/tasks/agc028_a

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

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

def lcm(x, y): #LCM
    # lowest_common_multiple
    return x * y // gcd(x, y)

l = lcm(n, m)
d = gcd(n, m)
n //= d
m //= d

for i in range(d):
    if s[i * n] != t[i * m]:
        print(-1)
        break
else:
    print(l)
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2502 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)


### FIXED CODE ###

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

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)
N=int(input())
S=input()
a=0
for i in range(N):
    if S[i]=="A":
        if S[i+1]=="B":
            if S[i+2]=="C":
                a+=1
                i+=2
print(a)

### FIXED CODE ###

N=int(input())
S=input()
a=0
for i in range(N-2):
    if S[i]=="A":
        if S[i+1]=="B":
            if S[i+2]=="C":
                a+=1
                i+=2
print(a)
#D
N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(N-1):
    if A[i+1]>A[i]:
        B.append(["up",i])
    elif A[i+1]<A[i]:
        B.append(["down",i])
        
C=[]
for i in range(len(B)-1):
    if B[i][0]==B[i+1][0]:
        continue
    C.append(B[i])
C.append(B[-1])

while True:
    if C==[]:
        break
    if C[-1][0]=="down":
        C.pop(-1)
    else:
        break
        
kabu=0
money=1000
if C!=[]:
    if C[0][0]=="up":
        kabu+=money//A[0]
        money%=A[0]
for act in C:
    if act[0]=="up":
        money+=A[act[1]+1]*kabu
        kabu=0
    else:
        kabu+=money//A[act[1]+1]
        money%=A[act[1]+1]
print(money)

### FIXED CODE ###

#D
N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(N-1):
    if A[i+1]>A[i]:
        B.append(["up",i])
    elif A[i+1]<A[i]:
        B.append(["down",i])
        
C=[]
for i in range(len(B)-1):
    if B[i][0]==B[i+1][0]:
        continue
    C.append(B[i])
if B!=[]:
    C.append(B[-1])

while True:
    if C==[]:
        break
    if C[-1][0]=="down":
        C.pop(-1)
    else:
        break
        
kabu=0
money=1000
if C!=[]:
    if C[0][0]=="up":
        kabu+=money//A[0]
        money%=A[0]
for act in C:
    if act[0]=="up":
        money+=A[act[1]+1]*kabu
        kabu=0
    else:
        kabu+=money//A[act[1]+1]
        money%=A[act[1]+1]
print(money)
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(2, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)


### FIXED CODE ###

a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)
from decimal import *
import math
a,b=map(str,input().split())
c=Decimal('a')
d=Decimal('b')
e=c*d
f=math.floor(e)
print(f)

### FIXED CODE ###

from decimal import *
import math
a,b=map(str,input().split())
c=Decimal(a)
d=Decimal(b)
e=Decimal(c*d)
f=math.floor(e)
print(f)
A = list(input())
B = list(input())
C = list(input())

for _ in range(A.count('a')):
    A.remove('a')

for _ in range(B.count('b')):
    B.remove('b')

for _ in range(C.count('c')):
    C.remove('c')

tmp = A.pop()
while True:
    if tmp == 'a':
        if len(A) == 0:
            print('A')
            exit()
        else:
            tmp = A.pop()

    if tmp == 'b':
        if len(B) == 0:
            print('B')
            exit()
        else:
            tmp = B.pop()

    if tmp == 'c':
        if len(C) == 0:
            print('C')
            exit()
        else:
            tmp = C.pop()


### FIXED CODE ###

from collections import deque

A = deque(list(input()))
B = deque(list(input()))
C = deque(list(input()))

tmp = A.popleft()
while True:
    if tmp == 'a':
        if len(A) == 0:
            print('A')
            break
        else:
            tmp = A.popleft()

    elif tmp == 'b':
        if len(B) == 0:
            print('B')
            break
        else:
            tmp = B.popleft()

    else:
        if len(C) == 0:
            print('C')
            break
        else:
            tmp = C.popleft()
N, K = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
for x in h:
    if h >= K:
        ans += 1

print(ans)

### FIXED CODE ###

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

ans = 0
for x in h:
    if x >= K:
        ans += 1

print(ans)
a=list(map(int,input().split());print(min(a[:1])+min(a[2:]))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
z=[a,b,c,d]
print(min(z[:2])+min(z[2:]))
def dp_func(n,dp,h):
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    if dp[n-1]==-1:
        dp[n-1]=dp_func(n-1,dp,h)

    c1=dp[n-1]+abs(h[n]-h[n-1])

    if dp[n-2]==-1:
        dp[n-2]=dp_func(n-2,dp,h)
        
    c2=dp[n-2]+abs(h[n]-h[n-2])

    return min(c1,c2)

def main():
    #input
    N=int(input())
    h=list(map(int,input().strip().split()))

    dp=[-1 for n in range(N)]

    return dp_func(N-1,dp,h)

if __name__=="__main__":
    print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

def dp_func(n,dp,h):
    if n==0:
        return 0
    elif n==1:
        return dp[1]
    
    else:
        if dp[n-1]==-1:
            dp[n-1]=dp_func(n-1,dp,h)

        c1=dp[n-1]+abs(h[n]-h[n-1])

        if dp[n-2]==-1:
            dp[n-2]=dp_func(n-2,dp,h)
            
        c2=dp[n-2]+abs(h[n]-h[n-2])
        
        dp[n]=min(c1,c2)
        return dp[n]

def main():
    #input
    N=int(input())
    h=list(map(int,input().strip().split()))
    # N=10000
    # h=[n**2 for n in range(N)]

    dp=[-1 for n in range(N)]
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    return dp_func(N-1,dp,h)

if __name__=="__main__":
    print(main())
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
ans = combinations_count(N, 2) * 10 ** (N-2) * 2 % (10**9 + 7)
print(ans)

### FIXED CODE ###

N = int(input())
ans = 10**N - 9**N*2 + 8**N
print(ans % (10**9 + 7))
H,W,M = map(int, input().split())
hNum = [0]*H
wNum = [0]*W
bom = [[0] * W for i in range(H)]
for i in range(M):
  h,w = map(int, input().split())
  bom[h-1][w-1] = 1
  hNum[h-1] += 1
  wNum[w-1] += 1

ans = 0
for i in range(H):
  for j in range(W):
    if bom[i][j] == 1:
      ans = max(ans, hNum[i]+wNum[j]-1)
    else:
      ans = max(ans, hNum[i]+wNum[j])

print(ans)

### FIXED CODE ###

H,W,M = map(int,input().split())
hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  r,c = map(int,input().split())
  r -= 1
  c -= 1
  hs[r] += 1
  ws[c] += 1
  s.add((r,c))
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])

i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)
N, A, B, C = [int(i) for i in input().split()]

ans = list()
l = list()

for n in range(N):
    l.append(input())

def dfs(i, a, b, c):
    if i == N:
        return True

    ss = l[i]
    if ss == 'AB':
        if a == 0 and b == 0:
            return False
        if b > 0 and dfs(i + 1, a + 1, b - 1, c):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b + 1, c):
            ans.append('B')
            return True
        return False
    elif ss == 'AC':
        if a == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a + 1, b, c - 1):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b, c + 1):
            ans.append('C')
            return True
        return False
    elif ss == 'BC':
        if b == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a, b + 1, c - 1):
            ans.append('B')
            return True
        if b > 0 and dfs(i + 1, a, b - 1, c + 1):
            ans.append('C')
            return True
        return False
    return False

dfs(0, A, B, C)

if len(ans) > 0:
    print('Yes')
    for x in reversed(ans):
        print(x)
else:
    print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)

N, A, B, C = [int(i) for i in input().split()]

ans = list()
l = list()

for n in range(N):
    l.append(input())

def dfs(i, a, b, c):
    if i == N:
        return True

    ss = l[i]
    if ss == 'AB':
        if a == 0 and b == 0:
            return False
        if b > 0 and dfs(i + 1, a + 1, b - 1, c):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b + 1, c):
            ans.append('B')
            return True
    if ss == 'AC':
        if a == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a + 1, b, c - 1):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b, c + 1):
            ans.append('C')
            return True
    if ss == 'BC':
        if b == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a, b + 1, c - 1):
            ans.append('B')
            return True
        if b > 0 and dfs(i + 1, a, b - 1, c + 1):
            ans.append('C')
            return True
    return False

dfs(0, A, B, C)

if len(ans) > 0:
    print('Yes')
    for x in reversed(ans):
        print(x)
else:
    print('No')
def calc(n):
    damage = (b * n)
    d = [max(dd - damage, 0) for dd in h]
    a_num = 0
    for i in range(len(d)):
        a_num += max(0, 1 + (d[i]-1) // (a - b))
    if a_num <= n:
        return True
    return False

n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
ans = 0
h.sort()

left = 1
right = (h[-1] + 1) // (b)

while (right - left) > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
print(middle)

### FIXED CODE ###

def calc(n):
    damage = (b * n)
    d = [max(dd - damage, 0) for dd in h]
    a_num = 0
    for i in range(len(d)):
        a_num += max(0, 1 + (d[i]-1) // (a - b))
    if a_num <= n:
        return True
    return False

n, a, b = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))
ans = 0
h.sort()

left = 0
right = 10000000000

while (right - left) > 1:
    middle = (left + right) // 2
    if calc(middle):
        right = middle
    else:
        left = middle
print(right)
li = list(map(int, input().split()))
ans = 0
for i in range(li[0] + 1):
  s = sum(list(map(int, str(i))))
  if sum >= li[1] and sum <= li[2]:
    ans += s
print(ans)

### FIXED CODE ###

li = list(map(int, input().split()))
ans = 0
for i in range(li[0]):
  i += 1
  s = sum(list(map(int, str(i))))
  if s >= li[1] and s <= li[2]: ans += i
print(ans)
import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

common=lcm_list(A)
ans=0
for i in range(N):
    ans+=A[i]**(-1)
print(int(common*ans)%a)

### FIXED CODE ###

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

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

common=lcm(A)
ans=0
for i in range(N):
    ans+=common//A[i]
print(ans%a)
a=int(input())
c=0
for i in range(0,a+1):
	if(i%3!=0)and(i%5==0):
		continue
    if(i%3!=0):
    	continue
    if(i%5==0):
    	continue
  	else:
    	c+=i
print(c)  
   


### FIXED CODE ###

n=int(input())
c=0
for i in range(1,n+1):
  if((i%3==0)and(i%5==0)):
    continue
  elif(i%3==0):
    continue
  elif((i%5==0)):
    continue
  else:
    c+=i
print(c)
o = input()
e = input()
lo = len(o)
le = len(e)

if lo >= le: l = lo
else: l = le

s = ""
for i in range(l):
        s += o[i]
        s += e[i]
print(s)

### FIXED CODE ###

o = input()
e = input()
lo = len(o)
le = len(e)

if lo == le: l = lo
elif lo >= le: l = le
else: l = lo

s = ""
for i in range(l):
        s += o[i]
        s += e[i]
if lo - le == 1:
    s += o[-1]
print(s)
import sys
n = int(input())
lst = list(map(int, input().split()))
res = 0
while True:
  for i in range(n):
    if lst[i] % 2 == 1:
      print(res)
      sys.exit()
  lst = [int(j / 2) for j in lst]
  res += 1

### FIXED CODE ###

lst = [int(i) for i in str(input())]
print(sum(lst))
import math
a,b = input().split
num = int(a+b)
print('Yes' if is_integer(math.sqrt(num)) else 'No')

### FIXED CODE ###

import sys
a,b = input().split()
num = int(a+b)
i=1
while(i<=num**0.5):
	if(i**2 == num):
		print('Yes')
		sys.exit()
	i += 1
print('No')
import math

a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))

### FIXED CODE ###

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

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

print(a*b // gcd(a, b))
n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

if pc == 1:
    for i, v in enumerate(x_bin):
        if v == '1':
            print(0)
        else:
            if i != n-1:
                if x[-1] == '0':
                    print(1)
                else:
                    print(2)
            else:
                print(2)
    exit()

p = {0: 1}
m = {0: 1}
for i in range(1, n):
    p[i] = p[i-1]*2 % pc_p
    m[i] = m[i-1]*2 % pc_m

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

x_p = x % pc_p
x_m = x % pc_m

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        if pc_m != 0:
            a = (x - m[i-1]) % pc_m
            print(rest[a] + 1)
        else:
            print(0)
    else:
        a = (x + p[i-1]) % pc_p
        print(rest[a] + 1)


### FIXED CODE ###

n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

if pc == 1:
    for i, v in enumerate(x_bin):
        if v == '1':
            print(0)
        else:
            if i != n-1:
                if x_bin[-1] == '0':
                    print(1)
                else:
                    print(2)
            else:
                print(2)
    exit()

p = {0: 1}
m = {0: 1}
for i in range(1, n):
    p[i] = p[i-1]*2 % pc_p
    m[i] = m[i-1]*2 % pc_m

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

x_p = x % pc_p
x_m = x % pc_m

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        a = (x_m - m[i-1]) % pc_m
        print(rest[a] + 1)
    else:
        a = (x_p + p[i-1]) % pc_p
        print(rest[a] + 1)
from sys import stdin

K = int(stdin.readline())

if K=="ABC":
  print("ARC")
else:
  print("ARC")

### FIXED CODE ###

from sys import stdin

K = str(stdin.readline().strip())

if K=="ABC":
  print("ARC")
else:
  print("ABC")
N=int(input())
A=map(int,input().split())
ans = 1
if 0 in A:
  print(0)
  exit()
for i in range(N):
  ans *= A[i]
  if ans > 10**18:
    print(-1)
    exit()
else:
  print(ans)

### FIXED CODE ###

def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()
N = [int(_) for _ in input().split()]
S = "".join(sorted(N))
print("YES" if S == 1479 else "NO")

### FIXED CODE ###

N = [str(_) for _ in input().split()]
S = "".join(sorted(N))
print("YES" if S == '1479' else "NO")
list = input().split()
N = int(list[0])

list_1 = input().split()
M = int(sum(list_1))

print(M-N)


### FIXED CODE ###

n, m = [int(num) for num in input().split()]
assments = sum(int(num) for num in input().split())
if n - assments < 0:
    print(-1)
else:
    print(n - assments)
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            break
print(ans)

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
S=input()
N=len(S)
mod=10**9+7

#import sys
#sys.setrecursionlimit(200000)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return (dp(cur+1,i+1)+dp(cur+1,i))%mod
		elif S[cur]=='?' and i!=3:
			return (dp(cur+1,i+1)+3*dp(cur+1,i))%mod
		elif S[cur]=='?':
			return 3*dp(cur+1,i)%mod
		else:
			return dp(cur+1,i)%mod

print(dp(0,0)%mod)

### FIXED CODE ###

S=input()
lens=len(S)
mod=10**9+7
cnt=[0,0,0,1]
for s in S:
    if s=="A":
        cnt[0]=(cnt[0]+cnt[3])%mod
    elif s=="B":
        cnt[1]=(cnt[0]+cnt[1])%mod
    elif s=="C":
        cnt[2]=(cnt[1]+cnt[2])%mod
    else:
        cnt[2]=(cnt[1]+3*cnt[2])%mod
        cnt[1]=(cnt[0]+3*cnt[1])%mod
        cnt[0]=(3*cnt[0]+cnt[3])%mod
        cnt[3]=cnt[3]*3%mod
print(cnt[2]%mod)
S = list(input())
SL = len(S)
L = len(S)
i = 1
while len(S)>0 and i<len(S):
  if int(S[i]) != int(S[i-1]):
    S.pop(i-1)
    S.pop(i-1)
    i=i-1
  else:
    i+=1

print(L-len(S))

### FIXED CODE ###

S = list(input())
SL = len(S)
L = len(S)
i = 1
while len(S)>1 and i<len(S):
  if int(S[i]) != int(S[i-1]):
    S.pop(i-1)
    S.pop(i-1)
    i-=1
  else:
    i+=1
  if i==0:
    i+=1
print(L-len(S))
import collections
N = int(input())
A = [int(_) for _ in input().split()]
INF = float('inf')
memo = collections.defaultdict(lambda: INF)


def c(start, res):
    if memo[start, res] != INF:
        return memo[start, res]
    elif start >= N:
        memo[start, res] = -INF
    elif res > 1:
        memo[start, res] = max(A[start] + c(start + 2, res - 1),
                               c(start + 1, res), c(start + 2, res))
    else:
        memo[start, res] = A[start]
    return memo[start, res]


print(c(0, N // 2))


### FIXED CODE ###

import collections, sys
sys.setrecursionlimit(100005)
N = int(input())
A = [int(_) for _ in input().split()]
INF = float('inf')
memo = collections.defaultdict(lambda: INF)


def c(start, res):
    if memo[start, res] != INF:
        return memo[start, res]
    elif 2 * res - 1 > N - start:
        memo[start, res] = -INF
    elif start >= N:
        memo[start, res] = -INF
    elif res > 1:
        memo[start, res] = max(A[start] + c(start + 2, res - 1),
                               c(start + 1, res), c(start + 2, res))
    else:
        memo[start, res] = max(A[start], c(start + 1, res))
    return memo[start, res]


print(c(0, N // 2))
# (c) midandfeed
r, c = [int(x) for x in input().split()]
q = []
sumr = [0]*c
tempr = 0
for i in range(r):
	col = [int(x) for x in input().split()]
	for j in range(c):
		sumr[j] += col[j]
	col.append(sum(col))
	q.append(col)
sumr.append(sum(sumr))
q.append(sumr)
for i in range(r+1):
	for j in range(c+1):
		print(q[i], end='')
		if (i != (r+1))
			print(' ', end='')
	print()

### FIXED CODE ###

# (c) midandfeed
r, c = [int(x) for x in input().split()]
q = []
sumr = [0]*c
tempr = 0
for i in range(r):
	col = [int(x) for x in input().split()]
	for j in range(c):
		sumr[j] += col[j]
	col.append(sum(col))
	q.append(col)
sumr.append(sum(sumr))
q.append(sumr)
for i in range(r+1):
	for j in range(c+1):
		print(q[i][j], end='')
		if (j != (c)):
			print(' ', end='')
	# if (i != (r) ):
	print()
import sys
N,K = map(int,input().split())
lsx = list(map(int,input().split()))
if 0 in lsx:
    K = K-1
    lsx.remove(0)
if bool(lsx) == False or K == 0:
    print(0)
    sys.exit()
lshu = []
for i in range(N):
    if lsx[i] < 0:
        lshu.append(lsx[i])
    else:
        sei = i
        break
lssei = lsx[sei:]
lenhu = len(lshu)
lensei = len(lssei)
lshu2 = [abs(lshu[i]) for i in range(lenhu-1,-1,-1)]
dishu = [0] + lshu2
dissei = [0] + lssei
ans = 2*10**8
for i in range(K):
    if i <= lenhu and K-i <= lensei:
        ans = min(ans,2*dishu[i]+dissei[K-i],dishu[i]+2*dissei[K-i])
print(ans)

### FIXED CODE ###

import sys
N,K = map(int,input().split())
lsx = list(map(int,input().split()))
if 0 in lsx:
    K = K-1
    lsx.remove(0)
if bool(lsx) == False or K == 0:
    print(0)
    sys.exit()
lshu = []
sei = len(lsx)
for i in range(len(lsx)):
    if lsx[i] < 0:
        lshu.append(lsx[i])
    else:
        sei = i
        break
lssei = lsx[sei:]
lenhu = len(lshu)
lensei = len(lssei)
lshu2 = [abs(lshu[i]) for i in range(lenhu-1,-1,-1)]
dishu = [0] + lshu2
dissei = [0] + lssei
ans = 10*10**8
for i in range(K+1):
    if i <= lenhu and K-i <= lensei:
        ans = min(ans,2*dishu[i]+dissei[K-i],dishu[i]+2*dissei[K-i])
print(ans)
# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 and B%K==0 and B-A=>K):
    print('OK')
else:
    print('NG')

### FIXED CODE ###

# A
K = int(input())
A, B = map(int,input().split())

if(A%K==0 or B%K==0):
    print('OK')
elif(B-A >= K - A%K):
    print('OK')
else:
    print('NG')
g=lambda a,b:abs(a[0]*b[1]-a[1]*b[0])

while True:
    t=input()
    if t=="":break
    l=[float(i) for i in t.split()]
    ba=[l[0]-l[2],l[1]-l[3]]
    ab=[-i for i in ba]
    cb=[l[2]-l[4],l[3]-l[5]]
    bc=[-i for i in cb]
    ca=[l[0]-l[4],l[1]-l[5]]
    ac=[-i for i in ca]
    ap=[l[6]-l[0],l[7]-l[1]]
    bp=[l[6]-l[2],l[7]-l[3]]
    cp=[l[6]-l[4],l[7]-l[5]]
    if g(ab,ac)<g(ab,ap) or g(ba,bc)<g(ba,bp):
        print("NO")
    else:
        print("YES")


### FIXED CODE ###

g=lambda a,b,c:(a[0]-b[0])*(b[1]-c[1])-(b[0]-c[0])*(a[1]-b[1])

while True:
    try:t=input()
    except:break
    l=[float(i) for i in t.split()]
    b=[g(l[0:2],l[2:4],l[6:8]),g(l[2:4],l[4:6],l[6:8]),g(l[4:6],l[0:2],l[6:8])]
    if len([i for i in b if i>0])==3 or len([i for i in b if i<0])==3:
        print("YES")
    else:
        print("NO")
maxv = -inf
minv = inf

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)

### FIXED CODE ###

maxv = -1 * (10 ** 10) - 1
minv = 10 ** 10 + 1

n = int(input())

for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv)

print(maxv)
import sys
  
a = 0
while True:
    i = int(sys.stdin.readline())
    if (b == 0):
        break
    b += 1
    print("Case " + str(a) + ":", a)

### FIXED CODE ###

import sys
num = 0
while(True):
    x = int(sys.stdin.readline())
    num += 1
    if x == 0:
        break
    print("Case %d: %d" % (num, x))
k,a,b=map(int,input().split())
z=a-b
if z<=0 and a<k:
    print(-1)
    exit()
print(-(k-a)//z*2+1)

### FIXED CODE ###

k, a, b = map(int, input().split())
if a >= k:
  print(1)
else:
  if a <= b:
    print(-1)
  else:
    r = -(-(k-a) // (a-b))
    print(2*r+1)