Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = input()                                                            
t = []                                                                 
a = []                                                                 
for i in range(int(N)):                                                
    t_n, a_n = input().split()                                         
    t.append(int(t_n))                                                 
    a.append(int(a_n))                                                 
                                                                       
ma = 0                                                                 
t_prev = 0                                                             
a_prev = 0                                                             
for t_n, a_n in zip(t, a):                                             
    summ = t_n + a_n                                                   
    summ_cp = summ                                                     
    i = 0                                                              
    while 1:                                                           
        i += 1                                                         
        summ = summ_cp * i                                             
        if summ >= ma and ((t_n*i) >= t_prev) and ((a_n*i) >= a_prev): 
            ma = summ                                                  
            break                                                      
        #summ = summ_cp * i                                            
    t_prev = t_n*i                                                     
    a_prev = a_n*i                                                     
print(ma)                                                              
                                                                       


### FIXED CODE ###

import math                                             
from decimal import Decimal                             
                                                        
N = input()                                             
t = []                                                  
a = []                                                  
for i in range(int(N)):                                 
    t_n, a_n = input().split()                          
    t.append(Decimal(t_n))                              
    a.append(Decimal(a_n))                              
                                                        
t_ans = 0                                               
a_ans = 0                                               
for t_n, a_n in zip(t, a):                              
    k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n)) 
    if not k:                                           
        k = 1                                           
    t_ans = Decimal(k*t_n)                              
    a_ans = Decimal(k*a_n)                              
print(t_ans+a_ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

table = [[0 for i in range(max(M)+1)] for j in range(n)]

def solve(i, m):
    if m == 0:
        return True
    elif i >= n:
        return False
    elif table[i][m] != 0:
        return table[i][m]
    elif m - A[i] >= 0:
        res = solve(i + 1, m) or solve(i + 1, m - A[i])
        table[i][m] = res
        return res
    else:
        res = solve(i + 1, m)
        table[i][m] = res
        return res

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

table = [[-1 for i in range(max(M)+1)] for j in range(n)]

def solve(i, m):
    if m == 0:
        return True
    elif i >= n:
        return False
    elif table[i][m] != -1:
        return table[i][m]
    elif m - A[i] >= 0:
        res = solve(i + 1, m) or solve(i + 1, m - A[i])
        table[i][m] = res
        return res
    else:
        res = solve(i + 1, m)
        table[i][m] = res
        return res

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')
### BUGGY CODE ###

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

for i in range(K):
        if A > 0:
                A -= 1
        elif B > 0:
                B -= 1
print(A, B)

### FIXED CODE ###

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

if K >= A:
        if B >= (K-A):
                B -= (K-A)
                A = 0
        else:
                B = 0
                A = 0
else:
        A -= K
print(A, B)
### BUGGY CODE ###

import sys
input=sys.stdin.readline

k=int(input())
mod=[]
seven=0
if k%2==0:
    print("-1")
    exit(0)
for i in range(10000000000000):
    seven=seven*10+7
    julia = seven%k
    mod.append(seven % k)
    if julia == 0:
        print(len(mod))
        exit(0)

### FIXED CODE ###

k=int(input())
n=7%k
for i in range(1,k+1):
  if n == 0:
    print(i)
    exit()
  n=(n*10+7) % k
print(-1)
### BUGGY CODE ###

(n, k), p, c = [[*map(int, i.split())] for i in open(0)]

def solve(x, t):
    visit = [0] * n
    visit[x] = 1
    loop = [0] * n
    count = 0
    ans = c[p[x] - 1]
    l = True
    sub = 0
    while True:
        x = p[x] - 1
        if l:
            if visit[x]:
                if loop[x]:
                    ln = sum(loop)
                    if t > l:
                        sub += (t//ln -1)*count*(count>0)
                        t %= ln
                        t += ln
                    l = False
                count += c[x]
                loop[x] = 1
            visit[x] = 1
        sub += c[x]
        t -= 1
        ans = max(sub, ans)
        if t < 1:
            return ans


print(max(solve(i, k) for i in range(n)))


### FIXED CODE ###

(n, k), p, c = [[*map(int, i.split())] for i in open(0)]

def solve(x, t):
    visit = [0] * n
    visit[x] = 1
    loop = [0] * n
    count = 0
    ans = c[p[x] - 1]
    l = True
    sub = 0
    while True:
        x = p[x] - 1
        if l:
            if visit[x]:
                if loop[x]:
                    ln = sum(loop)
                    if t > l:
                        sub += (t//ln -1)*count*(count>0)
                        t %= ln
                        t += ln
                    l = False
                count += c[x]
                loop[x] = 1
            visit[x] = 1
        sub += c[x]
        t -= 1
        ans = max(sub, ans)
        if t < 1:
            return ans


print(max(solve(i, k) for i in range(n)))
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 10**9+7

from collections import defaultdict
last = -1
dic = defaultdict(list)
idx = 0
lis = []
for i in range(N):
    c = int(input())
    if c==last:
        continue
    last = c
    dic[c].append(idx)
    lis.append(c)
    idx += 1
memo = {}
def dfs(i):
    if i==idx:
        return 1
    if i in memo.keys():
        return memo[i]
    v = lis[i]
    ret = 0
    for nx in dic[v]:
        if nx<=i: continue
        ret += dfs(nx+1)
        ret %= mod
    ret += dfs(i+1)
    ret %= mod
    memo[i] = ret
    return ret
print(dfs(0))

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 10**9+7

last = {}
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = dp[i-1]
    c = int(input())
    if c in last and last[c]+1<i:
        dp[i] += dp[last[c]]
        dp[i] %= mod
    last[c] = i

print(dp[N])
### BUGGY CODE ###

from bisect import bisect_left as bl
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    if K > max(A):
        print("IMPOSSIBLE")
        exit()
    if K in A:
        print("POSSIBLE")
        exit()
    key = bl(A,K)
    pre = A[key:]
    for a in pre:
        if a-K in A:
            print("POSSIBLE")
            exit()
    B = map(lambda x:x%2,A)
    B = set(B)
    flag = 0
    for i in range(N-1):
        if A[i+1] - A[i] not in A:
            flag = 1
    if len(B) == 2 and flag:
        print("POSSIBLE")
        exit()
    print("IMPOSSIBLE")
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    if K > max(A):
        print("IMPOSSIBLE")
        exit()
    if K in A:
        print("POSSIBLE")
        exit()

    E = list(map(lambda x:abs(x-K),A))
    E = set(E)
    C = [A[i+1]-A[i] for i in range(N-1)]
    C = set(C)
    D = set(A)
    if E&D:
        print("POSSIBLE")
        exit()

    print("IMPOSSIBLE")
    

if __name__ == "__main__":
    main()
### BUGGY CODE ###

def prime_table(n):
    i = 2
    l = [True for _ in range(n + 1)]
    table = [False for _ in range(n + 1)]
    while i * i <= n:
        j = i + i
        while j <= n:
            l[j] = False
            j += i
        i += 1
    for i in range(n + 1):
        if l[i] and i >= 2:
            table[i] = True
    return table

prime_list = prime_table(10 ** 5)
Q = int(input())

for _ in range(Q):
    count = 0
    l, r = map(int,(input().split()))
    while l <= r:
        if l == 2017 or (prime_list[l] and prime_list[(lambda x:(x + 1) // 2)(l)]):
            count += 1
        l += 2
    print(count)


### FIXED CODE ###

#coding:UTF-8

def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True


mx = 10 ** 5
p = [0 for _ in range(mx + 1)]
for i in range(3, mx + 1):
    if i == 2017 or (is_prime(i) and is_prime((i + 1) // 2)):
        p[i] = 1
d = [0 for i in range(mx + 1)]
for i in range(3, mx + 1):
    d[i] += p[i] + d[i - 1]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(d[r] - d[l - 1])
### BUGGY CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
MAX = 10**5+5
INF = 10**9
P = 1000000007

def resolve():
    s = input().strip()
    dp = [[0]*13 for _ in range(MAX)]
    dp[0][0]=1
    for i,x in enumerate(s):
        if x=='?':
            c=-1
        else:
            c=int(x)
        for j in range(10):
            if(c!=-1 and c!=j):
                continue
            for k in range(13):
                t=(k*10+j)%13
                dp[i+1][t] = dp[i+1][t]+dp[i][k]
    l=len(s)
    print(dp[l][5]%P)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
MAX = 10**5+5
INF = 10**9
P = 1000000007

def resolve():
    s = input().strip()
    dp = [[0]*13 for _ in range(MAX)]
    dp[0][0]=1
    for i,x in enumerate(s):
        if x=='?':
            c=-1
        else:
            c=int(x)
        for j in range(10):
            if(c!=-1 and c!=j):
                continue
            for k in range(13):
                t=(k*10+j)%13
                dp[i+1][t] = dp[i+1][t]+dp[i][k]
        for j in range(13):
            dp[i+1][j]=dp[i+1][j]%P
    l=len(s)
    print(dp[l][5]%P)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  for j in range(n):
    if a[j]==i+1:
      b.append(j+1)
print(*b)
      

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i,j in enumerate(a,1):
  b[j-1]=i
print(*b)
### BUGGY CODE ###

N=int(input())
S=input()
ans = 0
d={'R':0,'G':0,'B':0}
R,G,B=[],[],[]
for i in S:
    d[i]+=1
    R.append(d['R'])
    G.append(d['G'])
    B.append(d['B'])
for i in range(N-2):
    for j in range(i+1,N-1):
        s = [S[i],S[j]]
        if len(set(s))==2:
            if 'R' not in s:
                ans += R[-1]-R[j]
            elif 'G' not in s:
                ans += G[-1]-G[j]
            else:
                ans += B[-1]-B[j]
            if 0<=2*j-i<N and len(set([S[i],S[j],S[2*j-i]]))==3:
                ans -=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
ans = 0
d={'R':0,'G':0,'B':0}
R,G,B=[],[],[]
for i in S:
    d[i]+=1
    R.append(d['R'])
    G.append(d['G'])
    B.append(d['B'])
for i in range(N-2):
    for j in range(i+1,N-1):
        s = [S[i],S[j]]
        if len(set(s))==2:
            if 'R' not in s:
                ans += R[-1]-R[j]
            elif 'G' not in s:
                ans += G[-1]-G[j]
            else:
                ans += B[-1]-B[j]
            if 0<=2*j-i<N and len(set([S[i],S[j],S[2*j-i]]))==3:
                ans -=1
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
A = set(n for n in range(1,N+1))

for m in range(M):
  L,R = map(int,input().split())
  B = set(n for n in range(L,R+1))
  A = A&B

print(len(A))

### FIXED CODE ###

N,M = map(int,input().split())
L1 = 0
R1 = N

for m in range(M):
  L2,R2 = map(int,input().split())
  L1 = max(L1,L2)
  R1 = min(R1,R2)
  
print(max(0,R1-L1+1))
### BUGGY CODE ###

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

a = [int(x)-1 for x in input().split()]

v = []
b = 0

for i in range(n):
    if b not in v:
        v.append(b)
        b = a[b]
    else:
        stop = v.index(b)
        j = i
        break


if k>j:
    r = (k-stop)%(j-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)


### FIXED CODE ###

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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)
### BUGGY CODE ###

import collections
from operator import mul
from functools import reduce
N = int(input())
A = list(map(int,input().split()))

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

for i in range(N):
    L = A[0:i]+A[i+1:N]
    c = collections.Counter(L)
    l = [i for i in c.values() if i != 1]
    ans = 0
    for j in l:
        ans += cmb(j,2)
    print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(input().split(),np.int64)

bincnt = np.bincount(A)

total = (bincnt * (bincnt - 1)).sum() // 2
ans = (total - (bincnt-1))[A].astype(str)

print('\n'.join(ans))
### BUGGY CODE ###

import os, sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
 
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7

def N(): return int(sys.stdin.readline())
def li(): return list(map(int, sys.stdin.readline().split()))
def bulk_li(): return list(map(lambda s: list(map(int, s.split())), sys.stdin.readlines()))

n, w = li()
wv = bulk_li()

# print(wv)
table = dict()

# 以下の条件で最大の価値の総和を返す
# i番目以降(i+1..n)の品物 / 残重量jのナップサック
def dp(i, j):
    if i == n:
        return 0
    if (i, j) in table:
        return table.get((i, j))

    w, v = wv[i]
    if w > j:
        return dp(i+1, j)

    table[(i, j)] = max(v + dp(i+1, j-w), dp(i+1, j))
    return table[(i, j)]

print(dp(0, w))


### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())
ndp = np.zeros(W+1, dtype= np.int64)
for _ in range(N):
    w, v = map(int,input().split())

    # 離散より連続で扱った方が簡単になる。
    np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:])
print(ndp[-1])


"""
https://atcoder.jp/contests/dp/submissions/6657472
より失敬。

めっちゃスマートな解法。
"""
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
a = []
count = 0
for i in range(N):
    a += [sorted(input())]
for i in range(N):
    for j in range(1, N):
        if i+j >= N:
            break
        if a[i] == a[i+j]:
            count += 1
print(count)

### FIXED CODE ###

from collections import defaultdict

n = int(input())
s = [input() for _ in range(n)]

d = defaultdict(int)
for i in range(n):
    d["".join(sorted(s[i]))] += 1

ans = 0
for k in d.keys():
    ans += d[k] * (d[k]-1) // 2
print(ans)
### BUGGY CODE ###

from functools import reduce
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    result = reduce(lambda x, y: x * y, A)
    max_number = 10 ** 18
    if result > max_number:
        print(-1)
    else:
        print(result)

    return


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
        if result > max_number:
            print(-1)
            return
    print(result)
    return


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import deque
H,W=map(int,input().split())

q=deque()
dist=[[-1]*(W+1) for a in range(H+1)]
G=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    G_comp=list(str(input()))
    for j in range(1,W+1):
        if G_comp[j-1]=='#':
            q.append((i,j))
            dist[i][j]=0
        G[i][j]=G_comp[j-1]

def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if G[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1

M=[]
for k in range(1,H+1):
    M.append(max(dist[k]))

print(max(M))






### FIXED CODE ###

from collections import deque
H,W=map(int,input().split())

q=deque()
dist=[[-1]*(W+1) for a in range(H+1)]
G=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    G_comp=list(str(input()))
    for j in range(1,W+1):
        if G_comp[j-1]=='#':
            q.append((i,j))
            dist[i][j]=0
        G[i][j]=G_comp[j-1]

def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if G[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1

M=[]
for k in range(1,H+1):
    M.append(max(dist[k]))

print(max(M))
### BUGGY CODE ###

#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    a = input()
    Q = int(input())
    qs = [input().split() for _ in range(Q)]
    ans = a
    for q in qs:
        if len(q) == 1:
            # ans = ''.join(list(reversed(ans)))
            ans = ans[::-1]
        else:
            if int(q[1]) == 1:
                ans = q[2] + ans
            else:
                ans = ans + q[2]
    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    a = input()
    Q = int(input())
    qs = [input().split() for _ in range(Q)]
    ans = deque(a)
    revcount = 0
    for q in qs:
        if len(q) == 1:
            revcount += 1
        else:
            if int(q[1]) == 1:
                if revcount % 2 == 0:
                    ans.appendleft(q[2])
                else:
                    ans.append(q[2])
            else:
                if revcount % 2 == 0:
                    ans.append(q[2])
                else:
                    ans.appendleft(q[2])
    if revcount % 2 == 1:
        ans.reverse()
    print(''.join(list(ans)))
    return


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
n = int(input())
s = list(map(str, input()))
num = [i for i in range(n)]
st = set()
for ll in list(itertools.combinations(s, r=3)):
  nn = ''.join(ll)
  st.add(nn)

print(len(st))

### FIXED CODE ###

n = int(input())
s = list(map(str, input()))

def solve(k):
  k1, k2, k3 = list(k)
  ans = 0
  flag = 0
  for i1 in range(n):
    if s[i1] == k1:
      for i2 in range(i1+1, n):
        if s[i2] == k2:
          for i3 in range(i2+1, n):
            if s[i3] == k3:
              flag = 1
              break
          break
      break
  if flag:
    return 1
  else:
    return 0

ans = 0
for k in range(1000):
  k = '{:0=3}'.format(k)
  ans += solve(k)

print(ans)
### BUGGY CODE ###

from itertools import combinations
N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
now = l[:2]
for i in range(2, N):
    for j in combinations(now, 2):
        if j[0]+j[1] > l[i]:
            count += 1
    now.append(l[i])
print(count)


### FIXED CODE ###

import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0

for i in range(N):
    for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-j-1
print(count)
### BUGGY CODE ###

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

    s = input()
    s = s[0:len(s)-1]
    Q = int(input())

    flg = 0 # 0:sonomama 1:gyakuten
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            if flg == 0:
                flg = 1
            else:
                flg = 0
        elif q[0]=="2":
            tmp = q[2]
            if (q[1] == "1" and flg ==0) or (q[1] == "2" and flg ==1):
                tmp += s
                s = tmp
            elif (q[1] == "2" and flg == 0) or (q[1] == "1" and flg == 1):
                s += tmp

    if flg==1:
        s = s[::-1]
    print(s)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

    s = input()
    s = s[0:len(s)-1]
    Q = int(input())
    head = []
    tail = []

    flg = 0 # 0:sonomama 1:gyakuten
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            if flg == 0:
                flg = 1
            else:
                flg = 0
        elif q[0]=="2":
            index,tmp = q[1],q[2]
            if (index == "1" and flg ==0) or (index == "2" and flg ==1):
                head.append(tmp)
            elif (index == "2" and flg == 0) or (index == "1" and flg == 1):
                tail.append(tmp)

    s1 = "".join(head)
    s1 = s1[::-1]
    s2 = "".join(tail)
    ans = s1 + s + s2
    if flg == 1:
        ans = ans[::-1]

    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7

def main():
  a,b,x = map(int,input().split())
  cnt = 0
  for l in range(a,b+1):
    if l % x == 0:
      cnt += 1
  print(cnt)
if __name__ == '__main__':
  main()

### FIXED CODE ###

#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7

def main():
  a,b,x = map(int,input().split())
  print(b//x - (a-1)//x)
if __name__ == '__main__':
  main()
### BUGGY CODE ###

X=int(input())

for i in range(1000):
    for j in range(10000):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()


### FIXED CODE ###

X=int(input())

for i in range(-200,200):
    for j in range(-200,200):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()