import math
import re
import random

def generator(s):
    a = []
    i = (s // 50) % 475
    for k in range(25):
        i = (i * 96 + 42) % 475
        a.append(26 + i)
    return a

p, x, y = list(map(int, input().split()))

ans = 10000000000000

for a in range(2000):
    for b in range(2000):
        k = x + 100 * a - 50 * b;
        if k >= y and p in generator(k):
            ans = min(ans, a);
            print(ans)
            return

print(ans)

# def func(arr, qb, allb, res):
#     for el in arr:
#         if el == 'b':
#             qb += 1
#         else:
#             allb += qb
#             qb = 0
#             res += allb
#             allb *= 2
#     return res
#
#
# arr = input()
#
#
# arr = arr[::-1]
#
# res = func(arr, 0, 0, 0)
#
# #print(res)
#
# print(res % (pow(10, 9) + 7))

# n = int(input())
#
#
# if n % 2 == 0:
#     print(n//2 - 1)
# else:
#     print(n//2)

#n = int(input())
# res = ''
# for i in range(n):
#     if i % 4 == 0 or i % 4 == 1:
#         res += 'a'
#     else:
#         res += 'b'
#
# print(res)

# l, r = map(int, input().split())
# if l == r and l % 2 != 0:
#     print(l)
# else:
#     print(2)

# n = int(input())
# a = list(map(len, input().replace('-', ' ').split()))
# for i in range(len(a) - 1):
#     a[i] += 1
#
#
#
#
#
# print(' '.join(map(str, a)))

# n = int(input())
# a = list(map(int, input().split()))
#
# b = []
# q = 0
# for i in range(n):
#     if a[i] != 0 and i != n-1:
#         q += 1
#     elif a[i] == 0 and i != n-1:
#        b.append(q)
#        q = 0
#     elif a[i] == 0 and i == n-1:
#         b.append(q)
#         b.append(0)
#         break
#     else:
#         q += 1
#         b.append(q)
#         break
#
#
# c = []
#
# for j in range(len(b)):
#     if j == 0:
#         for i in range(b[0]):
#             c.append(b[0] - i)
#         c.append(0)
#     elif j == len(b) - 1:
#         for i in range(b[j]):
#             c.append(i + 1)
#     else:
#
#         if b[j] % 2 == 0:
#             for i in range(b[j]//2):
#                 c.append(i + 1)
#             for i in range(b[j]//2):
#                 c.append(b[j]//2 - i)
#             c.append(0)
#         else:
#             for i in range(b[j]//2 + 1):
#                 c.append(i + 1)
#             for i in range(b[j]//2):
#                 c.append(b[j]//2 - i)
#             c.append(0)
#
#
# #print(' '.join(map(str, b)))
#
# print(' '.join(map(str, c)))

#print('2 1 0 1 0 0 1 2 3 ')

# n, k  = map(int, input().split())
#
#
# if k > n*n:
#     print (-1)
#     return
#
# a = [[0] * n for i in range(n)]
#
# for i in range(n):
#     if k == 0:
#         break
#     a[i][i] = 1
#     k -= 1
#     if k == 0:
#         break
#     elif k == 1:
#         a[i+1][i+1] = 1
#         break
#     else:
#         for j in range(i+1, min(n, i + 1 + k//2)):
#                        a[i][j] = 1
#                        a[j][i] = 1
#                        k -= 2
#
#
# for i in range(n):
#     print(' '.join(map(str, a[i])))

# n = int(input())
# a = list(map(int, input().split()))
# #print(' '.join(map(str, a)))
#
#
#
# b = set()
#
# for el in a:
#     if el-1 in b:
#         b.discard(el-1)
#         b.add(el)
#     else:
#         b.add(el)
#
# print(len(b))


# written by sak
#
#	sk<3
#
# powered by codechef

import math
z=input()
z=z.split(' ')
p=int(z[0])
x=int(z[1])
y=int(z[2])

i=int(math.floor(x/50))
i=i%475
flag=0
for j in range(0,25):
	i=(i*96 + 42)%475
	#print(26+i)
	if((26+i)==p):
		print("0")
		flag=1
		break
if(flag!=1):
	ans=0
	while 1:
		curr=x+100*ans
		while(curr>=y):
			i=int(math.floor(curr/50))
			i=i%475
			win={}
			for j in range(0,25):
				i=(i*96 + 42)%475
				if((26+i)==p):
					print(ans)
					flag=1
					break
			curr-=50
			if(flag==1):
				break
		ans+=1
		if(flag==1):
			break


p,x,y = list(map(int,input().split()))
ls = []
i = x//50 % 475
for z in range(25):
  i = (i*96 + 42) % 475
  ls.append(i+26)
if p in ls:
  print(0)
  quit()
l = x-50
m = x
while l >= y:
  ls = []
  i = l//50 % 475
  for z in range(25):
    i = (i*96 + 42) % 475
    ls.append(i+26)
  if p in ls:
    print(0)
    quit()
  l-=50
index = 1
while True:
  ls = []
  i = (m+index*50)//50 % 475
  for z in range(25):
    i = (i*96 + 42) % 475
    ls.append(i+26)
  if p in ls:
    print((50*index + 50)//100)
    break
  else:
    index += 1


p, x, y = list(map(int, input().split()))

def f(s):
    rtn = []
    i = (s // 50) % 475
    for _ in range(25):
        i = (i * 96 + 42) % 475
        rtn.append(26 + i)
    return rtn

ans = -1
tmp = x
while y <= tmp:
    if p in f(tmp):
        ans = 0
        break
    tmp -= 50
tmp = x
while ans < 0:
    tmp += 50
    if p in f(tmp):
        ans = (tmp - x + 50) // 100

print(ans)


inp = input()

p, x, y = list(map(int, inp.split()))

Tshirt = []
s = x

while(s >= y):
    Tshirt = []
    ans = (s // 50) % 475
    for i in range(25):
        ans = (ans * 96 + 42) % 475
        Tshirt.append(ans + 26)

    if p in Tshirt:
        print(0)
        return
    s -= 50

hack = 0
while(not(p in Tshirt)):
    Tshirt = []
    ans = (x // 50) % 475
    for i in range(25):
        ans = (ans * 96 + 42) % 475
        Tshirt.append(ans + 26)
    x += 50
    hack += 1

print(hack // 2)


def mat(s, p):
    i = (s // 50) % 475
    for _ in range(25):
        i = (i*96 + 42) % 475
        if i + 26 == p:
            return True
    return False

p,x,y = map(int, input().split())
s = x
while s >= y:
    s -= 50
if s < y:
    s += 50
while not mat(s, p):
    s += 50
if s <= x:
    print(0)
else:
    print(int((s - x) / 100 + 0.5))


#!/usr/bin/env python
import sys
def eligible(score, position, thresh):
    if score < thresh:
        return False
    i = (score // 50) % 475
    for __ in range(25):
        i = (i * 96 + 42) % 475
        if position == 26 + i:
            return True
    return False

def main():
    p, x, y= list(map(int, sys.stdin.readline().split()))
    diff = 0
    for __ in range(475):
        if eligible(x + diff, p, y):
            print("0")
            return
        diff -= 50
    diff = 0
    for __ in range(475):
        if eligible(x + diff, p, y):
            succ = diff // 100
            unsucc = (diff // 50) %2 ## if 1, we need additional success
            print(str(succ + unsucc))
            return
        diff += 50

main()


from sys import stdin, stdout

p, x, y = list(map(int, stdin.readline().strip().split()))

def getScores(s):
    scores = []
    i = (s // 50) % 475

    for g in range(25):
        i = (i * 96 + 42) % 475
        scores.append(26 + i)

    return scores

z = x
count = 0

while True:
    if x > y:
        if p in getScores(x):
            break
        else:
            x += 50
            count += 1
    else:
        x += 50
        count += 1

dcount = 0
dF = False
x = z
while x >= y:
    if p in getScores(x):
        dF = True
        break
    else:
        x -= 50
        dcount += 1

if dF == True or count == 0:
    print(0)
else:
    print(count // 2 + count % 2)


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

res = 1
while (k % 2 == 0):
    res += 1
    k //= 2
print(res)


def main():
    n, k = list(map(int, input().split()))
    while (n != 0):
        if (k == (2**(n - 1))):
            print(n)
            return
        else:
            k = k % (2**(n - 1))
        n -= 1
main()


n, k = list(map(int, input().split()))
res = 1
while (k & 1) == 0:
  k >>= 1
  res += 1
print(res)


n, k = map(int, input().split())
i = 1
while (k % 2 == 0):
    k /= 2
    i += 1
print(i)


def f(n, k):
    m = our[n]
    if m // 2 + 1 == k:
        return n
    return f(n - 1, k % (m // 2 + 1))

our = [0, 1]
n, k = map(int, input().split())
while len(our) <= n + 1:
    our.append(our[-1] * 2 + 1)
print(f(n, k))


n, k = list(map(int, input().split()))
finish = False
length = 1
for i in range(n-1):
    length = length * 2 + 1
while n!=1:
    gran = length // 2 + 1
    if k == gran:
        print(n)
        finish = True
        break
    if k < gran:
        length = length // 2
        n -= 1
    if k > gran:
        k -= (length // 2 + 1)
        length = length // 2
        n -= 1
if not finish:
    print(1)


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

def f(i,j):
    l = (1<<(i-1))
    if j==l:
        return i
    elif j<l:
        return f(i-1, j)
    else:
        return f(i-1, l-(j-l))

print(f(n,k))


def go(n, m):
    t = 2**(n-1)
    if m == t:
        return n
    else:
        if m < t:
            return go(n-1, m)
        else:
            return go(n-1, m-t)
n, m = map(int, input().split())
print(go(n, m))


def p(n, k):
    if k == 2 ** (n - 1):
        return(n)
    if k > 2 ** (n - 1):
        k -= 2 ** (n - 1)
    return p(n - 1, k)

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


n, k = [int(x) for x in input().strip().split(" ")]
le = 2**n - 1

def binsearch(level, le, ind):
	if level == 1:
		return 1
	if ind == le // 2 + 1:
		return level
	if ind > le // 2 + 1:
		ind -= le // 2 + 1
	return binsearch(level-1, le//2, ind)

print(binsearch(n,le,k))


n, k = list(map(int, input().split()))
k -= 1
x = 1
while True:
    if k % 2 ** x == 2 ** (x - 1) - 1:
        print(x)
        break
    x += 1


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

s = 0
while not(k % 2):
    s += 1
    k //= 2

print(s + 1)


def rec(depth, pos):
    if pos > 2 ** (depth - 1):
        rec(depth - 1, pos - 2 ** (depth - 1))
    elif pos == 2 ** (depth - 1):
        print(depth)
        return
    else:
        rec(depth - 1, pos)
    return

n, k = [int(i) for i in input().split()]
rec(n, k)


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

def nk(n, k):
    if n == 1: return 1
    t = 2**(n-1)
    if k == t: return n
    if k < t: return nk(n-1,k)
    else: return nk(n-1,k-t)

print(nk(n, k))


import sys
n, k = list(map(int, input().split()))
v = k
k -= 1
sum = 0
for i in range(1, n + 1):
    if ((k - sum) % 2 == 0):
        print(i)
        break
    sum += v // (1 << i)


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

lengths = [1]

n, k = n-1, k-1

for i in range(n):
    lengths.append(lengths[-1] * 2 + 1)

def search(n, k):
    if k == 0:
        return 1
    l = lengths[n]
    if k == l // 2:
        return n + 1
    if k < l // 2:
        return search(n-1, k)
    else:
        return search(n-1, k - l//2 - 1)

print(search(n, k))


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

def dfs(q, d):
    q = q % (2**(d-1))
    if (q == 0):
        print(d)
    else:
        dfs(q, d-1)

dfs(k, n)


n , k = map(int, input().split())
res = 0
while k % 2 == 0:
    k /= 2
    res += 1
print(res + 1)


n, k = map(int, input().split())
now = n
while True:
    if k == 2 ** (now - 1):
        print(now)
        break
    else:
        now -= 1
        k %= 2 ** now


import string
import math

line=input()
n=int(line.split(" ")[0])
k=int(line.split(" ")[1])

def search(l,r,k,dep):
    mid=(l+r)/2
    if k==mid or l==r:
        return(dep)
    if k<mid:
        return search(l,mid-1,k,dep-1)
    if k>mid:
        return search(mid+1,r,k,dep-1)

print(search(1,pow(2,n)-1,k,n))


def solve(n, k):
    if n == 1:
        return 1
    if k == 2 ** (n - 1):
        return n
    return solve(n - 1, k % (2 ** (n - 1)))

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


n, k = map(int, input().split())
a = 0
while k % 2 == 0:
    a += 1
    k /= 2
print(a + 1)


# coding=utf-8
__author__ = 'Alexander'

def f(n,k):
    t = 2 ** (n-1)

    if k == t:
        return n
    elif k < t:
        return f(n-1, k)
    else:
        return f(n-1, k-t)

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

print(f(n,k))


n, k = map(int, input().split())
cnt = 0
while k % 2 == 0:
    k = k // 2
    cnt += 1
print(cnt + 1)


import math

n, k = list(map(int, input().split()))
arr = reversed([int(math.pow(2, i)) for i in range(50)])

for index, num in enumerate(arr):
	if k % num == 0:
		print(50 - index)
		break


import sys
input = sys.stdin.readline

def mult_input():
	return map(int,input().split())

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

for nt in range(int(input())):
	n,k=map(int,input().split())
	for i in range(2,n+1):
		if n%i==0:
			num=i
			break
	print (n+i+2*(k-1))


t=int(input())
for _ in range(t):
    n,k=list(map(int,input().split()))
    if n%2==0:
        print(n+2*k)
    else:
        i=2
        while 1>0:
            if n%i==0:
                break
            i=i+1
        n=n+i
        k=k-1
        print(n+2*k)


t = int(input())
for ii in range(t):
    n, k = map(int, input().split())
    if n % 2 == 0:
        print(n + 2 * k)
    else:
        f = 0
        for j in range(2, n + 1):
            if n % j == 0:
                print(n + j + 2 * (k - 1))
                break


'''input
3
5 1
8 2
3 4
'''
def solve():
	n,k = map(int,input().split())
	div = 0
	for i in range(2,n+1):
		if n%i==0:
			div = i
			break
	print(n+div+(k-1)*2)
	return
t = 1
t = int(input())
while t>0:
	t-=1
	solve()


q = int(input())

for _ in range(q):
    n, k = list(map(int, input().split()))
    if n%2:
        for d in range(3, n+1):
            if n%d == 0:
                n += d
                k -= 1
                break
    n += k*2
    print(n)


import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    for i in range(2, n+1):
        if n % i == 0:
            n += i
            break
    n += 2 * (k-1)
    print(n)
    return

# solve()

T = ni()
for _ in range(T):
    solve()


for _ in range(int(input())):
    n, k = map(int, input().split())
    d1 = 2
    while n % d1 != 0:
        d1 += 1

    n = n + d1
    k -= 1
    n += k*2
    print(n)


# The real secret to success is enthusiasm. Walter Chrysler
# by : Blue Edge - Create some chaos

def give(n):
    i=2
    while i*i<=n:
        if n%i==0:
            return i
        i+=1
    return n
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    print(n+give(n)+2*(k-1))


t=int(input())
for i in range(t):
  n,k=map(int,input().split())
  ans=n
  for i in range(2,n+1):
    if n%i==0:
      ans+=i
      break
  ans+=2*(k-1)
  print(ans)


for f in range(int(input())):
    n,k=map(int,input().split())
    div=2
    while div*div<n and n%div!=0:
        div+=1
    if div*div>n:
        div=n
    print(n+div+(k-1)*2)


"""T=int(input())
for _ in range(0,T):
    n=int(input())
    a,b=map(int,input().split())
    s=input()
    s=[int(x) for x in input().split()]
    for i in range(0,len(s)):
        a,b=map(int,input().split())"""

T=int(input())
for _ in range(0,T):
    n,k=list(map(int,input().split()))
    ans=n
    if(n%2==0):
        ans+=(2*k)
    else:
        ans+=(2*(k-1))
        for i in range(2,n+1):
            if(n%i==0):
                ans+=i
                break
    print(ans)


t = int(input())
for _ in range(t):
    n, k = list(map(int, input().split()))
    best = 0
    for i in range(2, n+1):
        if n % i == 0:
            best = i
            break
    print(n+best+(2*(k-1)))


from math import sqrt
from collections import defaultdict as dd
import sys
input=sys.stdin.readline
import bisect
t=int(input())
while t:
    #n=int(input())
    n,k=map(int,input().split())
    #l=list(map(int,input().split()))
    for i in range(2,n+1):
        if(n%i==0):
            ind=i
            break
    n=n+i
    n=(k-1)*2+n
    print(n)
    t-=1


# test = iter('''0
# 1 2
# '''.splitlines())
#
#
# def input():
#     return next(test)

def int_input():
    return int(input())

def ints_input():
    return (int(x) for x in input().split())

t=int_input()
for _ in range(t):
    n,k=ints_input()
    if (n&1) == 0:
        print(n+k+k)
    else:
        for i in range(3, n+1, 2):
            if n % i == 0:
                print(n+i+2*(k-1))
                break


t = int(input())

for _ in range(t):
    n, k = list(map(int, input().strip().split()))
    if n % 2 == 0:
        print(n + 2*k)
    else:
        for i in range(3, n + 1):
            if n % i == 0:
                print(n + i + (k-1)*2)
                break


import math
import sys

#sys.stdin = open("in.txt")

t = int(input())
for i in range(t):
    n, k = map(int, input().split())
    for i in range(k):
        if  (n % 2 == 0):
            n += 2 * (k - i)
            break
        else:
            for d in range(3, 1000, 2):
                if (n % d == 0 or d * d > n):
                    break
            if (n % d > 0):
                d = n
            n += d
    print(n)


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

def main():
    from math import sqrt
    t = 1
    t = int(input())
    for _ in range(t):
        n , k = map(int , input().split())
        if n % 2 == 0:
            print(n + k * 2)
        else:
            for i in range(3 , n + 1):
                if n % i == 0:
                    print(n + i + (k - 1) * 2)
                    break
    return

def __starting_point():
    main()
__starting_point()


t=int(input())
for you in range(t):
    l=input().split()
    n=int(l[0])
    k=int(l[1])
    for i in range(2,n+1):
        if(n%i==0):
            break
    n+=i
    k-=1
    print(n+(2*k))


for i in range(int(input())):
    n,k=map(int,input().split())
    ind=-1
    for j in range(2,int(n**0.5)+1):
        if n%j==0:
            ind=j
            break
    if ind==-1:
        ind=n
    k-=1
    su=n+ind+(k)*2
    print(su)


t=int(input())
for _ in range(t):
	n,k=list(map(int,input().split()))
	div=-1
	for i in range(2,int(n*0.5)+1):
		if n%i==0:
			div=i
			break
	if div==-1:
		div=n
	n+=div
	k-=1
	print(n+k*2)


"""
Codeforces Contest 266 Div 2 Problem B

Author  : chaotic_iak
Language: Python 3.3.4
"""

def ceildiv(a,b):
    return a//b + (1 if a%b else 0)

def main():
    n,a,b = read()
    s = 6*n
    if a*b >= s:
        print(a*b)
        print(a,b)
        return
    t = int((6*n) ** .5)
    tgt = 9001*n
    tgta = 0
    tgtb = 0
    for i in range(1, t+1):
        c = ceildiv(s,i)
        if a <= i and b <= c:
            if tgt > i*c:
                tgt = i*c
                tgta = i
                tgtb = c
        if b <= i and a <= c:
            if tgt > i*c:
                tgt = i*c
                tgtb = i
                tgta = c
    print(tgt)
    print(tgta,tgtb)

################################### NON-SOLUTION STUFF BELOW

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())


from math import *
n,a,b = map(int,input().split())
ans = (10000005700000,1000000000064000)
ansp = 10**55
if a*b>=6*n:
    ans = (a,b)
    ansp = a*b

for x in range(int(sqrt(6*n)*1.33)):
    yy = max(0,ceil((6*n-a*b-b*x)/(a+x))-1)
    for y in range(yy,yy+3):
        if 6*n<=(a+x)*(b+y)<ansp:
            ansp=(a+x)*(b+y)
            ans = (a+x,b+y)
a,b = b,a
for x in range(int(sqrt(6*n)*1.44)):
    yy = max(0,ceil((6*n-a*b-b*x)/(a+x))-1)
    for y in range(yy,yy+3):
        if 6*n<=(a+x)*(b+y)<ansp:
            ansp=(a+x)*(b+y)
            ans = (b+y,a+x)

print (ansp)
print(*ans)


def main():
    n, a, b = list(map(int, input().split()))

    s = 6 * n

    if a * b >= s:
        print(a*b)
        print(a, b)
        return

    ma, mb = min(a, b), max(a, b)

    _s = float('inf')
    _a = 0

    for i in range(min(int(s**0.5)+1, s // mb), ma - 1, -1):
        _b = (s + i - 1) // i
        si = i * _b
        if _s > si:
            _a, _s = i, si
            if si == s:
                break
    print(_s)
    _b = _s // _a
    if not (a <= _a and b <= _b):
        _a, _b = _b, _a
    print(_a, _b)

def __starting_point():
    main()

__starting_point()


def solve(n, a, b):
    need = n * 6

    orig_a, orig_b = a, b

    if a < b:
        a, b = b, a

    y = b

    best_prod = None
    best = (None, None)

    while True:
        x, modulo = divmod(need, y)

        if modulo:
            x += 1

        if x < a:
            x = a

        prod = x * y

        if not best_prod or best_prod > prod:
            best_prod = prod
            best = (x, y)

        if best_prod == need:
            break

        y += 1

        if x < y:
            break

        if x < a or y < b:
            break

    x, y = best
    if x < orig_a or y < orig_b:
        best = (y, x)

    return best

def __starting_point():
    n, a, b = list(map(int, input().split()))
    x, y = solve(n, a, b)
    print(x * y)
    print(x, y)

__starting_point()


import math

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

#variables
x=6*n-1

#main
if a*b>6*n:
	print(a*b)
	print(str(a)+' '+str(b))
	quit()

while True:
	x+=1
	for i in range(min(a,b),math.floor(math.sqrt(x))+1):
		if x%i==0:
			if i>=a and x/i>=b:
				print(x)
				print(str(i)+' '+str(x//i))
				quit()
			if i>=b and x/i>=a:
				print(x)
				print(str(x//i)+' '+str(i))
				quit()


from math import *
from itertools import *
n, a, b = map(int, input().split())
if a * b >= 6 * n:
  print(a * b)
  print(a, b)
else:
  p = ceil(sqrt(6 * n))
  s, a1, b1 = min(chain(((x * ceil(6 * n / x), x, ceil(6 * n / x)) for x in range(a, p + 1) if ceil(6 * n / x) >= b), \
                        ((ceil(6 * n / y) * y, ceil(6 * n / y), y) for y in range(b, p + 1) if ceil(6 * n / y) >= a)))
  print(s)
  print(a1, b1)


import math
n, a, b = list(map(int, input().split()))
s = 6*n
if a*b >= s:
    print(a*b)
    print(a, b)
else:
    aa, bb = a, b
    area = float('inf')
    _a = 0
    for i in range(min(math.ceil(s**0.5), s // max(a, b)), min(a, b)-1, -1):
        _b = math.ceil(s/i)
        _s = _b * i
        if _s <= area:
            area, _a = _s, i
            if _s == s:
                break
    print(area)
    _b = area//_a
    if not (aa <= _a and bb <= _b):
        _a, _b = _b, _a
    print(_a, _b)


from math import ceil

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

s = 6 * n

if a * b >= s:
    na, nb = a, b
else:
    a1, b1 = min(a, b), max(a, b)
    q = [(x, ceil(s / x)) for x in range(a1, ceil(s ** .5)) if ceil(s / x) > b1]
    na, nb = min(q, key=lambda c: c[0] * c[1])
    if na < a:
        na, nb = nb, na

print(na * nb)
print(na, nb)


a, b, c = list(map(int, input().split(' ')))
def solve(a, b, c):
    if b >= c:
        b, c = c, b
    for i in range(max(6*a, b*c), 10**50):
        for j in range(b, int(i**0.5)+1):
            if i%j==0:
                if int(i/j)>=c:
                    return (i, j, int(i/j))
x, y, z = solve(a, b, c)

print(x)
if y>=b and z>=c:
    print(y, z)
else:
    print(z, y)


n, a, b = map(int, input().split())
n = 6 * n
s = a * b
if s >= n:
    print(s)
    print(a, b)
    return
m = int(n ** 0.5) + 1
s = (a + m) * (b + m)
for x in range(a, m):
    y = max((n - 1) // x + 1, b)
    if x * y < s:
        s = x * y
        u, v = x, y
for y in range(b, m):
    x = max((n - 1) // y + 1, a)
    if x * y < s:
        s = x * y
        u, v = x, y
print(s)
print(u, v)


from math import ceil

n, a, b = list(map(int, input().split()))
s = n * 6

if s <= a * b:
    na, nb = a, b
else:
    a1, b1 = min(a, b), max(a, b)
    q = [(x, ceil(s / x)) for x in range(a1, ceil(s ** .5)) if ceil(s / x) > b1]
    na, nb = min(q, key = lambda c : c[0] * c[1])
    if na < a:
        na, nb = nb, na

print(na * nb)
print(na, nb)


n,a,b = list(map(int, input().split(' ')))
A = 6*n
if a*b >= 6*n :
    print(a*b)
    print(a,b)
else :
    R = []
    temp = float("INF")
    for i in range(1, int(A**0.5)+2) :
        j = A//i
        if i*j < A : j+=1
        x = max([a,b,i,j])
        y = max(min(a,b) , min(i,j))
        if temp > x*y :
            temp = x*y
            if b>a : x,y = y,x
            R = [x,y, temp]
    print(R[2])
    print(R[0], R[1])


__author__ = 'trunghieu11 - vuondenthanhcong11@gmail.com'

# ---------- Actual Code ----------

count, a, b = list(map(int, input().split()))
areaNeed = 6 * count

if a * b >= areaNeed:
    print(a * b)
    print(a, b)
    return

isSwap = False
if a > b:
    a, b = b, a
    isSwap = True

answerArea = 10**10
answerA = -1
answerB = -1

for i in range(a, int(areaNeed ** 0.5) + 1):
    curB = (areaNeed + i - 1) // i
    if curB >= b:
        curArea = i * curB
        if curArea < answerArea:
            answerArea = curArea
            answerA = i
            answerB = curB

if isSwap:
    answerA, answerB = answerB, answerA

print(answerArea)
print(answerA, answerB)

# ---------- My Tools -------------


from math import sqrt,ceil;
def main():
    n,a,b = [int(i) for i in input().split()]
    swaped = 0
    if (a > b):
        a,b = b,a
        swaped = 1
    if (a*b >= 6*n):
        print(a*b)
        print(a,b)
        return 0
    new_a_max = ceil(sqrt(6*n))
    ans = []
    for newa in range(a,new_a_max+1):
        newb = ceil((6*n)/newa)
        if (newa*newb >= 6*n and newb >= b):
            ans.append([newa*newb,newa,newb])
    ans = sorted(ans)
    if (swaped):
        ans[0][1],ans[0][2] = ans[0][2],ans[0][1]
    print(ans[0][0])
    print(ans[0][1],ans[0][2])
def __starting_point():
    main()

__starting_point()


from math import sqrt
from math import ceil

(n, a, b) = list(map(int, input().split(' ')))
batas = ceil(sqrt(6 * n))
luas = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + \
    100
p, l = 0, 0

if a * b >= 6 * n:
    print(a * b)
    print("%d %d" % (a, b))
    return

for i in range(a, max(a, batas + 1)):
    lenmin = ceil(float(6 * n) / i)
    if lenmin < b:
        continue
    if lenmin * i == 6 * n:
        print("%d\n%d %d" % (6 * n, i, lenmin))
        return
    if lenmin * i > 6 * n:
        if lenmin * i < luas:
            p = i
            l = lenmin
            luas = lenmin * i

for i in range(b, max(b, batas + 1)):
    lenmin = ceil(float(6 * n) / i)
    if lenmin < a:
        continue
    if lenmin * i == 6 * n:
        print("%d\n%d %d" % (6 * n, lenmin, i))
        return
    if lenmin * i > 6 * n:
        if lenmin * i < luas:
            p = lenmin
            l = i
            luas = lenmin * i

print("%d\n%d %d" % (p * l, p, l))


import sys

try:
    while True:
        n, a, b = list(map(int, input().split(" ")))
        flag = False
        if a > b:
            flag = True
            a, b = b, a
        if 6*n <= a * b:
            print(a*b)
            res = str(a) + " " + str(b)
            print(res)
            continue
        res = 1 << 60
        i = a
        ans1 = 0
        ans2 = 0
        while i*i <= 6 * n:
            tmp = 6*n//i
            if tmp * i < 6 * n:
                tmp += 1
            if tmp < b:
                i += 1
                continue
            if i*tmp < res:
                res = i * tmp
                ans1 = i
                ans2 = tmp
            i += 1
        if flag:
            ans1, ans2 = ans2, ans1
        print(res)
        ans = str(ans1) + " " + str(ans2)
        print(ans)

except EOFError:
    pass


import math

n,a,b=list(map(int,input().split()))
target=6*n
if(target<a*b):
    p=a
    q=b
else:
    m=int(target ** 0.5)+1
    s=(a+m)*(b+m)
    for i in range(a,m):
        bb=max(math.ceil(target/i),b)
        if(i*bb<s):
            s=i*bb
            p=i
            q=bb
    for j in range(b,m):
        aa=max(math.ceil(target/j),a)
        if(j*aa<s):
            s=j*aa
            p=aa
            q=j
print(p*q)
print(p,q)


from math import ceil

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

s = 6 * n

if a * b >= s:
    x, y = a, b
else:
    a1, b1 = min(a, b), max(a, b)
    q = [(x, ceil(s / x)) for x in range(a1, ceil(s ** .5)) if ceil(s / x) > b1]
    x, y = min(q, key=lambda c: c[0] * c[1])
    if x < a:
        x, y = y, x

print(x * y)
print(x, y)


import math
x=[]
count=0
n,a,b=list(map(int,input().split()))
if a>b:
    count=1
if a*b>=n*6:
    print(a*b)
    print(a,b)
elif max(a,b)<=n and min(a,b)<=6:
    print(n*6)
    if count==1:
        print(max(n,6),min(n,6))
    else:
        print(min(n,6),max(n,6))
else:
    for i in range(min(a,b),min(math.ceil(n*6/min(a,b)),int((6*n)**0.5)) + 1):
        if math.ceil(n*6/i)>=max(a,b):
            x.append([math.ceil(n*6/i) * i,i])
    x.sort()
    print(x[0][0])
    if count==1:
        print(max(x[0][1],x[0][0]//x[0][1]),min(x[0][1],x[0][0]//x[0][1]))
    else:
        print(min(x[0][1],x[0][0]//x[0][1]),max(x[0][1],x[0][0]//x[0][1]))


n,a,b=list(map(int,input().split()))
if a*b>=6*n:
    print(a*b)
    print(a,b)
else:
    sq,ansx,ansy,ar=round(((6*n)**0.5)),1e9,1e9,1e18
    for i in range(1,sq+6):
        p,q=i,(6*n+i-1)//i
        if max(p,q)>=max(a,b) and min(p,q)>=min(a,b):
            if ar>p*q:
                ar=p*q
                ansx,ansy=min(p,q),max(p,q)
    print(ansx*ansy)
    if ansx>=a and ansy>=b:
        print(ansx,ansy)
    else:
        print(ansy,ansx)


from math import ceil

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

s = 6 * n

if a * b >= s:

    x, y = a, b

else:

    a1, b1 = min(a, b), max(a, b)

    q = [(x, ceil(s / x)) for x in range(a1, ceil(s ** .5)) if ceil(s / x) > b1]

    x, y = min(q, key=lambda c: c[0] * c[1])

    if x < a:

        x, y = y, x

print(x * y)

print(x, y)

# Made By Mostafa_Khaled


import math

n, a, b = list(map(int, input().strip().split()))
min_sq = n * 6

if a * b >= min_sq:
    print('{}\n{} {}'.format(a * b, a, b))
else:
    max_sq = math.inf

    swap = False
    if a > b:
        a, b = b, a
        swap = True

    a_n, b_n = a, b

    for i in range(a, int(math.ceil(math.sqrt(min_sq))) + 1):
        n_b = int(math.ceil(min_sq / i))

        if n_b < b:
            continue

        new_sq = n_b * i
        if new_sq < max_sq:
            max_sq = new_sq
            a_n = i
            b_n = n_b

    if swap:
        a_n, b_n = b_n, a_n
    print('{}\n{} {}'.format(max_sq, a_n, b_n))


n, a , b = list(map(int, input().split()))
n *= 6
swapped = False
if a > b:
    a, b = b, a
    swapped = True
a, b = min(a,b), max(a,b)
a1, b1 = a, b
s = (1<<61)
for i in range(a, int(n**0.5)+1):
    j = max(b1, (n-1) // i + 1)
    if i * j < s:
        s = i * j
        a, b = i, j
print(a * b)
if swapped:
    print(b, a)
else:
    print(a, b)


from math import sqrt
n, a, b=map(int, input().split())
p, x, y=a*b, a, b
n*=6
if n>p:
	i=min(x, y)
	j=min((n//max(x, y)), int(sqrt(n)))+1
	p=n*(a+b)
	for e in range(i, j):
		k=(n+e-1)//e
		if e*k<p:
			p=e*k
			x=e
			y=k
			if p==n:
				break
if (a>b and x<y) or (a<b and x>y):
	x, y=y, x
print(p)
print(x, y)


def find(ins):
	ins += 1

	test = [int(i) for i in str(ins)]

	inlist = []

	for i in test:
		if i in inlist:

			test = find(ins)
			break

		else:
			inlist.append(i)

	return ''.join(str(x) for x in test)

ins = int(input())
print(find(ins))


y = int(input())
y = y+1
def isDistinct(year):
    sy = str(year)
    li = []
    for i in sy:
        if(i in li):
            return False
        li.append(i)
    return True

while(not isDistinct(y)):
    y = y+1

print(y)


import sys
inp = sys.stdin
y = int(inp.readline()) + 1

def check_dif(num):
  s = str(num)
  ok = 1
  for i in range(len(s)):
    if s[i] in s[i + 1:]:
      ok = 0
  return ok

while check_dif(y) == 0:
  y += 1
print(y)


n = int(input()) + 1
while len(set(str(n))) != 4:
	n += 1
print(n)


y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something
while len(set(str(y))) != len(str(y)): y+=1 #scott
print(y) #steven remember ++ doesn't exist


# http://codeforces.com/problemset/problem/271/A you start this should be like a 2-liner with python?

#sry i see it now

def check(x): # let's practice writing functions though and yeah i think list == array so not list prolly
# http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html
    return len(set(str(x)))==len(str(x)) # should work??
y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something

while not check(y): y+=1 #scott

print(y) #steven remember ++ doesn't exist


# http://codeforces.com/problemset/problem/271/A you start this should be like a 2-liner with python?

#sry i see it now

def check(x): # let's practice writing functions though and yeah i think list == array so not list prolly
# http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html
    return len(set(str(x)))==len(str(x)) # should work??
y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something

while check(y) == 0:  y+=1 #scott

print(y) #steven remember ++ doesn't exist
#oh wait it might be the == false might need to be FALSE or something stupid like that also ! does not exist
#oh ic


# http://codeforces.com/problemset/problem/271/A you start this should be like a 2-liner with python?

#sry i see it now

def check(x): # let's practice writing functions though and yeah i think list == array so not list prolly
# http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html
    return len(set(str(x)))==len(str(x)) # should work??
y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something

while check(y) == False: y+=1 #scott

print(y) #steven remember ++ doesn't exist


# http://codeforces.com/problemset/problem/271/A you start this should be like a 2-liner with python?

#sry i see it now

def check(x): # let's practice writing functions though and yeah i think list == array so not list prolly
# http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html
    return len(set(str(x)))==len(str(x)) # should work??
y = int(input()) + 1 #scott wait you don't even right? you can do like list(str(y)) or something

while check(y) is False: y+=1 #scott

print(y) #steven remember ++ doesn't exist


n=input()
year=int(n)
year+=1
n=list(str(year))
while(not(n.count(n[0])==n.count(n[1])==n.count(n[2])==n.count(n[3])==1)):
    year+=1
    n=list(str(year))

print(year)


3

y = int(input())
ans = y + 1
while True:
    if len(set(list(str(ans)))) == 4:
        break
    ans += 1
print(ans)


n = int(input()) + 1
while len(set(str(n))) != 4: n += 1
print(n)


def is_distinct(year):
    years = str(year)
    s = set()
    for c in years:
        if c in s:
            return False
        else:
            s.add(c)
    return True

def upper_distinct(year):
    year += 1
    while(True):
        if is_distinct(year):
            return year
        else:
            year += 1

def main():
    first_line = input()
    first_line = first_line.split()

    year = int(first_line[0])
    print(upper_distinct(year))

main()


y=int(input())+1
while(len(set(str(y)))!=len(str(y))):
    y+=1
print(y)


import sys

def year():
    listyear = []
    year = input().split()
    k = True
    for i in range(len(year[0])):
        listyear.append(int(year[0][i]))
    listyear.reverse()
    return(listyear)

def nextyear(listyear):
    if listyear[0] == 9:
        listyear[0] = 0
        if listyear[1] == 9:
            listyear[1] = 0
            if listyear[2] == 9:
                listyear[2] = 0
                if listyear[3] == 9:
                    listyear[3] = 0
                else:
                    listyear[3] += 1
            else:
                listyear[2] += 1
        else:
            listyear[1] += 1
    else:
        listyear[0] += 1
    return listyear

def rightyear(listyear):
    nextyear(listyear)
    while len(set(listyear)) != 4:
        listyear = nextyear(listyear)
    listyear.reverse()

    for i in listyear:
        print(i,end="")

rightyear(year())


n = int(input())
while True:
    n += 1
    c = set(str(n))
    if len(c) == len(str(n)):
        print(n)
        break


n = int(input()) + 1
while len(set(str(n))) != 4:
    n += 1
print(n)


def cnt(n):
    a = [0] * 10
    c = 0
    b = 0
    while n != 0:
        a[n % 10] += 1
        if a[n % 10] == 1:
            c += 1
        n //= 10
        b += 1
    if b == c:
        return True
    else:
        return False

n = int(input().strip())
i = 1
while not cnt(n + i):
    i += 1
print(n + i)


y=int(input())

def is_b_year(x):
	s=set()
	for c in str(x):
		s.add(c)
	if len(s) == 4:
		return True
	else :
		return False

for x in range(y+1,2**31-1):
	if is_b_year(x):
		print(x)
		break


year = int(input())

for i in range(year + 1, 10000):
    y = i
    a = y // 1000
    y = y - a * 1000
    b = y // 100
    y = y - b * 100
    c = y // 10
    y = y - c * 10
    lst = [a, b, c, y]
    lst.sort()
    if lst[0] != lst[1] and lst[1] != lst[2] and lst[2] != lst[3]:
        print(i)
        break


for i in range(int(input()) + 1, 10000):
    if len(set(list(str(i)))) == 4:
        print(i)
        break


def isUnique(num):
    string=str(num)
    d={'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
    for i in string:
        if d[i]==0:
            d[i]=1
        elif d[i]==1:
            return 0
    return 1

string=input()
num=int(string)
while 1:
    num+=1
    if isUnique(num):break
print(num)


def getmask(x):
    ans = 0
    for i in range(2, x + 1):
        while x % (i * i) == 0:
            x //= i * i
        if x % i == 0:
            ans ^= 1 << i
            x //= i
    return ans

def main():
    maxn = 71
    n = int(input())
    a = [int(i) for i in input().split()]
    cnt = [0] * maxn
    for i in a:
        cnt[i] += 1
    masks = {}
    for i in range(1, maxn):
        if cnt[i]:
            masks[getmask(i)] = masks.get(getmask(i), 0) + cnt[i]
    while len(masks) > 1 or 0 not in masks:
        if not masks:
            print(0)
            return
        fixed = max(masks.keys())
        for i in list(masks.keys()):
            if i ^ fixed < i:
                masks[i ^ fixed] = masks.get(i ^ fixed, 0) + masks[i]
                masks[i] = 0
        masks[0] = masks.get(0, 0) + masks[fixed] - 1
        masks[fixed] = 0
        masks = {i: j for i, j in list(masks.items()) if j > 0}
    print(pow(2, masks[0], 10**9+7) - 1)

main()


from collections import defaultdict
def getmask(x):
    ans = 0
    for i in range(2, x + 1):
        while x % i == 0:
            x //= i
            ans ^= 1 << i
    return ans

def main():
    maxn = 71
    n = int(input())
    a = [int(i) for i in input().split()]
    cnt = [0] * maxn
    for i in a:
        cnt[i] += 1
    masks = defaultdict(int)
    for i in range(1, maxn):
        masks[getmask(i)] += cnt[i]
    while masks[0] != sum(masks.values()):
        fixed = max(i for i in masks if masks[i])
        masks[0] -= 1
        for i in list(masks.keys()):
            if i ^ fixed < i:
                masks[i ^ fixed] += masks[i]
                masks[i] = 0
    print(pow(2, masks[0], 10**9+7) - 1)

main()


from collections import *

l = int(input())
c = Counter(map(int, input().split()))
t = defaultdict(int)
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]

for k, s in c.items():
    d = 0
    for i, q in enumerate(p):
        while k % q == 0:
            k //= q
            d ^= 1 << i
    t[d] += s

u = defaultdict(int)
u[0] = 1

for x in t:
    if x: l -= 1
    if 0 < x < 2048:
        v = u.copy()
        for y in u: v[x ^ y] += u[y]
        u = v

e = 1000000007
print((u[0] * pow(2, l, e) - 1) % e)


from sys import stdin

def find_prime(max_value):
    assert max_value >= 2
    result = [2]
    for i in range(3, max_value):
        state = 1
        for item in result:
            if item * item > i:
                break
            elif i % item == 0:
                state = -1
                break
        if state == 1:
            result.append(i)
    return result

module = int(10e8) + 7

n = int(stdin.readline())
A = list(map(int, stdin.readline().split()))
number = [0 for i in range(70)]
for item in A:
    number[item - 1] += 1

prime_list = find_prime(70)

prime_map = {}
for i in range(2, 70 + 1):
    result = 0
    for item in prime_list:
        cur = i
        num = 0
        while cur % item == 0:
            num += 1
            cur = int(cur / item)
        result = result * 2 + num % 2
    prime_map[i] = result

number_dic = {0: 1}
sum_time = 0
for i in range(2, 70 + 1):
    if number[i - 1] >= 1:
        mask = prime_map[i]
        state = 1
        new_number_dic = number_dic.copy()
        for key, value in list(new_number_dic.items()):
            new_key = key ^ mask
            if new_key in number_dic:
                number_dic[new_key] += value
            else:
                number_dic[new_key] = value
            number_dic[new_key] %= module
        sum_time += (number[i - 1] - 1)

result = number_dic[0]

for j in range(number[0] + sum_time):
    result *= 2
    result %= module
print(result-1)


from collections import defaultdict
            #from collections import defaultdict
def getmask(x):
    ans = 0
    for i in range(2, x + 1):
        while x % i == 0:
            x //= i
            ans ^= 1 << i
    return ans

def main():
    maxn = 71
    #maxn = 71
    n = int(input())
    #n = int(input())
    a = [int(i) for i in input().split()]
    cnt = [0] * maxn
    for i in a:
        cnt[i] += 1
    masks = defaultdict(int)
    for i in range(1, maxn):
        masks[getmask(i)] += cnt[i]
    while masks[0] != sum(masks.values()):
        fixed = max(i for i in masks if masks[i])
        masks[0] -= 1
        for i in list(masks.keys()):
            if i ^ fixed < i:
                masks[i ^ fixed] += masks[i]
                masks[i] = 0
    print(pow(2, masks[0], 10**9+7) - 1)

main()


n = int(input())
moves = input()

turns_vasnja = int((len(moves)-1) / n)

count = 0
for i in range(1, turns_vasnja+1):
    if moves[n * i - 3] == moves[n * i - 2] == moves[n * i - 1]:
        count += 1

print(count)


n=int(input())

s=input()
nn=len(s)
ans=0
for i in range(n,nn,n):
    if(s[i-1]+s[i-2]+s[i-3]=='aaa' or s[i-1]+s[i-2]+s[i-3]=='bbb'):
        ans+=1
print(ans)


n = int(input())
s = input().strip()
pl = 0
ans = 0
for q in range(len(s)):
    if q>=3 and pl==0:
        if s[q-3]==s[q-2]==s[q-1]:
            ans+=1
    pl = (pl+1) % n
print(ans)


n = int(input())
s = input()
ans = 0
for i in range(n, len(s), n):
    if s[i - 3:i] in ('aaa', 'bbb'):
        ans += 1
print(ans)


n = int(input())
s = input()
ans = 0
for i in range(len(s)):
    if i % n == 0 and i >= 3:
        if s[i-1] == s[i-2] == s[i-3]:
            ans += 1
print(ans)


cnt, n, ans = 1, int(input()), 0
s = input()
for i in range(1, len(s)):
	if cnt == 0 and s[i - 1] == s[i - 2] == s[i - 3]:
		ans += 1
	cnt += 1
	if cnt == n:
		cnt = 0
print(ans)


n = int(input())
string = input()
count = 0
i = n
while i < len(string):
    flag = False
    if string[i - 1] == string[i - 2] and string [i - 2] == string[i - 3] and i >= 3:
        flag = True
    if flag:
        count += 1
    i += n
print(count)


a=int(input())
s=input()
n=0
for i in range(a,len(s),a):
    if s[i-2]==s[i-1] and s[i-1]==s[i-3] :
        n+=1
print(n)


import sys
fin = sys.stdin

n = int(fin.readline())
b = fin.readline().strip()
m = len(b)

res = 0
for i in range(n, m, n):
  if b[i - 3] == b[i - 2] == b[i - 1]:
    res += 1

print(res)


n = int(input())
s = input()
cnt = 0
for i in range(len(s))[n::n]:
  if s[i-1] == s[i-2] and s[i-1] == s[i-3]:
    cnt += 1
print(cnt)


n = int(input())
s = input().strip()
ans = 0
for i in range(n, len(s), n):
    ans += s[i - 3:i] == "bbb" or s[i - 3:i] == 'aaa'
print(ans)


n=int(input())
s=input()
a,b=n,0
while a<len(s):
	if s[a-3]==s[a-2]==s[a-1]:b+=1
	a+=n
print (b)


n=input('')
n=int(n)
str=input('')
l=len(str)
count=0
if l<=4:
    print(0)
elif l>4:
        c=n
        while c<=(l-1):
          str1=str[c-3:c]
          if str1=='aaa' or str1=='bbb':
            count+=1
          c+=n
        print(count)


n = int(input())
s = input()
i = n
ans = 0
while i < len(s):
	if s[i - 1] == s[i - 2] and s[i - 2] == s[i - 3]:
		ans += 1
	i += n
print(ans)


n = int(input())
moves = input()
i = n
count = 0
while(i < len(moves)):
    m = moves[i - 1]
    if(m == moves[i - 2] and m == moves[i - 3] and m == moves[i - 3]):
        count += 1
    i += n
print(count)


n = int( input() )
s = input()
i=n
l = len(s)
tot = 0
while i<len(s):
	if s[i-1] == s[i-2] == s[i-3]:
	    tot += 1
	i += n
print(tot)


n=int(input())
s=input()
a,b=n,0
while a<len(s):
	if s[a-1]==s[a-2]==s[a-3]:
		b+=1
	a+=n
print(b)


n = int(input());
s = input();
cnt = 0;
for i in range(len(s))[n::n]:
    if s[i - 1] == s[i - 2] and s[i - 2] == s[i - 3]:
        cnt += 1;
print(cnt);


n = int(input())
s = str(input())

while (len(s)-1) % n != 0:
    s = s[:len(s)-1]

sol = 0
for i in range(len(s)-1, 3, -n):
    if s[i-1] == s[i-2] and s[i-2] == s[i-3]: sol += 1

print(sol)


n=int(input())
s=input()
count=0
i=(n)
while i<len(s):
    if s[i-1]==s[i-2]==s[i-3]:
        count+=1
    i+=n
print(count)


n, s, ans = int(input()), input(), 0
for i in range(len(s)):
    if i > 2 and not i % n and s[i - 1] == s[i - 2] == s[i - 3]:
            ans += 1
print(ans)


3

n = int(input())
s = input()
print(len([1 for i in range(n, len(s), n) if len(set(list(s[i - 3:i]))) == 1]))


n = int(input())
s = str(input())

sl = len(s)
d = 0

for i in range(n, sl, n):
    if s[i-1] == s[i-2] and s[i-1] == s[i-3]:
        d += 1

print(d)


#332A Down the Hatch!

n = int(input())
actions = input()
glasses = 0
for i in range(n, len(actions), n):
	if actions[i-1] == actions[i-2] == actions[i-3]:
		glasses += 1
print(glasses)


s, n, t = 0, int(input()), input()
print(sum(t[i - 3: i] in ['aaa', 'bbb'] for i in range((3 // n + 1) * n , len(t), n)))


n, m, k = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
ind = []
pre = []

for _ in range(n):
    s = input()
    ind.append([])
    for i, c in enumerate(s):
        if c == '1':
            ind[-1].append(i)

for i in range(n):
    pre.append([])
    for j in range(k + 1):
        pre[i].append([])
        if len(ind[i]) > j:
            pre[i][j] = ind[i][-1] - ind[i][0] + 1
        else:
            pre[i][j] = 0
            continue
        for x in range(j + 1):
            y = len(ind[i]) - 1 - j + x

            if y >= x and ind[i][y] - ind[i][x] + 1 < pre[i][j]:
                pre[i][j] = ind[i][y] - ind[i][x] + 1
dp = [[]]

for i in range(k + 1):
    dp[0].append(pre[0][i])

for i in range(1, n):
    dp.append([])
    for j in range(0, k + 1):
        dp[i].append(pre[i][j] + dp[i - 1][0])
        for z in range(j + 1):
            dp[i][j] = min(dp[i][j], dp[i - 1][z] + pre[i][j - z])

print(dp[n - 1][k])


import queue
intput = lambda:list(map(int, input().split()))

N, M, K = intput()
ht = [[] for _ in range(N)]
for _ in range(N):
    day = input()
    ht[_] = [i for i in range(M) if day[i] == '1']

# req[i][j] -- required hours for day i if j lessons skipped
# dp[i][j] -- required hours up to day i if j lesson skipped
# dp[i+1][j+z] = dp[i][j] + req[i][z]

tc = [1,2,3,8,9]
# just return dp[-1][-1]
req = [[0 for _ in range(M+1)] for __ in range(N)]
dp = [[0 for _ in range(K+1)] for __ in range(N)]
for i in range(N):
    # cost to skip j lessons today
    for j in range(len(ht[i])):
        req[i][j] = ht[i][-1] - ht[i][0] + 1  # default large num
        # if start at the first-th lesson
        for first in range(j+1):
            last = first + len(ht[i])-j-1
            cost = ht[i][last]-ht[i][first]+1
            if last >= first:
                req[i][j] = min(req[i][j], cost)

for i in range(min(len(req[0]), len(dp[0]))):
    dp[0][i] = req[0][i]
for i in range(1, N):
    # total skipped up to this point
    for j in range(K+1):
        dp[i][j] = dp[i-1][j] + req[i][0]
        # additional skipped for this day -- min of (skips left, curr skips, num lessons)
        for z in range(1+min(j, len(ht[i]))):
            dp[i][j] = min(dp[i][j], dp[i-1][j-z] + req[i][z])

# print('{}\n{}'.format(req,dp))
print(dp[-1][-1])


R = lambda: map(int, input().split())
n, m, k = R()
cls = [list(i for i, x in enumerate(map(int, input())) if x) for _ in range(n)]
dp = [[n * m] * (k + 1) for i in range(n + 1)]
dp.append([0] * (k + 1))
for i in range(n):
    row = cls[i]
    c2l = [m + 1] * (m + 1)
    c2l[0] = row[-1] - row[0] + 1 if row else 0
    c2l[len(row)] = 0
    for r in range(len(row)):
        for l in range(r + 1):
            c2l[len(row) - (r - l + 1)] = min(c2l[len(row) - (r - l + 1)], row[r] - row[l] + 1)
    for j in range(k + 1):
        for c, l in enumerate(c2l):
            if j + c <= k and l < m + 1:
                dp[i][j] = min(dp[i][j], dp[i - 1][j + c] + l)
print(min(dp[n - 1]))


def min_sub_array(day, k):
    if not day:
        return [0] * (k + 1)
    n = len(day)
    best = [float('inf')] * (n + 1)
    best[0] = 0
    best[1] = 1
    for size in range(2, n + 1):
        for i in range(n + 1 - size):
            best[size] = min(best[size], day[i + size - 1] - day[i] + 1)
    output = [0] * (k + 1)
    for i in range(k + 1):
        if n - i > 0:
            output[i] = best[n - i]
    return output

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

day = [i for i, val in enumerate(input()) if val == '1']
best = min_sub_array(day, K)

for _ in range(N - 1):
    day = [i for i, val in enumerate(input()) if val == '1']
    new_day_best = min_sub_array(day, K)

    new_best = [float('inf')] * (K + 1)
    for i in range(K + 1):
        for j in range(i + 1):
            new_best[i] = min(new_best[i], new_day_best[j] + best[i - j])
    best = new_best
print(best[K])


import sys
input = sys.stdin.readline

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
from collections import Counter
import math
import bisect
from collections import deque
n,m,lesson=int_array()
dp=[[250005 for i in range(lesson+2)]for j in range(n+1)]
days=[[] for i in range(n)]
for i in range(n):
	s=input()
	for  j in range(m):
		if s[j]=="1":
			days[i].append(j+1)

m=[[250005 for i in range(lesson+2)]for j in range(n+1)]
for i in range(n):
	for j in range(lesson+1):
		if j<=len(days[i]):
			if j==len(days[i]):
				m[i][j]=0
				continue
			else:
				for k  in range(0,j+1):
					var=days[i][0+k]
					var1=days[i][-1*max(1,1+(j-k))]
					m[i][j]=min(m[i][j],var1-var+1)

for i in range(lesson+1):
	dp[0][i]=m[0][i]
for i in range(1,n):
	for j in range(lesson+1):
		for k in range(j+1):

			dp[i][j]=min(dp[i][j],dp[i-1][j-k]+m[i][k])
			#dp[i][j] = min(dp[i][j], dp[i - 1][k]+m[i][j-k])

print(min(dp[n-1]))


import sys

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

dp = [0]*(k+1)

for a in table:
    one = []
    for i in range(m):
        if a[i] == '1':
            one.append(i)

    if not one:
        continue

    ni = len(one)
    subdp = [10**9] * (ni+1)
    subdp[-1] = 0

    for i in range(ni):
        for j in range(i, ni):
            subdp[ni-(j-i+1)] = min(subdp[ni-(j-i+1)], one[j]-one[i]+1)

    next_dp = [10**9]*(k+1)
    for i in range(k, -1, -1):
        for j in range(ni+1):
            if i+j > k:
                break
            next_dp[i+j] = min(next_dp[i+j], dp[i] + subdp[j])
    dp = next_dp

print(min(dp))


3

s = input()
alph = ''.join([chr(ord('a') + x) for x in range(26)])
l = [[]]
for x in s:
    if x not in alph:
        l[-1].append(x)
    else:
        if len(l[-1]):
            l.append([])
l = list([''.join(x) for x in l])
ansa = 0
ansb = 0
for t in l:
    if len(t) > 2 and t[-3] == '.':
        ansb += int(t[-2:])
        t = t[:-3]
    ansa += int(''.join(t.split('.')))
ansa += ansb // 100
ansb %= 100
ansa = str(ansa)
ans = []
last = len(ansa)
for x in range(len(ansa) - 3, -1, -3):
    ans.append(ansa[x:last])
    last = x
if last != 0:
    ans.append(ansa[:last])
ans.reverse()
if ansb != 0:
    ans.append("%02d" % ansb)
print(".".join(ans))


s = input()
l = ''.join(list((map(lambda x : x if ord('0') <= ord(x) <= ord('9') or x == '.' else ' ', list(s)))))

def readnum(s):
    if len(s) >= 3 and s[-3] == '.':
        a = s[:-3]
        b = s[-2:]
    else:
        a = s
        b = '00'
    a = ''.join(list(filter(lambda x : x != '.', a)))
    return (a,b)
l = list(map(readnum,l.split()))
a,b = (0,0)
for (x,y) in l:
    a += int(x)
    b += int(y)
a += b//100
b = b%100

a = str(a)

na = ''
nd = 0
for c in a[::-1]:
    if nd % 3 == 0 and len(na) != 0:
        na = '.' + na
    na = c + na
    nd += 1

print(na, end='')
if b:
    print('.%02d' % b)


# You lost the game.
s = str(input())
n = len(s)
i = 0
r = 0
A = "0123456789."
while i < n:
    while A.count(s[i]) == 0:
        i += 1
    p = ""
    while i < n and A.count(s[i]):
        p += s[i]
        i += 1
    E = list(p.split("."))
    #print(p,E)
    e = len(E)
    if len(E[e-1]) == 2:
        v = 0
        for j in range(e-1):
            v = v*1000 + int(E[j])
        v = v*100 + int(E[e-1])
    else:
        v = 0
        for j in range(e):
            v = v*1000 + int(E[j])
        v *= 100
    r += v
#print(r)
R = str(r)
m = len(R)-2
res = ""
if m > 0:
    res = R[:m%3]
    for i in range(m%3,m,3):
        if i>0:
            res += "."+R[i:i+3]
        else:
            res += R[i:i+3]
if m <= 0:
    res += "0"
if m == -1:
    res += ".0"+R[m+1]
elif R[m:m+2] != "00":
    res += "." + R[m:m+2]

print(res)


s = input()
curnum = 0
ans = 0
dr = 0
n = len(s)
s += 'aaa'
i = 0
while i < n:
    #print(i, curnum)
    if '0' <= s[i] <= '9':
        curnum = 10 * curnum + int(s[i])
    elif s[i] == '.':
        if ('0' <= s[i + 1] <= '9') and ('0' <= s[i + 2] <= '9') and not('0' <= s[i + 3] <= '9'):
            dr += (10 * int(s[i + 1]) + int(s[i + 2]))
            i = i + 2
    else:
        ans += curnum
        curnum = 0
    i += 1
ans += curnum
ans += dr // 100
ans2 = dr % 100
if ans2 == 0:
    ans2 = ''
elif ans2 < 10:
    ans2 = '.0' + str(ans2)
else:
    ans2 = '.' + str(ans2)
ans = int(ans)
ans = str(ans)
nans = ''
for i in range(len(ans)):
    if i % 3 == 0 and i != 0:
        nans += '.'
    nans += ans[len(ans) - 1 - i]
print(nans[::-1] + ans2)


s = input()
name = False
s2 = '0'
cnt = 0
pointsPresent = False
sum = 0
for i in range(len(s)):
    if s[i] in "1234567890.":
        name = False
    else:
        name = True
    if name:
        if cnt == 3 or not pointsPresent:
            sum += int(s2) * 100
        else:
            sum += int(s2)
        s2 = "0"
        cnt = 0
        pointsPresent = False
    else:
        if s[i] != '.':
            s2 += s[i]
            cnt += 1
        else:
            cnt = 0
            pointsPresent = True
if cnt == 3 or not pointsPresent:
    sum += int(s2) * 100
else:
    sum += int(s2)

if sum < 10:
    print("0.0" + str(sum))
elif sum < 100:
    print("0." + str(sum))
else:
    if sum % 100 == 0:
        sum //= 100
        c = -1
    else:
        c = 0
    s3 = str(sum)
    for i in range(len(s3) - 1, -1, -1):
        c += 1
        if c == 3:
            c = 0
            s3 = s3[:i + 1] + '.' + s3[i + 1:]
    print(s3)


import sys, math
s = input()
gg = 0
i = 0
dbl = 0
while i < len(s):
    if 'a' <= s[i] <= 'z':
        i += 1
        continue
    h = '000'
    while i < len(s) and  not 'a' <= s[i] <= 'z':
        h += s[i]
        i += 1
    ans = ''
    if h[-3] == '.':
        dbl += int(h[-2:])
        h = h[:-3]
    for z in h:
        if z != '.':
            ans += z
    gg += int(ans)
#print(gg, dbl)
dd = []
gg += dbl // 100
dbl = dbl % 100
gg = gg
if dbl != 0:
    dbl = str(dbl)
    while len(dbl) < 2:
        dbl = '0' + dbl
    dd.append(dbl)
#print(dd)
if gg == 0:
    dd.append(0)
while gg != 0:
    dd.append(str(gg % 1000))
    if (gg >= 1000):
        while len(dd[-1]) < 3:
            dd[-1] = '0' + dd[-1]
    gg //= 1000
dd.reverse()
print(*dd, sep = '.')


s = input().strip()
dc = set()

for i in range(ord('0'), ord('9') + 1):
    dc.add(chr(i))

dc.add('.')

s1 = ""
for i in range(1, len(s)):
    if s[i] in dc and s[i - 1] not in dc:
        s1 += " "
    if s[i] in dc:
        s1 += s[i]

a = []
s = s1.split(' ')
rub = 0
cop = 0
for i in s:
    if i != "":
        left = "00"
        right = ""
        if len(i) >= 4 and i[-3] == '.':
            left = i[-2:]
            right = i[:-3]
        else:
            right = i
        rt = ""
        for j in right:
            if j != '.':
                rt += j
        rub += int(rt)
        cop += int(left)

rub += cop // 100
cop -= (cop // 100) * 100
anss = ""
rubs = str(rub)
cnt = 1
for i in range(len(rubs) - 1, -1, -1):
    anss += rubs[i]
    if cnt % 3 == 0:
        anss += '.'
    cnt += 1
anss = list(anss)
anss.reverse()
if anss[0] == '.':
    anss = anss[1:]
anss = ''.join(anss)
print(anss, end='')
if cop != 0:
    print('.', end='')
    if cop < 10:
        print(0, end='')
    print(cop, end='')


#!/usr/bin/env python3

import decimal
import itertools

def is_digit_or_dot(char):
    return char.isdigit() or char == "."

def compute(bill):
    prices = []
    for k, v in itertools.groupby(bill, is_digit_or_dot):
        if not k:
            continue
        segments = "".join(v).split(".")
        if len(segments[-1]) == 2:
            cent = decimal.Decimal("." + segments[-1])
            dollar = decimal.Decimal("".join(segments[:-1]))
            price = cent + dollar
        else:
            price = decimal.Decimal("".join(segments))
        prices.append(price)
    amount = sum(prices)
    dollar, cent = divmod(amount, 1)
    ans = "{:,d}".format(int(dollar)).replace(",", ".")
    if cent > 0:
        ans += str(cent)[1:]
    return ans

def main():
    print(compute(input()))

def __starting_point():
    main()

__starting_point()


def f(t):
    if t == '':
        return 0
    m = len(t)
    if '.' not in t:
        return int(t) * 100
    if t[-3] != '.':
        t += '00'
    t2 = ''.join([i for i in t if i != '.'])
    return int(t2)

def wr(x):
    if x < 100:
        res = '0.'
        if x < 10: res += '0'
        res += str(x)
        return res
    x = str(x)
    m = len(x)
    res = x[-2:]
    for i in range(m - 2, 2, -3):
        res = x[i - 3:i] + '.' + res
    res = x[0: (m - 2) % 3] + '.' + res
    if res[0] == '.': res = res[1:]
    if res[-2:] == '00': res = res[:-3]
    return res

s = input() + '_'
num = '1234567890.'
ans = 0
n = len(s)
cur = ''
for i in range(n):
    if s[i] not in num:
        ans += f(cur)
        cur = ''
    else:
        cur += s[i]
print(wr(ans))


s = input()
ans = 0
d = ""
for i in range(len(s)):
    if s[i] in "0123456789.":
        d += s[i]
    else:
        si = ""
        if len(d):
            for j in range(len(d)):
                if d[j] != ".":
                    si += d[j]
            si1 = int(si)
            if (len(d) >= 3 and d[-3] != ".") or len(d) < 3:
                si1 *= 100
            #print(si1)
            ans += si1
        d = ""
si = ""
for j in range(len(d)):
    if d[j] != ".":
        si += d[j]
    si1 = int(si)
if (len(d) >= 3 and d[-3] != ".") or len(d) < 3:
    si1 *= 100
ans += si1
if ans < 10:
    print("0.0{}".format(ans))
elif ans < 100:
    print("0.{}".format(ans))
else:
    ansl = str(ans)[::-1]
    ansi = ansl[0] + ansl[1] + "."
    for i in range(2, len(ansl)):
        if i % 3 == 2 and i != 2:
            ansi += "."
        ansi += ansl[i]
    if ans % 100 == 0:
        a = ansi[::-1]
        print(a[:-3])
    else:
        print(ansi[::-1])


lat='qwertyuiopasdfghjklzxcvbnm'
lats=[]
lats+=lat
c=str(input())
for i in lats:
    c=c.replace(i,' ')
c=c.split()
#print(c)

k=0
for i in c:
    j=int(i.replace('.',''))
    i=i.replace('.',' ')

    i=i.split()
    if len(i[len(i)-1])!=2 or len(i)==1:
        j*=100
    #print(j)
    k+=j
#print(k)
print(format(k//100,',d').replace(',','.'),end='')
if k%100!=0:
    print(".%02d" % (k%100))


s = input().strip()
i = 0
alph = 'abcdefjhigklmnopqrstuwvxyz'
ans = 0
while i < len(s):
    if s[i] in alph:
        i += 1
    else:
        j = i
        while j < len(s) and (s[j] in '1234567890' or s[j] == '.'):
            j += 1
        c = s[i:j]
        fl = False
        for k in range(len(c) - 1, -1, -1):
            if c[k] == '.':
                fl = True
                if len(c) - k - 1 == 3:
                    c += '00'
                break
        if not fl:
            c += '00'
        a = ''
        for k in c:
            if k != '.':
                a = a + k
        #print(a)
        ans += int(a)
        i = j
an = str(ans)
a = ''
if len(an) < 3:
    an = '0' * (3 - len(an)) + an
a += an[-1]
a += an[-2]
a += '.'
i = 0
#print(an)
for k in range(len(an) - 3, -1, -1):
    a += an[k]
    i += 1
    if i == 3 and k > 0:
        a += '.'
        i = 0
fl = False
if ans % 100 == 0:
    fl = True

for i in range(len(a) - 1, -1, -1):
    if not fl or i > 2:
        print(a[i], end='')


s = input().rstrip()
for i in range(ord('a'), ord('z') + 1):
    s = 'z'.join(s.split(chr(i)))
s = list(s.split('z'))
ans = 0
ans2 = 0
for i in s:
    if len(i) == 0:
        continue
    q = i.split('.')
    if len(q) == 1 or len(q[-1]) == 3:
        ans += int(''.join(q))
    else:
        ans += int(''.join(q[:len(q)-1]))
        ans2 += int(q[-1])
ans += ans2 // 100
ans2 %= 100
d = ''
if ans2 != 0:
    d = str(ans2)
    d = '.' + '0' * (2 - len(d)) + d
a = []
ans = int(ans)
while ans >= 1000:
    a.append('.' + '0' * (3 - len(str(ans % 1000))) + str(ans % 1000))
    ans //= 1000
a.append(str(ans))
a.reverse()
print(''.join(a) + d)


from decimal import *

# newstr = oldstr.replace("M", "")

def add(l):
	num = list()
	for v in l:
		if v != '.':
			num.append(v)
	num = int(''.join(num))
	if len(l) >= 3 and l[-3] == '.':
		return num
	return num * 100

def solve():
	s = input()
	res = 0
	l = list()
	for c in s:
		if c.islower():
			if len(l) > 0: res += add(l)
			l = list()
		else:
			l.append(c)
	if len(l) > 0: res += add(l)
	return res

def prt(n):
	n = str(n)
	n = n[::-1]
	first = True
	res = ""
	while len(n) > 0:
		if first:
			s = n[:2][::1] if len(n) >= 2 else n[:1] + '0'
			res += s
			res += '.'
			n = n[len(s) :]
		else:
			tmp = ""
			for i in range(3):
				if len(n) == 0:
					break
				tmp += n[0]
				n = n[1:]
			tmp += '.'
			res += tmp

		first = False

	res = res[::-1]

	if len(res) == 3:
		res = '0' + res
	else:
		if res[0] == '.':
			res = res[1:]
	if len(res) >= 3 and res[-1] == '0' and res[-2] == '0' and res[-3] == '.':
		res = res[:-3]
	return res

print(prt(solve()))


s = input()
rub = 0
kop = 0
cur = 0
len_cur = 0
for i in range(len(s)):
    if 122 >= ord(s[i]) >= 97:
        if len_cur == 2:
            kop += cur - cur // 100 * 100
            rub += cur // 100
        else:
            rub += cur
        cur = 0
        len_cur = 0
    elif 57 >= ord(s[i]) >= 48:
        cur = 10 * cur + int(s[i])
        len_cur += 1
    elif s[i] == '.':
        len_cur = 0

if len_cur == 2:
    kop += cur - cur // 100 * 100
    rub += cur // 100
else:
    rub += cur

rub += kop // 100
kop = kop - kop // 100 * 100

if kop < 10: kop = '0' + str(kop)
kop = str(kop)
srub = ''
if len(str(rub)) % 3 != 0:
    srub += str(str(rub)[:len(str(rub)) % 3]) + '.'

c = 0
for i in range(len(str(rub)) % 3, len(str(rub))):
    c += 1
    srub += str(rub)[i]
    if c == 3:
        srub += '.'
        c = 0

if kop == '00':
    print(srub[:-1])
else:
    print(srub + kop)


from math import *

def remd(x):
    y = []
    for i in x:
        if i != '.':
            y.append(i)
    return ''.join(y)

def parse(x):
    if '.' not in x:
        return int(x)
    i = len(x) - 1
    cnt = 0
    while x[i] != '.':
        i -= 1
        cnt += 1
    if cnt == 2:
        x1 = int(remd(x[:i]))
        x2 = int(x[i + 1:])
        return x1 + x2 / 100
    else:
        return int(remd(x))

def format(y):
    y1 = int(y)
    y2 = round((y - y1) * 100)

    y1 = str(y1)
    yy = []
    for i in range(len(y1)):
        yy.append(y1[len(y1) - 1 - i])
        if i % 3 == 2 and i != len(y1) - 1:
            yy.append('.')
    yy.reverse()
    yy = ''.join(yy)

    if y2 != 0:
        yy += '.'
        yy += ('%02d' % y2)
    return yy

s = input()
pr = []
cur = []
for i in s:
    if '0' <= i <= '9' or i == '.':
        cur.append(i)
    else:
        if len(cur) > 0:
            pr.append(''.join(cur))
            cur = []
if len(cur) > 0:
    pr.append(''.join(cur))

sm = 0
for i in pr:
    sm += parse(i)
print(format(sm))


def fr(s):
    ans = 0
    was = False
    s = s.split('.')
    if len(s[-1]) == 2 and len(s) != 1:
        ans += int(s[-1]) / 100
        was = True

    s = s[::-1]
    for i in range(was, len(s)):
        ans += int(s[i]) * (10 ** (3 * (i - was)))

    return ans

def to(n):
    ans =  []
    was = False
    if int(n) != n:
        tmp = str(n - int(n))
        tmp = tmp[2:]
        try:
            if tmp[2]:
                if tmp[2] >= "5":
                    tmp = tmp[0] + str(int(tmp[1]) + 1)
                else:
                    tmp = tmp[:2]
        except:
            pass
        if len(tmp) == 1:
            tmp += '0'
        ans.append(tmp)
        was = True
    n = int(n)

    while n > 0:
        tmp = str(n % 1000)
        if len(tmp) < 3 and n >= 1000:
            tmp = '0' * (3 - len(tmp)) + tmp
        ans.append(tmp)

        n //= 1000
    ans = ans[::-1]
    if was and len(ans) == 1:
        ans = ["0"] + ans

    return ".".join(ans)

s = input() + "a"

data = []
last = 0
number = False
for i in range(len(s)):
    if "a" <= s[i] and s[i] <= "z":
        if number:
            number = False
            data.append(s[last:i])
        continue
    if not number:
        last = i
        number = True

nums = [fr(i) for i in data]

print(to(sum(nums)))


def get_down(i):
    if len(i) > 3 and i[-3] == '.':
        return int(i[-2:])
    return 0

def get_up(ans):
    if len(ans) > 3 and i[-3] == '.':
        ans = ans[:-3]
    ans = ans.replace('.', '')
    return int(ans)

def modify(up, down=0):
    ans = ''
    f = (up == 0)
    while up != 0:
        ans = str(up % 1000).rjust(3, '0') + '.' + ans
        up //= 1000
    ans = ans.lstrip('0')
    if down == 0:
        ans = ans[:-1]
    else:
        down = str(down).rjust(2, '0')
        ans += down
    if (f):
        ans = '0.' + ans
    return ans

s = input().strip()
numb = []
cur = ''
f = 0
for i in s:
    if '0' <= i <= '9':
        f = 1
        cur += i
    elif i == '.':
        cur += i
    elif 'a' <= i <= 'z' or 'A' <= i <= 'Z':
        f = 0
        if (cur):
            numb.append(cur)
            cur = ''
if cur:
    numb.append(cur)
    cur = ''
ans_up = 0
ans_down = 0
for i in numb:
    #print(i, get_up(i), get_down(i))
    ans_up += get_up(i)
    ans_down += get_down(i)
ans_up += ans_down // 100
ans_down %= 100
print(modify(ans_up, ans_down))


s = input()
c = set()
c.add('1')
c.add('2')
c.add('3')
c.add('4')
c.add('5')
c.add('6')
c.add('7')
c.add('8')
c.add('9')
c.add('0')
c.add('.')

ans = []
j = 0
st = ''
for i in range(len(s)):
    if s[i] in c:
        st += s[i]
    elif len(st) > 0:
        ans.append(st)
        st = ''
x = 0
ans.append(st)
for i in range(len(ans)):
    if len(ans[i]) < 3:
        ans[i] += '.00'
    if ans[i][-3] != '.':
        ans[i] += '.00'
cc = set()
cc.add('1')
cc.add('2')
cc.add('3')
cc.add('4')
cc.add('5')
cc.add('6')
cc.add('7')
cc.add('8')
cc.add('9')
cc.add('0')
pp =''
pk = 0
pr = 0
for i in range(len(ans)):
    for j in range(len(ans[i]) - 1, - 1, -1):
        if ans[i][j] == '.':
            x = j
            break
    p1 = ans[i][:x]
    p2 = ans[i][x + 1:]
    for ii in range(len(p1)):
        if p1[ii] in cc:
            pp += p1[ii]
    pr += int(pp)
    pp = ''
    pk += int(p2)
while pk > 99:
    pk -= 100
    pr += 1
pk = str(pk)
if len(pk) < 2:
    pk = '0' + pk
answer = str(pr) + '.' + pk
j = answer.index('.')
q = 0
for i in range(j, -1, -1):
    if q == 2:
        answer = answer[:i] + '.' + answer[i:]
        q = 0
    elif answer[i] != '.':
        q += 1
if answer[-1] == '0' and answer[-2] == '0' and answer[-3] == '.':
    answer = answer[:-3]
if answer[0] == '.':
    answer = answer[1:]
print(answer)

"""
        ans[j] = ans[j] * 10 + int(s[i])
    elif s[i] == '.':
        ans[j] *= 100"""


s = input()
ms = ['']
dct = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'}
p = 0
for i in s:
    if i in dct:
        ms[-1] += i
        p = 1
    else:
        if p:
            ms.append('')
            p = 0
rub = 0
kop = 0
if ms[0] == '':
    ms = []
for i in ms:
    box = i.split('.')
    l = len(box)
    a = 0
    b = 0
    p = 0
    for j in range(l - 1, -1, -1):
        if len(box[j]) == 2 and j == l - 1:
            b = int(box[j])
            p = 1
        else:
            a += int(box[j]) * (1000 ** (l - 1 - j - p))
    rub += a
    kop += b
rub += kop // 100
kop %= 100

s = str(rub)
l = len(s)
d = l % 3
ret = ''
ind = 0
if d:
    ind = d
    for i in range(d):
        ret += s[i]
    ret += '.'
cnt = 0
for i in range(ind, l):
    ret += s[i]
    cnt += 1
    cnt %= 3
    if not cnt:
        ret += '.'
if kop:
    if kop < 10:
        ret += '0'
    ret += str(kop)
    print(ret)
else:
    l = len(ret)
    for i in range(0, l - 1, 1):
        print(ret[i], end = '')


from decimal import Decimal
check = input()
check = check + 'a'
bukvi = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f' ,'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']
flag = 0
number = []
numbers = []
for symvol in check:
    if flag == 0:
        if symvol not in bukvi:
            flag = 1
    if flag == 1:
        if symvol not in bukvi:
            number += symvol
        else:
            numbers += [number]
            number = []
            flag = 0
ans = 0
for num in numbers:
    integ = []
    for i in range(len(num)):
        if num[i] != '.':
            integ += num[i]
        else:
            if i == len(num) - 3:
                integ += [num[i]]
    ans += Decimal(''.join(integ))
ans = str(ans)
if len(ans) >3 and ans[-1] == ans[-2] == '0' and ans[-3] == '.':
    ans = ans[:-3]
res = []
cnt = 0
if len(ans) > 3 and ans[-3] == '.':
    for i in range(len(ans) - 4, -1, -1):
        if cnt == 3:
            res += ['.']
            cnt = 0
        res += ans[i]
        cnt += 1
    res.reverse()
    res += ans[-3:]
else:
    for i in range(len(ans) - 1, -1, -1):
        if cnt == 3:
            res += ['.']
            cnt = 0
        res += ans[i]
        cnt += 1
    res.reverse()
print(''.join(res))


import re
o=input
C=len
E=float
F=int
d=print
U=sum
S=re.findall
l=o()
e=S("[\d\.]+",l)
def p(u):
 u=u.split('.')
 if C(u[-1])==2 and C(u)>1:
  G=u[-1]
  return E("".join(u[:-1])+"."+G)
 else:
  return F("".join(u))
def V(flo):
 if F(flo)==flo:
  return '{:,}'.format(F(flo)).replace(',','.')
 else:
  return '{:,.2f}'.format(flo).replace(',','.')
e=[p(num)for num in e]
d(V(U(e)))


s = str(input())
s = s[::-1]

current = ""
answer = 0

for el in s:
    if '9' >= el >= '0':
        current += el
    elif el == '.':
        if len(current) == 2:
            current += '.'
    else:
        if current != '':
            answer += float(current[::-1])
            current = ''

temp = "%.2f" % answer
if temp[len(temp) - 2:] != '00':
    temp_2 = temp[:len(temp) - 3][::-1]
    temp = temp[len(temp) - 2:]
    parts = []
    current = ""
    for i in range(len(temp_2)):
        current += temp_2[i]
        if len(current) == 3:
            parts.append(current[::-1])
            current = ''
    if current != '':
        parts.append(current[::-1])
    print(*parts[::-1], sep='.', end='.')
    print(temp)

else:
    temp_2 = str(int(answer))[::-1]
    parts = []
    current = ""
    for i in range(len(temp_2)):
        current += temp_2[i]
        if len(current) == 3:
            parts.append(current[::-1])
            current = ''
    if current != '':
        parts.append(current[::-1])
    print(*parts[::-1], sep='.')


"""
Codeforces Contest Good Bye 2014 Contest Problem A

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    n,t = read()
    a = read()
    c = 1
    while c < t:
        c += a[c-1]
    if c == t:
        print("YES")
    else:
        print("NO")

#################################################### HELPERS

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())


n, t = map(int, input().split())
arr = list(map(int, input().split()))
cur = 0
was = False
while cur < n:
	try:
		cur = cur+arr[cur]
		if(cur == t-1):
			was = True
	except:
		break
if(was):
	print('YES')
else:
	print('NO')


n, t = map(int, input().split())
a, cur = [0] + [int(x) for x in input().split()], 1
while cur < t:
    cur += a[cur]
print('YES' if cur == t else 'NO')


n,t=map(int,input().split())
a=list(map(int,input().split()))
can=[0 for _ in range(n)]
can[0]=1
for i in range(n-1):
  if can[i]:
    can[i+a[i]] = 1
print("YES" if can[t-1] else "NO")


n, t = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
p = 1
while p < t:
    p += a[p-1]
if p == t:
    print("YES")
else:
    print("NO")


#input
n,t=map(int,input().split())
a=[int(x) for x in input().split()]

#variables
p=1

#main
while p<=t:
	if p==t:
		print('YES')
		quit()
	p+=a[p-1]

#output
print('NO')


n,t = list(map(int, input().split()))
l = input().split()
for i in range(n-1):
    l[i] = int(l[i])
l = [0]+l
now = 1
while 1:
    now += l[now]
    if now > t:
        ans = 0
        break
    if now == t:
        ans = 1
        break

if ans == 0:
    print("NO")
else:
    print("YES")


n,m=input().split(' ')
n=int(n)
m=int(m)
seq=[1]
a=input()
line=a.split(' ')
c=1
while c!=n:
    c+=int(line[c-1])
    seq.append(c)
if m in seq:
    print("YES")
else:
    print("NO")


line = input().split()
n = int(line[0])
t = int(line[1])

line = input().split()
arr = [int(num) for num in line]
n = 0
while n < t - 1:
    n += arr[n]

if n == t - 1:
    print('YES')
else:
    print('NO')


import sys

nums = [int(x) for x in sys.stdin.readline().split(" ")]
a = [int(x) for x in sys.stdin.readline().split(" ")]

t = nums[1]

curr = 1
while curr < t:
	curr += a[curr-1]
if curr == t:
	print("YES")
else:
	print("NO")


__author__ = 'Rakshak.R.Hegde'
"""
Created on Dec 30 2014 PM 08:30

@author: Rakshak.R.Hegde
"""

def mint(): return map(int, input().split())

n, t = mint()
a = list(mint())
curr = 1
while curr < t:
    curr = curr + a[curr - 1]
print('YES' if curr == t else 'NO')


import sys

def main():
    n,t = tuple([int(y) for y in input().split()])
    a = [int(x) for x in input().split()]
    c = 1
    while True:
        c = c + a[c - 1]
        if c == t:
            print("YES")
            return
        elif c > t:
            print("NO")
            return
    print("NO")

def __starting_point():
    main()

__starting_point()


__author__ = 'Daniil'
n,t = list(map(int,input().split()))

a = list(map(int,input().split()))
i=0
while i!=t-1:
    i+=a[i]
    if i>t-1:
        print('NO')
        quit()
print('YES')


def ans():
    n, t= [int(i) for i in input().split()]
    a= [0]
    a+= [int(i) for i in input().split()]
    #print(a)

    ans= 1
    i= 1
    while True:
        ans+= a[i]
        i= ans
        if ans== t:
            print("YES")
            return

        if i> t:
            print("NO")
            return

ans()


n, t = (int(i) for i in input().split())
portals = [int(i) for i in input().split()]
home = 1
while True:
    if home == t:
        print('YES')
        break
    elif home > t:
        print('NO')
        break
    home += portals[home-1]


n, t = map(int, input().split())
a = list(map(int, input().split()))
pos = 1
while (pos < t): pos += a[pos-1]
print(('NO', 'YES')[pos == t])


n, t = list(map(int, input().split()))
t = t - 1
j = [int(x) for x in input().split()]

cur = 0
while True:
    if cur > t:
        print('NO')
        break
    cur += j[cur]
    if cur == t:
        print('YES')
        break


n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
current = 1
while current < t:
    current = current + a[current-1]

if current == t:
    print('YES')
else:
    print('NO')


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

current = 0

while current < t - 1:
    current = a[current] + current

print('YES' if current == t - 1 else 'NO')


def main():
	n, t = list(map(int, input().split()))
	a =[0] + list(map(int, input().split())) + [100000]
	d = {}
	for i in range(1,n):
		d[i] = i + a[i]
	reached = True
	i = 1
	count = 1
	while reached and count <= 100009:
		if i in d:
			if d[i] == t:
				print ('YES')
				return
			i = d[i]
			count += 1
		else:
			break
	print('NO')

def __starting_point():
	main()

__starting_point()


c = input().split()
n = int(c[0])  # ���������� �����
t = int(c[1])  # ����� ������
c = input().split()  # �������

for i in range(n-1):
    c[i] = int(c[i])

a = 1
while (a < n) and (a < t):
    a += c[a-1]

if a == t:
    print('YES')
else:
    print('NO')


import math,string,itertools,fractions,heapq,collections,re,array,bisect
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict

def main(n,t,a):
    j = 1
    while j<n:
        #print(j,a[j-1])
        j += a[j-1]
        if j==t:
            print("YES")
            return
    print("NO")

def main_input():
    n,t = list(map(int,input().split()))
    a = list(map(int,input().split()))
    main(n,t,a)

def __starting_point():
    main_input()

__starting_point()


n, t = input().rsplit(' ')
n, t = int(n), int(t)
lineWorld = [int(x) for x in input().rsplit(' ')]
start = 1
while start < t and start < n:
    oldStart = start
    start += lineWorld[start - 1]
    if start == oldStart:
        break
if start == t:
    print('YES')
else:
    print('NO')


n, t = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
now = 0
result = 0
while now < n - 1:
    now += a[now]
    if now + 1 == t:
        result = 1
if result:
    print('YES')
else:
    print('NO')


"""
Codeforces Round 244 Div 1 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

class InputHandlerObject(object):
    inputs = []

    def getInput(self, n = 0):
        res = ""
        inputs = self.inputs
        if not inputs: inputs.extend(input().split(" "))
        if n == 0:
            res = inputs[:]
            inputs[:] = []
        while n > len(inputs):
            inputs.extend(input().split(" "))
        if n > 0:
            res = inputs[:n]
            inputs[:n] = []
        return res
InputHandler = InputHandlerObject()
g = InputHandler.getInput

############################## SOLUTION ##############################
n = int(input())
a = [int(x) for x in g()]
ct = 0
res = 0
for i in a:
    ct += i
    if ct < 0:
        res += 1
        ct = 0
print(res)


n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
cntpols = 0
for i in range(len(a)):
    if a[i] == -1:
        if cntpols == 0:
            cnt += 1
        else:
            cntpols -= 1
    else:
        cntpols += a[i]
print(cnt)


n=int(input())
L=list(map(int,input().split()))
r=0
ans=0
for i in range(n):
    if(L[i]==-1):
        if(r==0):
            ans+=1
        else:
            r-=1
    else:
        r+=min(L[i],10)
print(ans)


n = int(input())
count = 0
free = 0

t = [int(x) for x in input().split()]
for i in t:
    if i > 0:
        free += i
    if i == -1:
        if free > 0:
            free -= 1
        else:
            count += 1

print(count)


n=int(input())
a=list(map(int,input().split()))
ans=0
t=0
for i in range(n):
    if a[i]>0:
        t+=a[i]
    else:
        if t==0:
            ans+=1
        else:
            t-=1
print(ans)


input()
cops = 0
count = 0
for e in map(int, str.split(input())):

    if e == -1:

        if cops == 0:

             count += 1

        cops = max(0, cops - 1)

    else:

        cops += e

print(count)


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

avail_cops = 0
crimes = 0

for event in seq:
	if event > 0:
		avail_cops += event
	else:
		if avail_cops == 0:
			crimes += 1
		else:
			avail_cops -= 1
print(crimes)


need_log = False
def log(*s):
  if need_log:
    print(*s)

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

x = 0
y = 0
for k in a:
  if k == -1:
    if y == 0:
      x += 1
    else:
      y -= 1
  else:
    y += k
print(x)


n = int(input())
A = list(map(int, input().split()))
c = 0
res = 0
for i in A:
    if i > 0:
        c += i
    elif c == 0:
        res += 1
    else:
        c -= 1
print(res)


n = int(input())
a = list(map(int, input().split()))
sv = 0
ans = 0
for i in range(n):
    if a[i] > 0:
        sv += a[i]
    else:
        k = -a[i]
        if k <= sv:
            sv -= k
        else:
            ans += (k - sv)
            sv = 0
print(ans)


n = int(input())
events = input().split()
untreated = 0
officers = 0
for i in range(len(events)):
    events[i]=int(events[i])
    if events[i]==-1:
        if officers>0:
            officers-=1
        else:
            untreated+=1
    else:
        officers+=events[i]
print(untreated)


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

police = 0
occur = 0

for i in range(n):
    police += events[i]
    if police < 0 :
        occur += 1
        police = 0
print(occur)


__author__ = 'Lipen'

def main():
	n = int(input())
	a = list(map(int, input().split()))
	now = 0
	answer = 0

	for x in a:
		if x == -1:
			if now>0:
				now-=1
			else:
				answer+=1
		else:
			now+=x

	print(answer)

main()


input()
res = 0
p = 0
for i in input().split():
    i = int(i)
    if i > 0:
        p += i
    elif p == 0:
        res += 1
    else:
        p -= 1
print(res)


n = int(input())
l = list(map(int, input().split()))
p, c = 0, 0

for i in l:
    if i > 0:
        p += i
    else:
        if p > 0:
            p -= 1
        else:
            c += 1

print(c)


#!/usr/bin/env python

from sys import stdin

stdin.readline()
cnt = 0
acc = 0
for i in map(int, stdin.readline().split()):
    if i == -1:
        if acc > 0:
            acc = acc - 1
        else:
            cnt = cnt + 1
    else:
        acc = acc + i
print(cnt)


n = int(input())
l = []
a = 0
s = input().split(' ')
if len(s) != n:
    while len(s) != n:
        print('Bad!')
        s = input().split(' ')
while a < len(s):
    l.append(int(s[a]))
    a += 1
count = 0
pm = 0
i = 1
if l[0] == -1:
    count += 1
else:
    i = 0
while i < len(l):
    if l[i] > 0:
       pm += l[i]
    if l[i] == -1:
        if pm > 0:
            pm -= 1
        else:
            count += 1
    i += 1
print(count)


n = int(input())
a = list(map(int,input().split()))
k = 0
pol = 0
for i in range(n):
    if a[i] < 0:
        if pol <= 0:
            k += 1
        else:
            pol -= 1
    else:
        pol += a[i]
print(k)


import sys

f = sys.stdin
n = int(f.readline())

s = f.readline().split()

total = 0
r = 0 # нерасследованные преступления
for j in s:
    d = int(j)
    if (d<0):
        if total==0:    r += 1
        else :          total -= 1
    else : total += d

print(str(r))


n = int(input())
a = input().split()

a = [int(i) for i in a]
l = 0
k = 0

for i in a:
	if i == -1:
		if l < 1:
			k += 1
		else:
			l -= 1
	else:
		l += i

print (k)


n = int(input())
police = 0
ans = 0
a = list(map(int, input().split()))
for i in range(n):
    q = a[i]
    if q < 0:
        if police > 0:
            police -= 1
        else:
            ans += 1
    else:
        police += q
print(ans)


n = int(input())
x = map(int, input().split())
k, res = 0, 0
for elm in x:
    if elm != -1: k += elm; continue
    if elm == -1 and k > 0: k -= 1
    else: res += 1
print(res)


input()
s = n = 0
for i in map(int, input().split()):
    s += i
    if s < 0:
        s = 0
        n += 1
print(n)


n = int(input())
A = input().split()
c = 0
p = 0
for i in range(n):
    if int(A[i]) > 0:
        p += int(A[i])
    else:
        if p > 0:
            p -= 1
        else:
            c += 1
print(c)


n = int(input())
a = map(int, input().split())
cnt = 0
sum = 0
for i in a:
    if i < 0 and sum <= 0:
        cnt += 1
    elif i > 0:
        sum += i
    elif i < 0 and sum > 0:
        sum += i
print(cnt)


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

for i in range(N):
    for j in range(N):
        if table[i][j] == 1:
            continue
        flg = False
        for s in range(N):
            for t in range(N):
                if table[i][j] == table[i][s] + table[t][j]:
                    flg = True
                    break
        if not flg:
            print("No")
            return
print("Yes")


I = lambda : map(int, input().split())
n, = I()
arr = []
for i in range(0, n):
    arr.append(list(I()))

for x in range(0, n):
    for y in range(0, n):
        if arr[x][y] != 1:
            found = False
            for s in range(0, n):
                for t in range(0, n):
                    if arr[x][y] == arr[x][s] + arr[t][y]:
                        found = True
            if not found:
                print("No")
                return
print("Yes")


def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(list(map(int, input().split())))
    for i in range(n):
        for j in range(n):
            e = a[i][j]
            if e == 1:
                continue
            else:
                fl = False
                for i1 in range(n):
                    for j1 in range(n):
                        if a[i1][j] + a[i][j1] == e:
                            fl = True
                            break
                    if fl:
                        break
                if fl:
                    continue
                else:
                    print('No')
                    return
    print('Yes')

main()


n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
ok = True
for i in range(n):
    for j in range(n):
        if a[i][j] != 1:
            check = False
            for k in range(n):
                for l in range(n):
                    if a[i][j] == a[i][k] + a[l][j]:
                        check = True
                    if check:
                        break
                if check:
                    break
            ok &= check
print("Yes" if ok else "No")


n = int(input())
s = []
for k in range(n):
    s.append([int(i) for i in input().split()])
t = 0
for i in range(n):
    for j in range(n):
        l = 0
        if s[i][j] !=1:
            for x in range(n):
                for y in range(n):
                    if s[i][x]+ s[y][j] == s[i][j]:
                        l = 1
            if not l:
                t = 1
if t:
    print("No")
else:
    print("Yes")


from sys import stdin, stdout

def main():
    n = int(stdin.readline())
    mat = []
    for i in range(n):
        mat.append(list(map(int, stdin.readline().split())))
    for i in range(n):
        for j in range(n):
            st = True
            for u in range(n):
                for k in range(n):
                    if mat[i][j] == 1 or mat[i][j] == mat[u][j] + mat[i][k]:
                        st = False
                        break
                if not st: break
            if st:
                return False
    return True

print('Yes' if main() else 'No')


import sys

def main():
    n = int(input())
    x = []
    for i in range(n):
        y = list(map(int,sys.stdin.readline().split()))
        x.append(y)

    for i in range(n):
        for j in range(n):
            if x[i][j] == 1:
                continue
            found = False
            for o in range(n):
                a = x[i][o]
                if o == j:
                    continue
                for p in range(n):
                    if p ==i:
                        continue
                    b = x[p][j]
                    if a+b == x[i][j]:
                        found = True
                        break
                if found:
                    break
            if not found:
                print("No")
                return
    print("Yes")

main()


n = int(input())
data = []
for i in range(n):
    data += [list(map(int, input().split()))]

for i in range(n):
    for j in range(n):
        if data[i][j] == 1:
            t = True
            continue
        t = False
        for k in range(n):
            for m in range(n):
                if data[i][k] + data[m][j] == data[i][j]:
                    t = True
                    break
        if not t:
            print("No")
            break
    if not t:
        break
if t:
    print("Yes")


def check(r, c, x):
    rtn = False
    rs = [a[r][i] for i in range(n) if i != c]
    cs = [a[i][c] for i in range(n) if i != r]
    for r in rs:
        for c in cs:
            if r + c == x:
                rtn = True
                break
    return rtn

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

ans = True
for i in range(n):
    for j in range(n):
        if a[i][j] != 1:
            ans &= check(i, j, a[i][j])

print('Yes' if ans else 'No')


def solve(g):
    for i in range(n):
        for j in range(n):
            if g[i][j] == 1:continue
            for p in range(n):
                for q in range(n):
                    if p == i or q == j:continue
                    if g[i][q] + g[p][j] == g[i][j]:break
                else:
                    continue
                break
            else:
                return "No"
    return "Yes"

n = int(input())

g = []

for i in range(n):
    g.append([int(item) for item in input().split()])

print(solve(g))


#! python3

def is_good(a, n, i, j):
    c = set([])
    for x in range(n):
        c.add(a[i][j] - a[i][x])
    for x in range(n):
        if a[x][j] in c:
            return True
    return False

n = int(input())
a = []
for _ in range(n):
    a.append([int(x) for x in input().strip().split(' ')])

good = True
for i in range(n):
    for j in range(n):
        if a[i][j] != 1 and not is_good(a, n, i, j):
            good = False
            break
if good:
    print("Yes")
else:
    print("No")


#!/usr/bin/env python3
import sys

def main():
    n = int(sys.stdin.readline())
    mat = [None for __ in range(n)]
    for indx in range(n):
        mat[indx] = list(map(int, sys.stdin.readline().split()))

    good = True
    for row in range(n):
        for col in range(n):
            if mat[row][col] == 1:
                continue
            else:
                good &= check_this_element(mat, row, col)
    if good:
        print("Yes")
    else:
        print("No")

def check_this_element(mat, row, col):
    n = len(mat)
    for _row in range(n):
        for _col in range(n):
            if mat[_row][col] + mat[row][_col] == mat[row][col]:
                return True
    return False

def __starting_point():
    main()

__starting_point()


#!/usr/bin/env python3
from sys import stdin, stdout

def rint():
    return list(map(int, stdin.readline().split()))
#lines = stdin.readlines()

def check(i, j):
    for r in range(n):
        for c in range(n):
           if a[i][c] + a[r][j] == a[i][j]:
               return 1
    return 0
n = int(input())
a = [[] for _ in range(n)]
for i in range(n):
    a[i] = list(rint())

for i in range(n):
    for j in range(n):
        if a[i][j] == 1:
            continue
        if check(i,j) == 0:
            print("No")
            return

print("Yes")


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

n = int(input())
matr = [list(int_input()) for i in range(n)]

good = True
for row in range(n):
    nums = set(matr[row])
    for col in range(n):
        num = matr[row][col]
        if num == 1:
            continue
        cur_good = False
        for i in range(n):
            cur_good |= num - matr[i][col] in nums
        good &= cur_good

print('Yes' if good else 'No')


#def proverka(b, k, m, p):
#  for i in range()

n = int(input())
a = []
for i in range(n):
    a.append([int(j) for j in input().split()])
flag = "Yes"
for i in range(n):
  for j in range(n):
    if(a[i][j] != 1):
      f = False
      for k in range(n):
        if(f):
          break
        for z in range(n):
          if(a[k][j] + a[i][z] == a[i][j]):
            f = True
          if(f):
            break
      if(not(f)):
        flag = "No"

print(flag)


n=int(input())
a=[[0]*n for i in range(n)]
f=True
d=True
for i in range(n):
    a[i]=list(map(int,input().split(" ")))
for i in range(n):
    for j in range(n):
        s=a[i][j]

        if s!=1:
            f = False
            for t in range(n):
                if t!=i:
                    x=s-a[t][j]
                    if x in a[i]:
                        f=True
        if f==False:
            d=False
if not d:
    print('No')
else:
    print('Yes')


n=int(input())
a=[]
for i in range(n):
	a.append(list(map(int,input().split())))
for i in range(n):
	for j in range(n):
		c=0
		if a[i][j]==1:
			continue
		for k in range(n):
			for l in range(n):
				if a[i][j]==a[i][k]+a[l][j]:
					c=1
					break
			if c:
				break
		if not c:
			print('No')
			return
print('Yes')


a = [list(map(int, input().split())) for i in range(int(input()))]
n = len(a)
for i in range(n):
    for j in range(n):
        if a[i][j] != 1:
            found = False
            for i2 in range(n):
                for j2 in range(n):
                    if a[i][j] == a[i][j2] + a[i2][j]:
                        found = True
            if not found:
                print('No\n')
                return
print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(n):
		if a[i][j]==1:
			continue
		val = False
		for k in range(n):
			for l in range(n):
				if (a[i][k]+a[l][j]==a[i][j]):
					val = True
		if val==False:
			print("No")
			return
print("Yes")


from itertools import *
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
for i,j in product(list(range(n)),list(range(n))):
    x=f[i][j]
    if x==1: continue
    if not any(a+b==x for a, b in product(chain(f[i][:j], f[i][j+1:]),(f[k][j] for k in chain(list(range(i)), list(range(i+1,n)))))):
        print("No")
        return
print("Yes")


def fin(s, row, column):
	for i in row:
		for j in column:
			if i+j == s:
				return True
	return False

n = int(input())
a = []
for i in range(n):
	k = input().split(' ')
	k = list(map(int,k))
	a.append(k)

ans = True

for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		else:
			s = a[i][j]
			row = a[i]
			column = []
			for t in range(n):
				column.append(a[t][j])
			ans = fin(s,row,column)
			if ans == False:
				break
	if ans == False:
		break

if ans==True:
	print("Yes")
else:
	print("No")


import sys

def is_good(lab):
  n = len(lab)
  for i in range(n):
    for j in range(n):
      v = lab[i][j]
      if v > 1 and all(x + y != v for x in lab[i] for y in (lab[k][j] for k in range(n))):
        return False
  return True

n = int(input())

lab = [[int(i) for i in input().split()] for _ in range(n)]

print('Yes' if is_good(lab) else 'No')


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

out = False
for i, row in enumerate(tbl):
    for j in range(len(row)):
        out = False
        e = row[j]
        if e == 1:
            out = True
            continue
        for j1, e1 in enumerate(row):
            if j1 != j:
                for i1 in range(n):
                    if e1 + tbl[i1][j] == e:
                        out = True
                        break
            if out:
                break
        if not out:
            print('No')
            break
    if not out:
        break
if out:
    print('Yes')


from collections import defaultdict, Counter
N = int(input())
B = list(map(int, input().split()))
C = list(map(int, input().split()))
Edge = defaultdict(list)
Edc = defaultdict(int)
for b, c in zip(B, C):
    if b > c:
        print(-1)
        return
    Edge[b].append(c)
    Edc[(b, c)] += 1
    if b != c:
        Edge[c].append(b)
Deg = Counter(B + C)
eul = 0
st = []
for k, v in list(Deg.items()):
    if v % 2:
        eul += 1
        st.append(k)
s, e = B[0], B[0]
if eul and eul != 2:
    print(-1)
    return
if eul:
    s, e = st[0], st[1]
ans = [s]
while True:
    vn = ans[-1]
    while True:
        vf = Edge[vn][-1]
        if Deg[vf] != 0 and Edc[(vn, vf) if vn < vf else (vf, vn)]:
            break
        Edge[vn].pop()
    vf = Edge[vn].pop()
    Deg[vn] -= 1
    Deg[vf] -= 1
    Edc[(vn, vf) if vn < vf else (vf, vn)] -= 1
    ans.append(vf)
    if not Deg[vf]:
        break
loop = defaultdict(list)
for a in ans:
    if Deg[a]:
        loopa = [a]
        while Deg[a]:
            vn = loopa[-1]
            while True:
                vf = Edge[vn][-1]
                if Deg[vf] != 0 and Edc[(vn, vf) if vn < vf else (vf, vn)]:
                    break
                Edge[vn].pop()
            vf = Edge[vn].pop()
            Deg[vn] -= 1
            Deg[vf] -= 1
            Edc[(vn, vf) if vn < vf else (vf, vn)] -= 1
            loopa.append(vf)
            if not Deg[vf]:
                break
        loop[a] = loopa
Ans = []
for a in ans:
    if loop[a]:
        Ans.extend(loop[a])
        loop[a] = []
    else:
        Ans.append(a)
if len(Ans) != N:
    print(-1)
    return
print(*Ans)


import sys

n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
b = a[:]
C = [0] * n
x = [0] * n
for i in range (0, 40):
    for j in range (0, n):
        x[j] = b[j] % 2
        b[j] = b[j] // 2
    if sum(x) == 1:
        for j in range (0, n):
            if x[j] == 1:
                C[j] = C[j] + 2 ** i
l = C.index(max(C))
print(" ".join(list(map(str, [a[l]]+a[0:l]+a[l+1:]))))


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

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

    for j in range(32, -1, -1):
        flg = 0
        for i, a in enumerate(A):
            if a >> j & 1:
                flg += 1
                idx = i
                if flg == 2:
                    break
        if flg == 1:
            A[0], A[idx] = A[idx], A[0]
            print(*A)
            return
    print(*A)

def __starting_point():
    main()

__starting_point()


import sys

# inf = open('input.txt', 'r')
# reader = (line.rstrip() for line in inf)
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

n = int(input())
a = list(map(int, input().split()))
digits = [[] for _ in range(32)]
for i, val in enumerate(a):
    shift = 0
    while val > 0:
        if val & 1:
            digits[shift].append(i)
        val >>= 1
        shift += 1

for i in reversed(list(range(32))):
    if len(digits[i]) == 1:
        idx = digits[i][0]
        a[0], a[idx] = a[idx], a[0]
        break

print(*a)

# inf.close()


n = int(input())
a = [int(i) for i in input().split()]
once = 0
twice = 2**64
for i in a:
    twice |= (once & i)
    once |= i
a = sorted([(i & ~twice,i) for i in a],reverse=True)
a = [j for i,j in a]
print(*a)