l=[]
for i in range(4):
    l.append(input())
ans=0
a=b=c=d=''
for i in range(4):
    for j in range(4):
        if j<2:
            a=l[i][j]+l[i][j+1]+l[i][j+2]
        if i<2:
            b=l[i][j]+l[i+1][j]+l[i+2][j]
        if i<2 and j<2:
            c=l[i][j]+l[i+1][j+1]+l[i+2][j+2]
        if i<2 and j>1:
            d=l[i][j]+l[i+1][j-1]+l[i+2][j-2]
        for k in (a,b,c,d):
            if k.count('.')==1 and k.count('x')==2:
                ans=1
print('YES' if ans else 'NO')


import sys
n=int(sys.stdin.readline().strip())
word=sys.stdin.readline().strip()
vow=set(['a', 'e', 'i', 'o','u','y'])
new_w=[]
idx=0

while idx<len(word):
    if word[idx] not in vow:
        new_w+=[word[idx]]
        idx+=1
        continue
    if idx<len(word):
        i=idx+1
        new_w+=[word[idx]]
        while i<len(word):
            if word[i] in vow:
                i+=1
            else:
                break
        idx=i

print "".join(new_w)


from math import sqrt

def genprimes(limit):
    lim = limit // 6
    sieve = [False, True, True] * lim
    lim = lim * 3 - 1
    for i, s in enumerate(sieve):
        if s:
            p, pp = i * 2 + 3, (i + 3) * i * 2 + 3
            le = (lim - pp) // p + 1
            if le > 0:
                sieve[pp::p] = [False] * le
            else:
                break
    sieve[0] = sieve[3] = True
    res = [i * 2 + 3 for i, f in enumerate(sieve) if f]
    for i, p in enumerate((2, 3, 5, 7)):
        res[i] = p
    while res[-1] >= limit:
        del res[-1]
    return res

def main():
    n, res = int(input()), 1
    for p in genprimes(int(sqrt(n)) + 12):
        if not n % p:
            res *= p
            while not n % p:
                n //= p
            if n == 1:
                break
    print(res * n)

if __name__ == '__main__':
    main()


from sys import stdin
rr = lambda: stdin.readline().strip()
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
def rry(N = None, f = rri):
    for i in xrange(N or rri()):
        yield f()

debug=0
if debug:
    fi = open('t.txt','r')
    rr = lambda: fi.readline().replace('\n','')

N = rri()
A = rrm()
BIG = 1000050
B = [False] * BIG
for x in A:
    B[x] = True

#add 25-K people
to_add = 25-N
if to_add:
    for x in xrange(1, BIG):
        if not B[x]:
            B[x] = True
            to_add -= 1
            if to_add == 0: break

invited = 0
ans = 0
for x in xrange(1, BIG):
    if B[x]:
        invited += 1
        if invited == 25: break
    else:
        ans += 1
print ans


import sys

t = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

n = 0
datas = None

def test(i):
	global n, datas, t
	for j in range(n):
		#print "datas[%2d]: %2d, t[%2d]: %2d"%(j, datas[j], i, t[i])
		if datas[j] != t[i]:
			return False
		i = (i+1) % 30
	return True

if __name__ == "__main__":
	n = int(raw_input())
	datas = [int(x) for x in raw_input().split()]
	if n == 1:
		if datas[0] == 15:
			print "DOWN"
		elif datas[0] == 0:
			print "UP"
		else:
			print "-1"
		sys.exit(0)

	i = datas[0]
	j = 0
	for j in range(29, -1, -1):
		if t[j] == datas[0]:
			break
	#print "datas[0]: %2d, t[i]: %2d, t[j]: %2d"%(datas[0], t[i], t[j])

	if not test(i) and not test(j):
		print "-1"
		sys.exit(0)

	if datas[n-1] == 0:
		print "UP"
		sys.exit(0)

	if datas[n-1] == 15:
		print "DOWN"
		sys.exit(0)

	delta = datas[n-1] - datas[n-2];
	print "UP" if delta > 0 else "DOWN"


vp = int(input())
vd = int(input())
t = int(input())
f = int(input())
c = int(input())
currentD = 0
ans = 0

if vp >= vd:
    ans = 0
else:
    currentD = vp * t

    while currentD < c:
        currentD += (vp * currentD) / (vd - vp)

        if currentD >= c:
            break

        ans += 1
        currentD += (f + currentD / vd) * vp

print(ans)


"""
Beautiful is better than ugly.
    Explicit is better than implicit.
Simple is better than complex.
    Complex is better than complicated.
Flat is better than nested.
    Sparse is better than dense.

    * Readability counts *

 // Author : raj1307 - Raj Singh
 // Date   : 21.06.19

"""

from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    #for _ in range(ii()):

    n=ii()

    if n==1:
        print(1)
    else:

        r=1
        ans=1
        for i in range(1,n):

           ans+=i*4

        print(ans)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()
    #dmain()


n = input()
if n == 0:
    print 1
else:
    n = n%4
    if n == 1:
        print 8
    elif n == 2:
        print 4
    elif n==3:
        print 2
    elif n == 0:
        print 6


import sys
n,k = map(int,input().split())
string = input()
gpos = string.index('G')
tpos = string.index('T')

no = 0
if gpos < tpos:
    while gpos != tpos:
        gpos += k
        if gpos >= n or gpos > tpos or string[gpos] == '#':
            no = 1
            break

else:
    while gpos != tpos:
        gpos -= k
        if gpos < 0 or gpos < tpos or string[gpos] == '#':
            no = 1
            break
if no == 0:
    print('YES')
else:
    print('NO')


import os

#first_line = map(int,raw_input().split())
n = int(raw_input())
times = n/3
remaining = n%3
ans = times*2
if remaining!=0:
	ans+=1
print ans


s = input()
vowels = 'aeiouyAEIOUY'
if s.split()[-1] == '?':
    if s.split()[-2][-1] in vowels:
        print('YES')
    else:
        print('NO')
else:
    if s.split()[-1][:-1][-1] in vowels:
        print('YES')
    else:
        print('NO')


I=input
a=I().split()
def f(s,z):
	if not z:return int(s[0])
	m=10**99
	for i in s:
		t=s[::];t.remove(i)
		for j in t:k=t[::];k.remove(j);m=min(m,f(k+[str(eval(i+z[0]+j))],z[1:]))
	return m
print(f(a,I().split()))


z,x,c=map(int,input().split())
if (z+x)>c:
	if x>z and x>c:
		d=2*(z+c)
	elif z>x and z>c:
		d=2*(x+c)
	else:
		d=x+z+c
if z+x<=c:
	d=2*z+2*x
print(d)


n, dic = int(input()), {}
s = input()
for i in range(1, n):
    try:dic[s[i-1:i+1]]+=1
    except:dic[s[i-1:i+1]]=1
print(max(dic.keys(), key=dic.get))


#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    from math import gcd
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    def gcd(x, y):
        """gcd(x, y) -> int
        greatest common divisor of x and y
        """
        while y:
            x, y = y, x % y
        return x

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    n, k = map(int, input().split())
    print(int(math.ceil((2 * n) / k) + math.ceil((5 * n) / k) + math.ceil((8 * n) / k)))

if __name__ == '__main__':
    sync_with_stdio(False)
    main()


a=list(map(int,input().split()))
a.sort()
if a[0]+a[-1]==a[1]+a[2] or a[0]+a[1]+a[2]==a[3]:
    print('YES')
else:
    print('NO')


import math
# import bisect
import sys
# from collections import Counter
input = sys.stdin.readline
def inp():
	return(int(input()))
def inlt():
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(s[:len(s)-1])
def invr():
	return(map(int,input().split()))
def print_fract(p,q):
	g = math.gcd(p,q)
	p//=g
	q//=g
	print(str(p)+"/"+str(q))
# list1, list2 = zip(*sorted(zip(list1, list2)))
a, b, c, d = invr()
if (a >= c and b >= d) or (a < c and b < d):
	fl = True
	area = 0
	if d*(a/c) <= b:
		area = d*a*a/c
	if c*(b/d) <= a:
		if area < c*b*b/d:
			fl = False
			p = (a*d) - (b*c)
			q = a*d
			print_fract(p,q)
	if fl:
		p = (b*c) - (a*d)
		q = b*c
		print_fract(p,q)
elif a >= c and b < d:
	p = (a*d) - (b*c)
	q = a*d
	print_fract(p,q)
elif a < c and b >= d:
	p = (b*c) - (a*d)
	q = b*c
	print_fract(p,q)


def pow3(N, M):
  if N == 0:
    return 0
  if N == 1:
    return 3 % M
  res = pow3(N / 2, M) ** 2
  if N % 2 == 1:
    res *= 3
  return res % M

def solve(N, M):
  return (pow3(N, M) + M - 1) % M

import sys
input = sys.stdin
N, M = map(int, input.readline().split())
print solve(N, M)


import itertools

print(sum(map(lambda x:(x==('Q','A','Q')), itertools.combinations(input(),3))))


class CodeforcesTask980ASolution:
    def __init__(self):
        self.result = ''
        self.necklace = ''

    def read_input(self):
        self.necklace = input()

    def process_task(self):
        try:
            if not self.necklace.count("-") % self.necklace.count("o"):
                self.result = "YES"
            else:
                self.result = "NO"
        except ZeroDivisionError:
            self.result = "YES"

    def get_result(self):
        return self.result

if __name__ == "__main__":
    Solution = CodeforcesTask980ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())


(n, m) = map(int, input().split())
if n <= m:
	print(n)
else:
	aM = m
	n -= m
	(l, r) = (0, int(2e9))
	while l < r:
		m = (l + r) // 2;
		val = m * (m+1) // 2;
		if val >= n:
			r = m
		else:
			l = m+1
	print(l + aM)


'''input
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv
'''
pos = 12
g = ['o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a',
     'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n']

s = raw_input()
ans, p1 = 0, -1
for x in s:
    for y in xrange(0, pos):
        if x == g[y]:
            p1 = y
            break
    for y in xrange(pos, len(g)):
        if x == g[y]:
            p1 = y
            break
    ans += min(abs(pos - p1), 26 - abs(pos - p1))
    pos = p1
print ans


#!/usr/bin/env python3

if __name__ == "__main__":
	n = int(input())
	fingers = list(map(int, input().split()))
	total_fingers = 0
	for finger in fingers:
		total_fingers = (total_fingers + finger)
	m = 0
	unwanted_sums = list(range(1,5*n+6,n+1))
	#print(unwanted_sums)
	for i in range(1, 6):
		if (total_fingers + i) not in unwanted_sums:
			#print(i)
			m += 1
	#print("----------" + str(m) + "-------------")
	print(m)


import sys

input = sys.stdin.readline

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

class Combinations:
    def __init__(self, max_num, mod):
        self.mod = mod
        self.factorials = [1]
        for i in range(1, max_num + 1):
            self.factorials.append((self.factorials[-1] * i) % mod)
        self.invs = [pow(self.factorials[-1], mod - 2, mod)]
        for i in reversed(range(1, max_num + 1)):
            self.invs.append(self.invs[-1] * i % mod)
        self.invs = self.invs[::-1]

    def __call__(self, n, k):
        return self.factorials[n] * self.invs[k] * self.invs[n - k] % self.mod

n, m = read_i()
MOD = 10**9 + 7
combinations = Combinations(max(n, m), MOD)
res = 0
for i in range(n // 2 + 1):
    res += combinations(n - i, i)
    res %= MOD
for i in range(m // 2 + 1):
    res += combinations(m - i, i)
    res %= MOD
res = 2 * (res - 1 + MOD) % MOD
print(res)


a, d, m = map(int, raw_input().split())
g, p, b = map(int, raw_input().split())
tot = g + p + b
ans = "YES"
if g < a:
    ans = "NO"
else:
    g -= a
if  g + p < d:
    ans = "NO"
if tot - a - d  < m:
    ans = "NO"
print ans


r,c=map(int,input().split())
a=[input() for i in range(r)]
print(r*c-len([1 for i in a if 'S' in i])*len([1 for i in zip(*a) if 'S' in i]))


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

def dividers(n):
    divs = []
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            divs.append(i)
            while n % i == 0:
                n //= i
        i += 1
    if n != 1:
        divs.append(n)
    return divs

def h(n, p):
    result = 0
    pi = p
    while n >= pi:
        result += n // pi
        pi *= p
    return result

ans = 1
for p in dividers(x):
    ans *= pow(p, h(n, p), 10 ** 9 + 7)
    ans %= (10 ** 9 + 7)
print(ans)


def main():
   n, s  = map(int,input().split())
   a = BS(1,n,s)
   print(n-a+1)

def BS(f,l,d):
    if(f>l):
        return f
    mi = (f+l)//2
    if(mi-sum([int(j) for j in str(mi)]) >= d):
        return BS(f,mi-1,d)
    else:
        return BS(mi+1,l,d)

if __name__ == "__main__":
    main()


"""."""
stor_size, steps_nr = (int(x) for x in input().split())
storage = sorted(list(input()))

best_weight = 1e+9
for start_idx in range(stor_size):
    curr_weight = 0
    curr_last = 'A'
    length = 0
    for letter in storage[start_idx:]:
        if ord(letter) - ord(curr_last) >= 2:
            curr_weight += ord(letter) - ord('a') + 1
            curr_last = letter
            length += 1
        if length == steps_nr:
            break
    if length == steps_nr:
        best_weight = min(curr_weight, best_weight)
if best_weight == 1e+9:
    best_weight = -1
print(best_weight)


s = str(input())
a = str('Danil')
b = str('Olya')
c = str('Slava')
d = str('Ann')
f = str('Nikita')
k = 0
if s.find(a) == s.rfind(a) and s.rfind(a) != -1:
    k = k + 1
elif s.find(a) != s.rfind(a):
    k = k + 10
if s.find(b) == s.rfind(b) and s.rfind(b) != -1:
    k = k + 1
elif s.find(b) != s.rfind(b):
    k = k + 10
if s.find(c) == s.rfind(c) and s.rfind(c) != -1:
    k = k + 1
elif s.find(c) != s.rfind(c):
    k = k + 10
if s.find(d) == s.rfind(d) and s.rfind(d) != -1:
    k = k + 1
elif s.find(d) != s.rfind(d):
    k = k + 10
if s.find(f) == s.rfind(f) and s.rfind(f) != -1:
    k = k + 1
elif s.find(f) != s.rfind(f):
    k = k + 10
if k == 1:
    print('YES')
else:
    print('NO')


import sys
input=sys.stdin.readline
n=input()
l=list(map(int,input().split()))
m=list(map(int,input().split()))
print("YNeos"[sum(l)<sum(m)::2])


input()
a = input().split()
b = set(a)
c = []

for i in a[::-1]:
    if i in b:
        c.insert(0, i)
        b.remove(i)

print(len(c))
print(" ".join(c))


c1=int(input())
c2=int(input())
c3=int(input())
c4=int(input())

if 1:
    if c3>0:

        if c1>0 and c1==c4:
            print("1")
        else:
            print("0")
    else:
        if c1==c4:
            print("1")
        else:
            print("0")


str = input()
ans = 'YES'
if str[0] == '1':
    for i in range(1, len(str) - 1):
        if str[i] != '1' and str[i] != '4':
            ans = 'NO'
            break
        if str[i] == '4' and str[i - 1] == '4' and str[i + 1] != '1':
            ans = 'NO'
            break
    if str[-1] != '1' and str[-1] != '4':
        ans = 'NO'
    if str[-1] == '4' and str[-2] == '4' and str[-3] != '1':
        ans = 'NO'
else:
    ans = 'NO'
print(ans)


def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	return ans

def binary_search(n, x, idx):
	l = 0
	r = n
	ans = 1
	bigger = 0
	smaller = 0
	while l < r:
		mid = (l + r) // 2
		if mid > idx:
			ans *= (n - x - bigger)
			ans %= mod
			bigger += 1
			r = mid
		elif mid < idx:
			l = mid + 1
			ans *= (x - 1 - smaller)
			ans %= mod
			smaller += 1
		else:
			l = mid + 1
	ans *= fact(n - smaller - bigger - 1)
	return ans % mod

# if ar[mid] <= x:
# 	l = mid + 1
# else:
# 	r = mid

mod = 1000000007
n, x, pos = map(int, input().split())
print(binary_search(n, x, pos))


a = input()
s = input()
z = ''
k1 = '""qwertyuiop""'
k2 = '""asdfghjkl;""'
k3 = '""zxcvbnm,./""'
for i in s:
    if a == 'R':
        if i in k1:
            z += k1[k1.find(i)-1]
        elif i in k2:
            z += k2[k2.find(i)-1]
        elif i in k3:
            z += k3[k3.find(i)-1]
    elif a == 'L':
        if i in k1:
            z += k1[k1.find(i)+1]
        elif i in k2:
            z += k2[k2.find(i)+1]
        elif i in k3:
            z += k3[k3.find(i)+1]
print(z)


cache = [[0 for i in range(3)] for j in range(101)]
n = input()
state = [0]
state += map(int,raw_input().split())
for i in range(1,n+1) :
	if state[i] == 0 :
		cache[i][0] = min(cache[i-1])+1
		cache[i][1] = 987654321
		cache[i][2] = 987654321
	elif state[i] == 1 :
		cache[i][0] = min(cache[i-1])+1
		cache[i][1] = 987654321
		cache[i][2] = min(cache[i-1][0],cache[i-1][1])
	elif state[i] == 2 :
		cache[i][0] = min(cache[i-1])+1
		cache[i][1] = min(cache[i-1][0],cache[i-1][2])
		cache[i][2] = 987654321
	elif state[i] == 3 :
		cache[i][0] = min(cache[i-1])+1
		cache[i][1] = min(cache[i-1][0],cache[i-1][2])
		cache[i][2] = min(cache[i-1][0],cache[i-1][1])
print min(cache[n][0],cache[n][1],cache[n][2])


t=map(int,raw_input().split());
m=map(int,raw_input().split());
L=[];S=[];
for i in xrange(t[0]-1):
    L.append(m[i+1]-m[i]);
for i in xrange(t[0]-2):
    S.append(m[i+2]-m[i]);
print max(max(L),min(S));


a, b = map(int,raw_input().split())
f = 0
d = 0
s = 0
for i in range(1,7):
	if(abs(i-a)<abs(i-b)):
		f = f+1
	elif(abs(i-a)==abs(i-b)):
		d = d+1
	else:
		s = s+1
print f,
print d,
print s,


from collections import deque
def valid(x,y):
    if x>=9 or y>=9 or x<0 or y<0:
        return 0
    elif v1[x][y]==1:
        return 0
    return 1
def king(i,j):
    v1[i][j]=True
    q=deque()
    q.append([i,j])
    dx=[1,0,-1,0,-1,-1,1,1]
    dy=[0,-1,0,1,-1,1,-1,1]
    while q:
        node=q.popleft()
        x=node[0]
        y=node[1]
        for i in range(8):
            if valid(x+dx[i],y+dy[i]):
                newx=x+dx[i]
                newy=y+dy[i]
                d1[newx][newy]=d1[x][y]+1
                v1[newx][newy]=1
                q.append([newx,newy])
s1,s2,e1,e2=map(int,input().split())
v1=[[False for i in range(9)]for j in range(9)]
v2=[[False for i in range(9)]for j in range(9)]
d1=[[0 for i in range(9)]for j in range(9)]
king(s1,s2)
if s1==e1 or s2==e2:
    rook=1
else:
    rook=2
if (s1+e1)%2!=(s2+e2)%2:
    bishop=0
elif s1+s2==e1+e2 or s1-s2==e1-e2:
    bishop=1
else:
    bishop=2
print(rook,bishop,d1[e1][e2])


k,n,w=map(int,input().split())
l=[]
for i in range(1,w+1):
    l.append(i)
p=0
for ele in range(0,len(l)):
    p=p+l[ele]
r=((p)*k)-n
if (r>0):
    print(r)
else:
    print("0")


n,k = map(int,raw_input().split())
print max(0,3*n-k)


n = list(map(int, input().split()))
a = set()
b = set()
for i in range(n[2]//n[0]):
 a.add((i+1)*n[0])
for i in range(n[2]//n[1]):
 b.add((i+1)*n[1])
print(len(a & b))


n = int(input())
pieces = list(map(int, input().split(' ')))
pieces.sort()
def even():
    diffEven = 0
    for i in range(len(pieces)):
        diffEven += abs(pieces[i] - ((i+1)*2))

    return(diffEven)

def odd():
    diffOdd = 0
    for j in range(len(pieces)):
        diffOdd += abs(pieces[j] - ((j*2)+1))

    return(diffOdd)

white = even()
black = odd()

print(min(black, white))


n, x = map(int, input().split(" "))
modulus = 998244353
negceil = lambda x: 0 if x < 0 else x
dp = [[-1 for _ in range(1000)] for _ in range(505)]

mx = 505
fac = [1] * mx
for i in range(1, mx):
    fac[i] = fac[i - 1] * i % modulus
ifac = [1] * 505
ifac[-1] = pow(fac[-1], modulus - 2, modulus)
for i in range(mx - 2, 0, -1):
    ifac[i] = (i + 1) * ifac[i + 1] % modulus
def C(a, b):
    return fac[a] * ifac[a - b] % modulus * ifac[b] % modulus

def solve(rem, thresh):
    prev_thresh = thresh - rem + 1
    global dp
    if rem == 1:
        return 0
    if rem == 0:
        return 1
    if prev_thresh >= x:
        return 0

    if dp[rem][thresh] != -1:
        return dp[rem][thresh]

    dp[rem][thresh] = 0

    for p in range(rem + 1):
        combs = C(rem, p)
        assigns = pow( (min(thresh, x) - prev_thresh), p, modulus)
        dp[rem][thresh] += combs * assigns * solve(rem - p, thresh + (rem - p - 1))
        dp[rem][thresh] %= modulus

    return dp[rem][thresh]

print(solve(n, n - 1))

"""
+31 247 247 247

back office GGP
08005090
"""


variants, volume = map(int, input().split())
cost = [int(x) for x in input().split()]
for i in range(1, variants):
    cost[i] = min(cost[i], 2*cost[i-1])
while len(cost) < 32:
    cost.append(cost[-1]*2)
ans = 0
binaryRepresentation = list(bin(volume)[2:])
while len(binaryRepresentation) < 32:
    binaryRepresentation = ['0'] + binaryRepresentation
binaryRepresentation.reverse()
for i in range(len(cost)):
    if binaryRepresentation[i] == '1':
        ans += cost[i]
    else:
        ans = min(ans, cost[i])
print(ans)


n=input()
t=n[0]
u=n[1]
f=0
li=[]
k=list(map(str,input().split()))
for i in k:
  for j in i:
    li.append(j)
if t in li:
  f=1
if u in li:
  f=1
if f==1:
  print("YES")
else:
  print("NO")


import sys
range = xrange
input = raw_input

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

mem = [[-1]*(n+1) for _ in range(n+1)]

# Solve for s[l:r]
def DP(l,r):
    # Empty string
    if l==r:
        return 0
    if mem[l][r]==-1:
        # Either remove the left most character
        score = 1 + DP(l+1,r)

        # Or remove a piece in the middle
        for i in range(l+1,r):
            if s[l] == s[i]:
                # s[l+1:i] is the middle piece
                new_score = DP(l+1,i) + DP(i,r)
                score = min(score,new_score)
        mem[l][r] = score
    return mem[l][r]

print DP(0,n)


from math import sqrt
def calc(n,m):
    count = 0
    for a in range(m+1):
        if a**2 + sqrt(m-a) == n:
            count += 1
    return count

# get inputs
n,m = map(int, input().split())

print(calc(n,m))


import  math
import urllib
import  urllib2
len=0
dict=[]
n =input()
arr=map(int,raw_input().split())
arr.sort(reverse=True)
for i  in range(n):
    while dict.count(arr[i]):
        arr[i]-=1
    if(arr[i]>0):
        len+=arr[i]
        dict.append(arr[i])
print len


N, M, K = map(int, input().split())
N = N // K + bool(N % K)
M = M // K + bool(M % K)

print(N * M)


from itertools import product
n = raw_input()
print sum([len(list(product('47', repeat=len(n) - i))) for i in xrange(1, len(n))]) + list(product('47', repeat=len(n))).index(tuple(n)) + 1


t = raw_input()
s = [c for c in t]

l = len(t);
d = (l>>1) + (l&1);
k=-1
for i in range(l):
    d += k*i
    s[i] = t[d-1]
    k = -k

print ''.join(s)


import math
n = int(input())
a = [int(i) for i in input().split() ]
avr = 0
a.sort()
for i in a:
    avr += i
avr = avr / n
if avr-4.5 >=0:
    print(0)
else:
    num = 4.5 - avr
    num = num * n
    if abs(int(num)-num)>0.0000001:
        num = math.ceil(num)
    else:
        num = int(num)
    cnt = 0
    for i in a:
        num += i - 5
        cnt += 1
        if num <= 0:
            break
    print(cnt)


words = set("abcdefghijklmnopqrstuvwxyz")
char_list = set()
for x in words:
    char_list.add(x)
input()
for x in set(input().lower()):
    if x in char_list:
        char_list.remove(x)
        if len(char_list) == 0:
            break

if len(char_list) == 0:
    print("YES")
else:
    print("NO")


# coding: utf-8

h, w = map(int, input().split())
a = [input() for i in range(h)]
berries = i = j = 0

while i < h and j < w:
  if a[i][j] == '*':
    berries += 1

  if i < h - 1 and a[i + 1][j] == '*':
    i += 1

  else:
    if j < w - 1:
      j += 1

    else:
      i += 1

print(berries)


x=input()
if x%4==0:
    print "1 A"
elif x%4==1:
    print "0 A"
elif x%4==2:
    print "1 B"
else:
    print "2 A"


n = input()

if n % 2 == 1:
    print 1
else:
    print 2


x=input()
a=map(int,raw_input().split())
if min(a) < 0:
	x1=0
	x2=0
	for i in a:
		if i>0:x1+=i
		else:x2+=i
	print x1-x2
else:
	print sum(a)


a,b,c=map(int,input().split())
l=c*2
x=min(a,b)
l+=x*2
if(b>a):
    b=b-a
    a=a-x
else:
    a=a-b
    b=b-x
if(a!=0 or b!=0):
    l+=1
print(l)


x=input()
x=x.split(' ')
n=int(x[0])
d=int(x[1])
x=input()
x=x.split(' ')
for i in range(n):
    x[i]=int(x[i])
x.sort()
l = []
for i in range(0, n):
    for j in range(i+1, n):
        if (x[j]-x[i])<=d:
            l.append(i + (n - j) - 1)
if l == []:
    print(n-1)
else:
     print(min(l))


import heapq

class mcf_graph_int_cost:

    def __init__(self, n):
        self.n = n
        self.pos = []
        self.g = [[] for _ in range(n)]

    def add_edge(self, from_, to, cap, cost):
        # assert 0 <= from_ < self.n
        # assert 0 <= to < self.n
        m = len(self.pos)
        self.pos.append((from_, len(self.g[from_])))
        self.g[from_].append(self.__class__._edge(to, len(self.g[to]), cap, cost))
        self.g[to].append(self.__class__._edge(from_, len(self.g[from_]) - 1, 0, -cost))
        return m

    class edge:
        def __init__(self, from_, to, cap, flow, cost):
            self.from_ = from_
            self.to = to
            self.cap = cap
            self.flow = flow
            self.cost = cost

    def get_edge(self, i):
        _e = self.g[self.pos[i][0]][self.pos[i][1]]
        _re = self.g[_e.to][_e.rev]
        return self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost)

    def edges(self):
        ret = []
        for i in range(len(self.pos)):
            _e = self.g[self.pos[i][0]][self.pos[i][1]]
            _re = self.g[_e.to][_e.rev]
            ret.append(self.__class__.edge(self.pos[i][0], _e.to, _e.cap + _re.cap, _re.cap, _e.cost))
        return ret

    def _dual_ref(self, s, t):
        self.dist = [4294967295] * self.n
        self.pv = [-1] * self.n
        self.pe = [-1] * self.n
        self.vis = [False] * self.n

        que = [s] # s ==  (0 << 32) + s
        self.dist[s] = 0
        while que:
            v = heapq.heappop(que) & 4294967295
            if self.vis[v]:
                continue
            self.vis[v] = True
            if v == t:
                break
            for i in range(len(self.g[v])):
                e = self.g[v][i]
                if self.vis[e.to] or e.cap == 0:
                    continue
                cost = e.cost - self.dual[e.to] + self.dual[v]
                if self.dist[e.to] > self.dist[v] + cost:
                    self.dist[e.to] = self.dist[v] + cost
                    self.pv[e.to] = v
                    self.pe[e.to] = i
                    heapq.heappush(que, ((self.dist[e.to] << 32) + e.to))
        if not self.vis[t]:
            return False

        for v in range(self.n):
            if not self.vis[v]:
                continue
            self.dual[v] -= self.dist[t] - self.dist[v]

        return True

    def slope(self, s, t, flow_limit=4294967295):
        # assert 0 <= s < self.n
        # assert 0 <= t < self.n
        # assert s != t

        self.dual = [0] * self.n
        self.dist = [4294967295] * self.n
        self.pv = [-1] * self.n
        self.pe = [-1] * self.n
        self.vis = [False] * self.n

        flow = 0
        cost = 0
        prev_cost = -1
        result = [(flow, cost)]
        while flow < flow_limit:
            if not self._dual_ref(s, t):
                break
            c = flow_limit - flow
            v = t
            while v != s:
                c = min(c, self.g[self.pv[v]][self.pe[v]].cap)
                v = self.pv[v]
            v = t
            while v != s:
                e = self.g[self.pv[v]][self.pe[v]]
                e.cap -= c
                self.g[v][e.rev].cap += c
                v = self.pv[v]
            d = -self.dual[s]
            flow += c
            cost += c * d
            if prev_cost == d:
                result.pop()
            result.append((flow, cost))
            prev_cost = cost
        return result

    def flow(self, s, t, flow_limit=4294967295):
        return self.slope(s, t, flow_limit)[-1]

    class _edge:
        def __init__(self, to, rev, cap, cost):
            self.to = to
            self.rev = rev
            self.cap = cap
            self.cost = cost

INF = 10 ** 9

n = int(input())
a1, a2, a3 = map(int, input().split())
b1, b2, b3 = map(int, input().split())

g = mcf_graph_int_cost(8)
g.add_edge(0, 1, a1, 0)
g.add_edge(0, 2, a2, 0)
g.add_edge(0, 3, a3, 0)
g.add_edge(4, 7, b1, 0)
g.add_edge(5, 7, b2, 0)
g.add_edge(6, 7, b3, 0)
for i in range(1, 4):
    for j in range(4, 7):
        cost = 1 if (j - i) % 3 == 1 else 0
        g.add_edge(i, j, INF, cost)

f, ans1 = g.flow(0, 7)

ans2 = min(a1, b2) + min(a2, b3) + min(a3, b1)
print(ans1, ans2)


import re
l = raw_input()
s = raw_input()
bat = []
for i in re.findall('\((.*?)\)', s):
    bat.extend([j for j in i.split('_') if j != ''])

cat = [len(i )for i in re.sub('\((.*?)\)','_', s).split('_')]
print max(cat), len(bat)


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

i = a
j = b

while (i != x and j != y):
    if (i == j):
        print('YES')
        quit()

    i = i + 1
    j = j - 1

    if (i > n):
        i = 1
    if (j == 0):
        j = n

if (i == j):
    print('YES')
    quit()

print('NO')


a, b, c =[int(q) for q in input().split()]
x, y, z =[int(q) for q in input().split()]
if a>=x:
    a -=x
    x=0
else:
    x -=a
    a=0
if b>=y:
    b -=y
    y=0
else:
    y -=b
    b=0
if c>=z:
    c -=z
    z=0
else:
    z -=c
    c=0
if x+y+z<=a//2+b//2+c//2:
    print("Yes")
else:
    print("No")


n1,n2,k1,k2=map(int,input().split())

if n1==n2:
    print("Second")
elif n1>n2:
    print("First")
else:
    print("Second")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 31 18:23:00 2019

@author: apple
"""
n=int(input())
es=input()
c=[]
sum=0
for i in range(n):
    if(sum<n):
        c.append(es[sum])
        sum+=i
    else:
        break
s=""
for i in range(len(c)):               #coonteestt
     s+=c[i]
if(n>1):
   print(s[1:])
else:
    print(es)


def f(n):
    # Build maximum number of pieces for
    #length 1 upto n in bottom up manner
    dp = [float("-inf")] * (n + 1)

    # Base Case
    dp[0] = 0

    # dp[i] gives maximum number of pieces that can
    # be obtained by cutting ribbon of length  i into pieces
    # of length a, b or c
    # dp[i] = -inf if it is not possible to cut the ribbon into pieces
    for i in range(1, n + 1):
        for length in l:
            # Cut into pieces if only we dont have negative length of ribbon
            if i - length >= 0:
                dp[i] = max(dp[i], 1 + dp[i - length])
    # return maximum number of pieces possible for ribbon with length n
    return dp[n]

l = list(map(int, input().split()))
n, l = l[0], l[1:]
print(f(n))


def whereis(k):
    n = 1
    while k > 0:
        k -= 9*10**(n-1)*n
        n+=1
    else:
        n-= 1
        return n

def kthdigit(k):
    a = whereis(k)
    sequence = ''
    sum = 0
    for b in range(1, a):
        sum += 9*10**(b-1)*b
    i = k-sum
    divider = (i-1)/a
    remainder = (i-1)%a
    number = divider + 10**(a-1)
    string = ''
    for huh in range (number, number+1):
        string += str(huh)

    return string[remainder]
we = input()
print kthdigit(we)


if __name__ == '__main__':
    num = int(input().strip())
    segments = []
    for i in range(1,num + 1):
        for j in range(num):
            if j + i > num:
                break
            segments.append((j,j+i))
    #print(segments)
    segments.sort(key = lambda x: (x[0],x[1]))
    count = 0
    while segments != []:
        right_end = segments[0][1]
        j = 0
        while j < len(segments):
            if segments[j][0] == right_end:
                right_end = segments[j][1]
                segments.remove(segments[j])
            else:
                j += 1
        count += 1
        segments.remove(segments[0])
    print(count)


n, m = map(int, raw_input().strip().split())
a = map(int, raw_input().strip().split())

a = sorted(a)
a.reverse()

def solve(mid):
    s = 0
    for i in range(n):
        now = a[i] - i/mid
        if now <= 0:
            break
        else:
            s += now
    if s >= m:
        return True
    else:
        return False

if sum(a) < m:
    print -1
else:
    l = 1
    r = n
    while(l<r):
        mid = (l+r)/2
        if(solve(mid)):
            r = mid
        else:
            l = mid+1
    print l


a=raw_input()
a=a.lower()
b=raw_input()
b=b.lower()
f=0
for i in xrange(len(a)):
    if a[i]>b[i]:
        print 1
        f=0
        break;
    if a[i]<b[i]:
        print -1
        f=0
        break
    if a[i]==b[i]:
        f=1
if f==1:
    print 0


xmin, ymin, xmax, ymax, a = 31400, 31400, 0, 0, 0

for i in range(int(input())):

    x1, y1, x2, y2 = map(int, input().split())

    xmin = min(xmin, x1)

    ymin = min(ymin, y1)

    xmax = max(xmax, x2)

    ymax = max(ymax, y2)

    a += (x2 - x1) * (y2 - y1)

print('YES' if xmax - xmin == ymax - ymin and a == (xmax - xmin) ** 2 else 'NO')


n,x,y=map(int,input().split())
if ((x==n/2 or  x==n/2+1) and (y==((n/2)) or y==((n/2)+1))):
    print("NO")
else:
    print("YES")


from math import *

n = int(input())
l = [0 for i in range(n - 2)]

for i in range(2, n):
    m = n

    while m != 0:
        l[i - 2] += m % i
        m -= m % i
        m //= i

zbr = sum(l)
br = n - 2
k = i

for i in range(1, br + 1):
    if zbr % i == 0 and br % i == 0:
        k = i

print('{}/{}'.format(zbr // k, br // k))


#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1391",problemID = "A",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers

    I prefer Python language over the C++ language :p :D

    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    q = 1
    w = 1
    for i in range(n,0,-1):
        q = (q * i) % 1000000007
        if i != 1:
            w = (2 * w) % 1000000007
    print((q - w) % 1000000007)

################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################

def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()

#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))

#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def range_prod(lo,hi):
    if lo+1 < hi:
        mid = (hi+lo)//2
        return range_prod(lo,mid) * range_prod(mid+1,hi)
    if lo == hi:
        return lo
    return lo*hi

def treefactorial(n):
    if n < 2:
        return 1
    return range_prod(1,n)
def pow( x, y):

	if (y == 1):
		return x
	if (y == 0):
		return 1

	temp = pow(x, y // 2)

	temp *= temp

	if (y & 1):
		temp *= x

	return temp
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m):
        for j in range(n):
            b[i][j] = a[j][i]
    return(b)
#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline

main()


a, b = input().split()
a, b = int(a), int(b)
a, b = min(a, b), max(a, b)

def eu(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a > b:
        return eu(a%b, b)
    return eu(a, b%a)

opt = b - a
factor = []
i = 1
while i**2 < opt+1:
    if opt % i == 0:
        factor.append(i)
        factor.append(int(opt/i))
    i+=1

target = a * b / eu(a, b)
drop = 0

for i in factor:
    firstupd = a - (a % i) + i
    secondupd = b - (b % i) + i
    dres = firstupd * int(secondupd/eu(firstupd,secondupd))
    if dres <= target:
        if dres == target:
            drop = min(i-(a%i),drop)
        else:
            target = dres
            drop = i-(a%i)
print(drop)


R=lambda:map(int,raw_input().split())
n,m=R()
a=R()
b=0
while a:
  c=m
  while a and c>=a[0]:
    c-=a.pop(0)
  b+=1
print b


a=raw_input()
plus=0
if a[0:2]=='KK':
    plus=1
else:
    for i in range(len(a)-1):
        if a[i:i+3]=='VVV' or a[i:i+3]=='KKK':
            plus=1
    if a[-2:]=='VV':
        plus=1
cnt=0
for i in range(len(a)-1):
    if a[i:i+2]=='VK':
        cnt+=1

print cnt+plus


n,k=map(int,input().split())
mini = min(1,k,n-k)
maxi = min(n-k,2*k)
print(mini,maxi)


S = raw_input()
N = len(S)
for i in xrange(N + 1):
    for j in xrange(i, N + 1):
        if S[:i] + S[j:] == "CODEFORCES":
            print "YES"
            exit()
print "NO"


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

cw=['v','<','^','>','v','<','^','>']
ccw=['v','>','^','<','v','>','^','<']
(s,e)=map(str,raw_input().split(' '))
n=int(raw_input())
n=n%4
tmp1=tmp2=0
cwind=cw.index(s)+n
ccwind=ccw.index(s)+n
if(cw[cwind]==e):
    tmp1=1
if(ccw[ccwind]==e):
    tmp2=1
if(tmp1==1 and tmp2==1):
    print "undefined"
elif(tmp1):
    print "cw"
else:
    print "ccw"


put = lambda: tuple(map(int, input().split()))

a, b = put()
if b / a >= 2:
    print(0)
else:
    used = []
    ans = 0
    if b <= a:
        a = b - 1
    if b % 2 == 0:
            up = b // 2
    else:
        up = (b - 1) // 2
    ans = a - up
    print(ans)


[n, m] = [int(x) for x in input().split()]
I = 0
S = 1
D = 2
C = 3
exses = [[0, 0, 0, 0]]
pops = [0] * (n+1)
i = 1
while i <= m:
  [s, d, c] = [int(x) for x in input().split()]
  exses.append([i, s, d, c])
  pops[d] = i
  i += 1

i = 1
result = [0] * (n+1)
fail = False
while i <=n:
  if pops[i] != 0 and exses[pops[i]][C] == 0:
    result[i] = m+1
  elif pops[i] != 0 and exses[pops[i]][C] > 0:
    fail = True
    break
  else:
    ex = None
    min = n+1
    for e in exses:
      if e[D] > i and e[S] <= i and e[D] < min and e[C] > 0:
        min = e[D]
        ex = e
    if ex == None:
      result[i] = 0
    else:
      result[i] = ex[I]
      ex[C] -= 1
  i += 1

if fail:
  print(-1)
else:
  for x in result[1:]:
    print(x, end=' ')


# http://codeforces.com/problemset/problem/450/A

from collections import deque
from math import ceil
# n, m = [int(x) for x in input().split()]
n, m = map(int, input().split())
candies = [int(x) for x in input().split()]

children = deque([int(x) for x in range(1, n + 1)])
home = []

max_num = 0
counter = 0
candies_dict = {}

for k in candies:
    counter += 1
    candies_dict[counter] = k

for i in candies:
    result = ceil(i / m)
    if result >= max_num:
        max_num = ceil(i / m)
        max_candies = i

# print(candies_dict)
# print(max_candies)

max_keys = []

for k, v in candies_dict.items():
    if v == max_candies:
        max_keys.append(k)

print(max_keys[-1])


def main():
  n, k = raw_input().split()
  k = int(k)
  if len(n) <= k or n == '0':
    print len(n) - 1
    return

  n = n[::-1]
  #print n, k
  numeros_sacados = 0
  ceros = 0
  for dig in n:
    if ceros == k:
      print numeros_sacados
      return
    if dig == '0':
      ceros += 1
    else:
      numeros_sacados += 1
  print len(n) - 1
  return

main()


n = int(input())
arr = list(map(int, input().split()))
x,y = min(arr), max(arr)
if arr.index(x)==0 or arr.index(y)==0 or arr.index(x)==n-1 or arr.index(y)==n-1:
	print(n-1)
elif arr.index(x) < arr.index(y):
    print(max(n-1 - arr.index(x), arr.index(y)))
elif arr.index(x) > arr.index(y):
    print(max(n-1 - arr.index(y), arr.index(x)))


m,n=map(int,raw_input().split())
if(m/n)%2==1:
	print "YES"
else:
	print "NO"


S = sorted
M = lambda : map(int,input().split())
m = int(input())
a = list(M())
cnto,cnte = 0,0
for i in a:
	if i == 100:
		cnto +=1
	else:
		cnte +=1
if cnto>0 :
	if cnto%2==0:
		print("YES")
	else:
		print("NO")
else:
	if cnte%2==0:
		print("YES")
	else:
		print("NO")


lim_w, bob_w = map(int, raw_input().split())
no_of_years = 0
while lim_w <= bob_w:
	lim_w = lim_w * 3
	bob_w = bob_w * 2
	no_of_years = no_of_years + 1
print(no_of_years)


def win(l,s):
    if l[0] == [s, s, s] or l[1] == [s, s, s] or l[2] == [s, s, s] or l[0][0] == s and l[1][0] == s and l[2][0] == s or \
            l[0][1] == s and l[1][1] == s and l[2][1] == s or l[0][2] == s and l[1][2] == s and l[2][2] == s or l[0][
        0] == s and l[1][1] == s and l[2][2] == s or l[0][2] == s and l[1][1] == s and l[2][0] == s:
        return 1
    else:
        return 0
a=list(input())
b=list(input())
c=list(input())
l=[a,b,c]
mf=a.count('X')+b.count('X')+c.count('X')
ms=a.count('0')+b.count('0')+c.count('0')
me=a.count('.')+b.count('.')+c.count('.')
if  mf -ms!= 1 and mf -ms!=0 :
    print('illegal')
else:
    n=win(l,'0')
    m=win(l,'X')
    if n==1 and m==1 or n==1 and mf-ms!=0 or m==1 and mf-ms!=1:
        print('illegal')
    elif n==1:
        print('the second player won')
    elif m==1:
        print('the first player won')
    else:
        if me==0:
            print('draw')
        elif mf-ms==1:
            print('second')
        else:print('first')


def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
t,a,b=map(int,raw_input().split())
G=gcd(a,b)
p=a*b
L=a*b
L=L/G
ans=0
if a<b:
    ans+=(a-1)
else:
    ans+=(b-1)
t1=t/L
ans+=t1
diff=0
if a<b:
    diff=a-1
else:
    diff=b-1
ans+=(diff*(t1-1))
m=t1*L
ans+=min(diff,t-m)
GG=gcd(ans,t)
ans/=GG
t/=GG
print str(ans)+"/"+str(t)


for _ in range(int(input())):
    n,k,l=map(int,input().split())
    depth=list(map(int,input().split()))
    fg=1;mn=-k;mx=k
    for i in depth:
        if i>l:fg=0;break
        mx=min(l-i,k)
        if mx==k:mn=-k
        else:mn=max(mn+1,-mx)
        if mn>mx:fg=0;break
    if fg:print("Yes")
    else:print("No")


k2, k3, k5, k6 = map(int, input().split())

sum256 = 0

sum32 = 0

while ( k2 > 0 and k5 > 0 and k6 > 0 ):
    x = min(k2, k5, k6)
    sum256 += (256 * x)
    k2 -= x
    k5 -= x
    k6 -= x

while ( k2 > 0 and k3 > 0 ):
    x = min(k2, k3)
    sum32 += (32 * x)
    k2 -= x
    k3 -= x

result = sum256 + sum32
print(result)


li=map(int,raw_input().split())

"""initially number shows n"""

n=li[0]
m=li[1]

count=0

while n<m:
    if m%2==0:
        m=m/2
    else:
        m=m+1
    count=count+1

print count+(n-m)


s=input()
p=set()
for i in s:
    p.add(i)
if len(p)%2 == 0:
    print("CHAT WITH HER!")
else:
    print("IGNORE HIM!")


import sys

def solve():
    s = [ch for ch in input()]
    n = len(s)

    for i in range(n):
        if i != n - 1 - i and s[i] == s[n - 1 - i]:
            continue

        tmp = s[i]
        s[i] = s[n - 1 - i]

        if s == s[::-1]:
            print('YES')
            return

        s[i] = tmp

    print('NO')

if __name__ == '__main__':
    solve()


a,b,c,d,x,y=map(int, input().split())
contador=0
while (x<=y):
    if(x%a%b%c%d==x):
        contador=contador+1
    x=x+1
print(contador)


n = int(input())

m = 3
while n % m == 0:
    m *= 3

print(int(n // m + 1))


def red(m,n):
    while n:
        m,n = n, m%n
    return m

def main():
    x = int(input())
    m = int((x-1)/2)
    n = int(x-m)
    while red(m,n) != 1:
        m = m-1
        n = x-m
    print(m,n)

if __name__ == "__main__" : main()


s=raw_input()
cu=0
cl=0
t=len(s)
for i in xrange(t):
    if s[i].isupper()==True:
        cu=cu+1
    else:
        cl=cl+1

if cu>cl:
    print s.upper()
else:
    print s.lower()


n=int(input())
x=y=1
r=0
while (x<=n):
  r+=1
  y+=1
  x=int(bin(y)[2:])
print(r)


#coding=utf-8

xA,yA = map(int, raw_input().split())
xB,yB = map(int, raw_input().split())
xC,yC = map(int, raw_input().split())

xAB,yAB=xA-xB,yA-yB
xBC,yBC=xB-xC,yB-yC

s = xAB*yBC-yAB*xBC

#print s
if s == 0:
	print "TOWARDS"
elif s > 0:
	print "LEFT"
else:
	print "RIGHT"


lemons = int(input())
apples = int(input()) // 2
pears = int(input()) // 4
total_sum = min(lemons, apples, pears) * 7
if apples * 2 < 2 or pears * 4 < 4:
    print(0)
else:
    print(total_sum)


import sys
import math
from statistics import mean
from collections import Counter

input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return (int (input ()))

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

def insr():
    s = input()
    return (list (s[:len (s) - 1]))

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

n,k,l,c,d,p,nl,np = invr()

a = k*l
a = int(a/nl)
b = c*d
s = p/np
ans = min(a,b,s)
ans = int(ans/n)
print(ans)


import copy

def elimina_lista(lista, posicao):
    i = posicao
    j = i
    cont2 = 0
    while lista[i] == lista[j]:
        cont = 2
        while i > 0 and lista[i-1] == lista[i]:
            i -= 1
            cont += 1
        while j < len(lista)-1 and lista[j+1] == lista[j]:
            j += 1
            cont += 1

        i -= 1
        j += 1
        if cont >= 3:
            cont2 += cont
            if i < 0 or j >= len(lista):
                 break
        else:
            break
    return cont2

n, k, x = map(int, raw_input().split())
lista = map(int, raw_input().split())
lista3 = []

for i in xrange(len(lista)):
    if lista[i] == x:
        if lista[i] != lista[i-1]:
            lista2 = copy.copy(lista)
            lista3.append(elimina_lista(lista2, i))

if lista3 == []:
    print 0
elif max(lista3) <= 0:
    print 0
else:
    print max(lista3) -1


from math import factorial
a, b = map(int, raw_input().split())
print factorial(min(a, b))


def assign(n,i):
	for e in range(i,len(n),4):
		if n[e]=="!":
			continue
		else:
			return n[e]
n = list(input())
l2 = [0]*4
for i in range(4):
	l2[i]=assign(n,i)
di = {l2[0]:0,l2[1]:0,l2[2]:0,l2[3]:0}
for i in range(len(n)):
	if n[i]=="!":
		di[l2[i%4]]+=1
print(di['R'],di['B'],di['Y'],di['G'])


n=input()
m=input()
if n>40:
  print m
else:
  print m%(pow(2,n))


import copy
n,m=[int(x) for x in input().split()]
res=[]
for i in range(n):
    d=[0]*n
    d[i]=1
    res.append(d)

for i in range(m):
    r,c = [int(x) for x in input().split()]
    res[r-1][c-1]=1
    res[c-1][r-1] = 1

groups=['x']*n
cor1=[]
cor2=[]
output=''
for i in range(n):
    if res[i]==[1]*n:
        groups[i]='b'
for i in range(n):
    if not groups[i]=='b':
        if len(cor1)==0:
            cor1=copy.deepcopy(res[i])
            groups[i]='a'
        elif res[i]==cor1:
            groups[i]='a'
        elif len(cor2)==0:
            cor2=copy.deepcopy(res[i])
            groups[i]='c'
        elif res[i]==cor2:
            groups[i]='c'
        else:
            output= 'No'
            break
if len(output)==0:
    print('Yes')
    print(''.join(groups))
else:
    print('No')

#print(res)


n , k = map(int,input().split())
l = -1
h = n + 1
while l + 1 < h:
    mid = (l + h) // 2
    if 2 * (mid + k * mid) <= n:
        l = mid
    else:
        h = mid
print(l , k * l , n - (l + k * l))


import math
def dtb(n):
    return bin(n).replace("0b","")
def btd(n):
    return int(n,2)

n=int(input())
r=list(map(int,input().split()))[:n]
b=list(map(int,input().split()))[:n]
count1,count2=0,0
flag=0
for i in range (n):
    if r[i]==1 and b[i]==0:
        count1+=1
    if r[i]==0 and b[i]==1:
        count2+=1

if count1==0:
    print(-1)
else:
    ans=math.ceil((count2+1)/count1)
    print(ans)


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


n,k,t=map(int,input().split())
count=0
ti=t+0
if t>k:
	count+=k
	t-=k
	if t>0:
		t-=n-k-1
	if t>0:
		count-=(ti-n)

else:
	count+=t

print(count)


import math
def lcm(a,b):
    return (a*b) // math.gcd(a,b)
a,b=map(int,input().split())
kpop=10**b
print(lcm(a,kpop))


a,b,c = map(int,input().split())
s=0

if c%a==0 or c%b==0:
    print('Yes')
else:
    for k in range(1,10001):
        h=0
        for j in range(1,10001):
            u = a*k+b*(j)

            if u==c:
                print('Yes')
                h+=1
                s+=1
                break
            elif u>c:
                break
        if s>0:
            break
    if s==0:
        print('No')


a,b,c,n = map(int,input().split())
x = n-(a+b-c)
if x < 1 or x > n or a > n or b >n or c > n or c >a or c >b:
    print('-1')
else:
    print(x)


from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

from bisect import bisect_left as lower_bound, bisect_right as upper_bound
def so():  return int(input())
def st():  return input()
def mj():  return map(int,input().strip().split(" "))
def msj(): return list(map(str,input().strip().split(" ")))
def le():  return list(map(int,input().split()))
def rc():  return map(float,input().split())
def lebe():return list(map(int, input()))

def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
def joro(L):
    return(''.join(map(str, L)))
def joron(L):
    return('\n'.join(map(str, L)))

def decimalToBinary(n): return bin(n).replace("0b","")

def isprime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True
def npr(n, r):
    return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
    answer = -1
    start = 0
    end = len(li) - 1

    while (start <= end):
        middle = (end + start) // 2
        if li[middle] >= num:
            answer = middle
            end = middle - 1
        else:
            start = middle + 1
    return answer  # min index where x is not less than num

def upper_bound(li, num):
    answer = -1
    start = 0
    end = len(li) - 1

    while (start <= end):
        middle = (end + start) // 2

        if li[middle] <= num:
            answer = middle
            start = middle + 1

        else:
            end = middle - 1
    return answer  # max index where x is not greater than num
def tir(a,b,c):
    if(0==c):
        return 1
    if(len(a)<=b):
        return 0

    if(c!=-1):
        return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c))

    else:
        return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))

def abs(x):
    return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
    # print(lb, ub, li)
    ans = -1
    while (lb <= ub):
        mid = (lb + ub) // 2
        # print('mid is',mid, li[mid])
        if li[mid] > val:
            ub = mid - 1
        elif val > li[mid]:
            lb = mid + 1
        else:
            ans = mid  # return index
            break
    return ans

def kadane(x):  # maximum sum contiguous subarray
    sum_so_far = 0
    current_sum = 0
    for i in x:
        current_sum += i
        if current_sum < 0:
            current_sum = 0
        else:
            sum_so_far = max(sum_so_far, current_sum)
    return sum_so_far

def pref(li):
    pref_sum = [0]
    for i in li:
        pref_sum.append(pref_sum[-1] + i)
    return pref_sum

def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    li = []
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n + 1, p):
                prime[i] = False
        p += 1

    for p in range(2, len(prime)):
        if prime[p]:
            li.append(p)
    return li

def primefactors(n):
    factors = []
    while (n % 2 == 0):
        factors.append(2)
        n //= 2
    for i in range(3, int(sqrt(n)) + 1, 2):  # only odd factors left
        while n % i == 0:
            factors.append(i)
            n //= i
    if n > 2:  # incase of prime
        factors.append(n)
    return factors

def read():
    sys.stdin  = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
def tr(n):
    return n*(n+1)//2
boi=int(1e9+7)
doi=int(1e9+7)
hoi=int(6e5+5)

poi=int(1e5+5)

y="YES"
n="NO"

def bulli(x):
    return bin(x).count('1')

import sys

f=[0]*(hoi)
r=[0]*(hoi)
d=[]
for i in range(poi):
    d.append([])
L=[0]*poi
M=[0]*poi

def ty(a,b):
    rr=1
    while(b):
        if(b%2):
            rr=(rr*a)%boi
        b=b//2
        a=a*a%boi
    return rr
def inv(a):
    re=1
    for i in range(1,1+a):
        re=(re*i)%boi
    re=ty(re,boi-2)
    return re
def ncr(m,k):
    if(m<0 or k<0 or k>m):
        return 0
    return f[m]*r[k]%boi*r[m-k]%boi
def gosa(a,b):
    if(0!=b):
        return gosa(b,a%b)
    return a

def iu():
    import sys
    import math as my
    import functools
    import bisect as bs
    input=sys.stdin.readline
    from collections import deque, defaultdict
    '''f[0]=1
    for i in range(1,hoi):
        f[i]=(f[i-1]*i)%boi
    r[hoi-1]=ty(f[hoi-1],boi-2)
    for i in range(hoi-2,-1,-1):
        r[i]=r[i+1]*(i+1)%boi'''
    z=0
    m=so()
    for i in range(poi-1,0,-1):
        for j in range(i,poi,i):
            d[j].append(i)
    for i in range(1,1+m):
        r=m-i
        s=len(d[r])
        for j in range(s):
            M[j]=r//(d[r][j])-1
            for k in range(j):
                if(not d[r][k]%d[r][j]):
                    M[j]=M[j]-M[k]
            z=z+M[j]*i*d[r][j]//gosa(d[r][j],i)%boi
    print(z%boi)

def main():
    for i in range(1):
        #print("Case #"+str(i+1)+": ",end="")
        iu()

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()


import sys
num=int(sys.stdin.readline().strip())
lst=map(int,sys.stdin.readline().strip().split())
while num>0:
    for i in range(7):
        num-=lst[i]
        if num<=0:
            print i+1
            break


count = int(input())

sum = 0
years = input().split(' ')
for y in years:
    sum += int(y)
print(int(sum/count))


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

ans=a//k+b//k
if ans==0:
	print(-1)
elif (a<k and b%k!=0) or (b<k and a%k!=0):
	print(-1)
else:
	print(ans)


n=int(input())
l=[0]*12
for u in range(4):
    s=list(input())
    for i in s:
        if(i.isdigit()):
            l[int(i)]+=1
for i in l:
    if(i>2*n):
        print("NO")
        break
else:
    print("YES")


def solve():
    n, m, k = map(int, input().split())
    if k > (n * m) // 2:
        print('NO')
        return
    if n % 2 == 1 and m % 2 == 0:
        if k < (m // 2):
            print('NO')
            return
        elif k == (m // 2):
            print('YES')
            return
        elif k > (m // 2):
            if (k - m // 2) % 2 == 0:
                print('YES')
                return
            else:
                print('NO')
                return
    if n % 2 == 0 and m % 2 == 0:
        if k % 2 == 0:
            print('YES')
        else:
            print('NO')
    if n % 2 == 0 and m % 2 == 1:
        if k % 2 == 1:
            print('NO')
        else:
            if k > (m * n - n) // 2:
                print('NO')
            else:
                print('YES')

for i in range(int(input())):
    solve()


input = raw_input()
a, b, f, k = map(int, input.split(" "))
t = b
p = 0
if b < f:
    print -1
else:
    while True:
        if t < f or b < a - f:
            print -1
            break
        if k == 1:
            if t < a:
                print p + 1
            else:
                print p
            break
        t -= f
        if t < 2 * (a - f):
            t = b
            p += 1
        k -= 1
        t -= a - f
        if t < a - f or b < f:
            print -1
            break
        if k == 1:
            if t < a:
                print p + 1
            else:
                print p
            break
        t -= a - f
        if t < 2 * f:
            t = b
            p += 1
        k -= 1
        t -= f


s = c_r = c_l = 0
for _ in range(input()):
    x, y = map(int, raw_input().split())
    c_r += x
    c_l += y
    if((x+y)%2 != 0):
        s+=1

if(c_l % 2 == 0 and c_r % 2 == 0):
    print 0
elif(s % 2 == 0 and s>0):
    print 1
else:
    print -1


colors = input()
instructions = input()

pointer = 0
for index in range(len(instructions)):
    if(instructions[index] == colors[pointer]):
        pointer += 1
print(pointer+1)


s=raw_input()
t=set([ord('a')-1])
for c in s:
  x=ord(c)
  if x not in t and (x-1) not in t:
    print 'NO'
    break
  t.add(x)
else:
  print 'YES'


import math
a,x,y=map(float,raw_input().split())
a=int(a)
n=1.0*y/a
i=int(n)
def f():
    print '-1'
    exit()
if n==i:
    f()
if i==0 or i%2==1:
    if x == a/2.0 or x == -1*a/2.0 :
        f()
    elif -a/2.0<x<a/2.0:
        print int(math.floor(i/2)*2+math.ceil(i/2.0)+1)
    else:
        f()
else:
    if x == a or x == -a or x == 0:
        f()
    elif -a<x<a:
        if x>0:
            print int(i+i/2+1)
        else:
            print int(i+i/2)
    else:
        f()


n = input()
x = []
y = []
for i in range(n):
	xi,yi = [int(xyi) for xyi in raw_input().split(" ")]
	if xi not in x:
		x += [xi]
	if yi not in y:
		y += [yi]
if len(x) != 2 or len(y) != 2:
	print -1
	exit()
print abs(x[0]-x[1]) * abs(y[0]-y[1])


y = lambda: list(map(int, input().split()))
k = lambda c: ord(c) - ord('0')
z1 = y()
z2 = y()
z3 = y()
for i in range(8):
    t = bin(i)[2:].zfill(3)
    bw = z1[k(t[0])]; bh = z1[1 - k(t[0])]
    w = z2[k(t[2])] + z3[k(t[1])]
    h = max(z2[1 - k(t[2])], z3[1 - k(t[1])])
    if h <= bh and w <= bw:
        print('YES')
        break
else:
    print('NO')


n=int(input())
a=""
for i in range(2,n):
    if(n%i==0 and len(a)<=2):
        a+=str(i)
        a+=str(n//i)
        break
if(len(a)==0):
    print("1"+str(n))
else:
    print(int(a))


a, b = [int(x) for x in input().split(' ')]

while min(a, b) > 0:
    if a >= 2 * b:
        a = a % (2 * b)
    elif b >= 2 * a:
        b = b % (2 * a)
    else:
        break
print(a, b)


word1 = input()
word2 = input()

w1len = len(word1)
w2len = len(word2)

if w1len != w2len:
    print('NO')

else:

    if (w1len % 2) == 0:  # ES
        index = w1len - 1
        cant = w1len
        i = 0
        while cant != 0:
            a = word1[i]
            b = word2[index]

            if a == b:
                i += 1
                index -= 1
                cant -= 1

            else:
                print('NO')
                break
        if cant == 0:
            print('YES')

    else:
        index = w1len - 1
        cant = w1len
        i = 0
        while cant != 0:
            a = word1[i]
            b = word2[index]

            if a == b:
                i += 1
                index -= 1
                cant -= 1

            else:
                print('NO')
                break
        if cant == 0:
            print('YES')


def t(a,b,c,d,e):
    #for i in range(5):
      #  v.append (int(input("podaj liczbe")))

    gr1=0
    gr2=0

    gr1=(b*a)+(d*2)
    gr2=(c*a)+(e*2)
    #print(gr1)
    #print(gr2)
    if gr1>gr2:
        print("Second")
    if gr1<gr2:
        print("First")
    if gr1==gr2:
        print("Friendship")

a,b,c,d,e = input().split(" ")
t(int(a),int(b),int(c),int(d),int(e))


s = input()
print(min(len(s), s.count('a')*2-1))


def R(x, y, z):
    if z < x + y and x < z + y and y < z + x:
        return 2
    elif z == x + y or x == z + y or y == z + x:
        return 1
    else:
        return 0

a, b, c, d = map(int, input().split())
s = max(R(b, c, d), R(a, c, d), R(a, b, d), R(a, b, c))
print(['IMPOSSIBLE', 'SEGMENT', 'TRIANGLE'][s])


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

for i in range(0, l):
	s = set()
	cnt = 0
	for j in a:
		s.add((i + j) % l)
	for j in range(0, l):
		cnt = 0
		for k in b:
			if (j + k) % l in s:
				cnt += 1
		if cnt == n:
			print('YES')
			exit(0)
print('NO')


data = input().split(" ")
k = [int(data[0]), int(data[1]), int(data[2])]
k.sort()
[k1, k2, k3] = k
has_solution = False
if k1 == 1:
    has_solution = True
elif k1 == 2 and k2 == 2:
    has_solution = True
elif k1 == 2 and k2 == 4 and k3 == 4:
    has_solution = True
elif k1 == 3 and k2 == 3 and k3 == 3:
    has_solution = True
if has_solution:
    print("YES")
else:
    print("NO")


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

if(min(n,m) % 2 == 0):
    print('Malvika')
else:
    print('Akshat')


def naxt(i) :
    e=bin(i+2)
    e=e[3:]
    e=e.replace("0","4")
    e=e.replace("1","7")
    return int(e)
i=0;ans=0;pr=0
l,r=map(int,input().split())
while(True):
    t=naxt(i)

    ans+=max((min(r,t)-max(l,pr)+1)*t,0)
    pr=t+1
    if r<=t :
        break
    i+=1
print(ans)


s=raw_input()
n=int(s)
m=len(s)
a=0 if m<2 else int('9'*(m-1))
print 9*(m-1)+sum(map(int,str(n-a)))


n = int(input())
ans = 0
for x in range(1, n + 1):
	ans += 2 ** x
print(ans)


#!/usr/bin/env python

def is_prime(x):
	temp = True
	for i in xrange(2,(x/2) + 1):
		if x%i == 0:
			temp =False
			break
	return temp

n,m = [int(x) for x in raw_input().split()]

ans = True

while True:
	n += 1
	if n > m:
		ans = False
		break
	if is_prime(n):
		if n != m:
			ans = False
		break

if not ans:
	print "NO"
else:
	print "YES"


def p(x):
 d=2
 while d*d<=x and x%d:d+=1
 return d*d>x
n=input()
print 1 if p(n) else 2 if 0==n%2 or p(n-2) else 3


def cal(x):
    ans = 0
    while (x):
        ans += x % 10
        x =x// 10
    return ans

n = int(input())
now = 19
i=1
while (i<n):
    now += 9
    if cal(now) == 10:
        i += 1
print (now)


n = int(int(input()))
ans = 0
for l in range(1, 11):
    if (l == len(str(n))):
        ans += (n - 10**(l-1) + 1) * l
    elif (l < len(str(n))):
        ans += (9 * 10**(l - 1)) * l
    else:
        break

print(ans)


n,m = input().split()
m=int(m)
n=int(n)
arr = sorted(map(int,input().split()))
mini=999999999
for j in range(m-n+1):
 if (arr[j+n-1]-arr[j]<mini):
   mini=arr[j+n-1]-arr[j]
print (mini)


n=int(input())
inp = list(map(int,input().split()))
from collections import Counter
c=Counter(inp)
inp=list(c.keys())
inp.sort()
if(len(inp)>3):
    flag=0
    for i in range(len(inp)-3+1):
        if(inp[i+1]-inp[i]==1 and inp[i+2]-inp[i+1]==1):
            flag=1
            print ('YES')
            break
    if(flag==0):
        print ('NO')
else:
    if(len(inp)==3):
        if(inp[1]-inp[0]==1 and inp[2]-inp[1]==1):
            print ('YES')
        else:
            print ("NO")
    else:
        print ('NO')


n=input()
count=0
for i in n:
    if i=='4' or i=='7':
        count+=1
if count==4 or count==7:
    print("YES")
else:
    print("NO")


w,h,k=map(int,input().split())
count=0
for i in range(1,k+1):
    count+=2*(w-4*(i-1))+2*(h-4*(i-1))-4
print(count)


from collections import Counter
s = input()
if '4' in s or '7' in s:
    print(Counter(sorted([elt for elt in s if elt in ['4', '7']])).most_common(1)[0][0])
else:
    print(-1)


import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools
from collections import deque,defaultdict,OrderedDict
import collections

def main():
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")

    #Solving Area Starts-->
    for _ in range(1):
        n=ri()
        a=ria()
        a=sorted(a)
        s=0
        for i in range(1,n,2):
            s+=a[i]-a[i-1]
        wi(s)

    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")

class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)

class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush

if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()


n,m=map(int,input().split())
li=list(map(int,input().split()))
li=sorted(li)
li1=sorted(list(map(int,input().split())))
a=max(li1)*10+max(li)
for i in li1:
 if i in li:
  a=i
  break
a1=min(li)
b1=min(li1)
b=min((a1*10+b1),(b1*10+a1))
print(min(a, b))


def win(a, b, a1, b2):
    return a > b2 and b > a1

a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = map(int, raw_input().split())
d = map(int, raw_input().split())

if win(a[0], b[1], c[0], d[1]) and win(a[0], b[1], d[0], c[1]) or win(b[0], a[1], c[0], d[1]) and win(b[0], a[1], d[0], c[1]):
    print 'Team 1'
elif (win(c[0], d[1], a[0], b[1]) or win(d[0], c[1], a[0], b[1])) and (win(c[0], d[1], b[0], a[1]) or win(d[0], c[1], b[0], a[1])):
    print 'Team 2'
else:
    print 'Draw'


def main():
    c, hr, hb, wr, wb = map(int, raw_input().split())
    if wr < wb:
        wr, wb = wb, wr
        hr, hb = hb, hr
    if wr > 10005:
        ans = 0
        for i in xrange(c / wr + 1):
            t = i * hr + (c - i * wr) / wb * hb
            if t > ans:
                ans = t
        print ans
        return
    ans = 0
    for i in [0, 1]:
        k = c / wr
        for j in xrange(10010):
            i = k + j
            if i * wr > c:
                break
            t = i * hr + (c - i * wr) / wb * hb
            if t > ans:
                ans = t
        for j in xrange(10010):
            i = k - j
            if i < 0:
                break
            t = i * hr + (c - i * wr) / wb * hb
            if t > ans:
                ans = t
        wr, wb = wb, wr
        hr, hb = hb, hr
    print ans
main()


from itertools import accumulate as _accumulate
import sys as _sys

def main():
    n, k = _read_ints()
    s = input()
    t = input()
    result = find_best_score_can_make(s, t, moves_n=k)
    print(result)

def _read_ints():
    return map(int, _sys.stdin.readline().split(" "))

_A = "a"
_B = "b"
_C = "c"

def find_best_score_can_make(s, t, moves_n):
    assert len(t) == 2
    if t[0] == t[1]:
        t_char = t[0]
        t_char_count = s.count(t_char)
        t_char_count += moves_n
        if t_char_count > len(s):
            t_char_count = len(s)
        return t_char_count * (t_char_count - 1) // 2

    s = [(_A, _B)[t.index(char)] if char in t else _C for char in s]
    s = ''.join(s)
    del t

    a_indices, b_indices, c_indices = _compute_abc_indices(s)

    best_score = -float("inf")

    max_c_start = min(len(c_indices), moves_n)
    for c_start in range(0, max_c_start+1):
        c_start_moves_spent = c_start
        moves_spent = c_start_moves_spent
        moves_remain = moves_n - moves_spent
        assert moves_remain >= 0

        max_b_start = min(len(b_indices), moves_remain)
        for b_start in range(0, max_b_start+1):
            b_start_moves_spent = b_start
            moves_spent = c_start_moves_spent + b_start_moves_spent
            moves_remain = moves_n - moves_spent
            assert moves_remain >= 0

            new_s = list(s)
            for i_i_c in range(0, c_start):
                i_c = c_indices[i_i_c]
                new_s[i_c] = _A
            for i_i_b in range(0, b_start):
                i_b = b_indices[i_i_b]
                new_s[i_b] = _A

            curr_best_score = _find_best_score_can_make_with_fixed_starts(new_s, moves_remain)
            best_score = max(best_score, curr_best_score)

    return best_score

def _compute_abc_indices(s):
    a_indices = []
    b_indices = []
    c_indices = []
    for i_char, char in enumerate(s):
        if char == _A:
            a_indices.append(i_char)
        elif char == _B:
            b_indices.append(i_char)
        else:
            assert char == _C
            c_indices.append(i_char)
    return a_indices, b_indices, c_indices

def _find_best_score_can_make_with_fixed_starts(s, moves_n):
    s = list(s)

    best_score = -float("inf")

    a_indices, b_indices, c_indices = _compute_abc_indices(s)

    a_n = len(a_indices)
    c_n = len(c_indices)

    max_a_stop = len(a_indices)
    max_c_stop = len(c_indices)

    def get_c_stop_by_moves_remain(moves_remain):
        min_c_stop = max_c_stop - moves_remain
        if min_c_stop < 0:
            min_c_stop = 0
        c_stop = min_c_stop
        return c_stop

    first_c_stop = get_c_stop_by_moves_remain(moves_n)
    new_s = _get_curr_s(s, a_indices, max_a_stop, c_indices, first_c_stop)
    curr_score = _get_curr_score_slow_way(new_s)

    best_score = max(best_score, curr_score)

    old_a_before = _compute_a_before(new_s)
    old_b_after_if_all_c_are_b = _compute_b_after(''.join(new_s).replace(_C, _B))

    curr_b_to_c_before_a = 0
    curr_a_to_b_after_c = 0

    prev_c_stop = None
    c_stop = first_c_stop
    c_stop_moves_spent = max_c_stop - c_stop

    min_a_stop = max_a_stop - moves_n
    min_a_stop = max(min_a_stop, 0)
    for a_stop in reversed(range(min_a_stop, max_a_stop-1 + 1)):
        a_stop_moves_spent = max_a_stop - a_stop
        moves_spent = a_stop_moves_spent
        moves_remain = moves_n - moves_spent
        assert moves_remain >= 0

        # a_stop update processing

        # s[a_indices[a_stop]]: _A -> _B
        # curr_score -= b_after[a_indices[a_stop]]
        # curr_score += a_before[a_indices[a_stop]]
        # prev_a_stop - a_stop == 1
        assert a_stop_moves_spent > 0

        curr_a_index = a_indices[a_stop]
        curr_b_to_c = c_stop
        if curr_b_to_c_before_a < curr_b_to_c \
                and c_indices[curr_b_to_c_before_a] < curr_a_index:
            while curr_b_to_c_before_a < curr_b_to_c \
                    and c_indices[curr_b_to_c_before_a] < curr_a_index:
                curr_b_to_c_before_a += 1
        elif curr_b_to_c_before_a > 0 \
                and c_indices[curr_b_to_c_before_a-1] > curr_a_index:
            while curr_b_to_c_before_a > 0 \
                    and c_indices[curr_b_to_c_before_a-1] > curr_a_index:
                curr_b_to_c_before_a -= 1

        prev_a_stop_moves_spent = a_stop_moves_spent - 1  # exclude curr move
        curr_b_to_c_after_a = curr_b_to_c - curr_b_to_c_before_a
        new_b_after = prev_a_stop_moves_spent - curr_b_to_c_after_a
        b_after = old_b_after_if_all_c_are_b[curr_a_index] + new_b_after
        curr_score -= b_after
        curr_score += old_a_before[curr_a_index]

        # c stop update

        prev_c_stop = c_stop
        c_stop = get_c_stop_by_moves_remain(moves_remain)
        c_stop_moves_spent = max_c_stop - c_stop

        # c_stop update processing

        assert c_stop - prev_c_stop in (0, 1)
        if c_stop - prev_c_stop == 1:
            # s[c_indices[prev_c_stop]]: _B -> _C
            # curr_score -= a_before[c_indices[prev_c_stop]]
            assert 0 <= prev_c_stop < len(c_indices)

            prev_c_index = c_indices[prev_c_stop]
            curr_a_to_b = a_n - a_stop
            if curr_a_to_b_after_c < curr_a_to_b \
                    and a_indices[a_n - (curr_a_to_b_after_c + 1)] > prev_c_index:
                while curr_a_to_b_after_c < curr_a_to_b \
                        and a_indices[a_n - (curr_a_to_b_after_c + 1)] > prev_c_index:
                    curr_a_to_b_after_c += 1
            elif curr_a_to_b_after_c > 0 \
                    and a_indices[a_n - curr_a_to_b_after_c] < prev_c_index:
                while curr_a_to_b_after_c > 0 \
                        and a_indices[a_n - curr_a_to_b_after_c] < prev_c_index:
                    curr_a_to_b_after_c -= 1

            a_to_b_before = curr_a_to_b - curr_a_to_b_after_c
            curr_a_before = old_a_before[prev_c_index] - a_to_b_before
            curr_score -= curr_a_before

        # saving result
        best_score = max(best_score, curr_score)

    return best_score

def _get_curr_s(s, a_indices, a_stop, c_indices, c_stop):
    s = list(s)
    for i_i_a in range(a_stop):
        i_a = a_indices[i_i_a]
        s[i_a] = _A
    for i_i_a in range(a_stop, len(a_indices)):
        i_a = a_indices[i_i_a]
        s[i_a] = _B
    for i_i_c in range(c_stop):
        i_c = c_indices[i_i_c]
        s[i_c] = _C
    for i_i_c in range(c_stop, len(c_indices)):
        i_c = c_indices[i_i_c]
        s[i_c] = _B
    return s

def _get_curr_score_slow_way(s):
    curr_score = 0
    a_accumulated = 0
    for char in s:
        if char == _A:
            a_accumulated += 1
        elif char == _B:
            curr_score += a_accumulated
    return curr_score

def _compute_a_before(s):
    result = tuple( _accumulate(int(char == _A) for char in s) )
    result = (0,) + result[:-1]
    return result

def _compute_b_after(s):
    result = tuple( _accumulate(int(char == _B) for char in s[::-1]) )[::-1]
    result = result[1:] + (0,)
    return result

if __name__ == '__main__':
    main()


k, b, n, t = map(int, raw_input().split())

x = 1
time = 0
while(x<=t):
    x = x*k+b
    time += 1
print max(n-time+1,0)


import collections
s=list(map(int,input().split()))
n=s[0]
m=s[1]
mydict={}
arrofsize=[]
arrofwts=[]
for i in range(m):
    t=input().split()
    arrofsize.append(int(t[0]))
    arrofwts.append(int(t[1]))
arrofwts2=list(set(arrofwts))
for i in arrofwts2:
    counts=0
    for j in range(0,len(arrofwts)):
        if(i==arrofwts[j]):
            counts+=arrofsize[j]
    mydict[i]=counts

size=list(mydict.values())
wt=list(mydict.keys())
arr=sorted(mydict.items())
count=0
i=len(wt)-1
while(i>=0):
    w1=arr[i][0]
    s1=arr[i][1]
    if(n>=s1):
        count=count+(s1*w1)
        n=n-s1

    elif(n<s1):
        count=count+(n*w1)
        n=n-n
    i=i-1
print(count)


# -*- coding: utf-8 -*-
"""
Created on Sat Sep  7 08:39:57 2019

@author: avina
"""

n,m = map(int, input().split())
k = pow(2,n) - 1
lo = 0; hi = k
i = 0
while lo <= hi:
    mid = (lo+hi) // 2

    if mid  > m-1:
        hi = mid -1

    elif m -1 > mid:
        lo = mid + 1

    else:
        break
    i+=1
print(n - i)


def solve(year):
    while(True):
        year = str(int(year)+1)
        if(len(set(year))==4):
            return year

if __name__ == "__main__":
    print(solve(input()))


#import resource
#import sys
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
#sys.setrecursionlimit(0x1000000)
from sys import stdin, stdout
mod=(10**9)+7
mod1=mod-1
def modinv(n,p):
    return pow(n,p-2,p)
fact=[1]
for i in range(1,100001):
    fact.append((fact[-1]*i)%mod)
def ncr(n,r,p):
    t=((fact[n])*(modinv(fact[r],p)%p)*(modinv(fact[n-r],p)%p))%p
    return t
def GCD(x, y):
   while(y):
       x, y = y, x % y
   return x
def BS(arr, l, r, x):
    if r >= l:
        mid = l + (r - l)/2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return BS(arr, l, mid-1, x)
        else:
            return BS(arr, mid+1, r, x)
    else:n -1
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import math
import heapq
from random import randint as rn
from Queue import Queue as Q
def comp(x,y):
    if(x[0]<y[0]):
        return -1
    elif(x[0]==y[0]):
        if(x[1]<y[1]):
            return -1
        else:
            return 1
    else:
        return 1
"""*********************************************************************************"""
a=map(int,raw_input().split())
a.sort()
k=max(a[2]-a[1]-a[0]+1,0)
print k


def next_minute(h, m):
  if m < 59:
    m += 1
  else:
    m = 0
    if h < 23:
      h += 1
    else:
      h = 0
  return h, m

s = raw_input()
h = int(s[:2])
m = int(s[3:])
while 1:
  h, m = next_minute(h, m)
  s = '%02d:%02d' % (h, m)
  if s == s[::-1]:
    break

print s


def solve(s, t):
    def is_sub(t, s):
        j = 0
        for x in s:
            if j < len(t) and x == t[j]:
                j += 1
            if j == len(t): return True
        return False

    cs, ct = {}, {}
    for x in s:
        if not x in cs:
            cs[x] = 0
        cs[x] += 1
    for x in t:
        if not x in ct:
            ct[x] = 0
        ct[x] += 1
    for x, c in ct.items():
        if not x in cs or c > cs[x]: return 'need tree'
    nauto = is_sub(t, s)
    nboth = False
    for x, c in cs.items():
        if not x in ct or c > ct[x]: nboth = True
    if nauto: return 'automaton'
    if nboth: return 'both'
    return 'array'

print solve(raw_input(), raw_input())


#####--------------Template Begin-------------------#####
import sys
#input = sys.stdin.readline
def i(): #Regular input
	return input()
def ii(): #integer input
	return int(input())
def li(): #list input
	return input().split()
def mi(): #map input
	return list(map(int, input().split()))
#####---------------Template Ends-------------------######
k, r=mi()
c=0
ans=0
while True:
	c+=k
	ans+=1
	if (c-r)%10==0 or c%10==0:
		print(ans)
		break


a, b, c = map(int, raw_input().split())
res = []
for i in xrange(82):
  x = b * (i ** a) + c
  if 0 < x < 1000000000 and sum(map(int, str(x))) == i:
    res.append(x)
print len(res)
for a in res:
  print a,


n, k = input().split()
n = eval(n)
time = 240
time -= eval(k)
for i in range(n, -1, -1):
	ans = n * (n + 1) // 2 * 5
	if (ans <= time):
		break
	n -= 1
print(n)


def mp():
    return map(int,str(raw_input()).strip().split())

from fractions import gcd
from math import *

c,v0,v1,a,l=mp()
n=0
while c>0:
    c-=v0
    if c>0:
        c+=l
        if v0<=(v1-a):
            v0+=a
        else:
            v0=v1
    n+=1
print n


import sys
from os import path
if(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):
    sys.stdin = open("C:/Users/prana/Desktop/sublime/input.txt","r")
    sys.stdout = open("C:/Users/prana/Desktop/sublime/output.txt","w")

# ----------------------------------------------------------------------

def solve():
    n,d=input().split()
    n=int(n)
    d=int(d)
    s=list(input())
    i=0
    count=0
    temp=0
    while i <(n-1):
        j=d
        while j>0:
            if i+j<n:
                # print(i,j,file = sys.stderr)
                if s[i+j] !="1":
                    j-=1
                else:
                    # print(1,file = sys.stderr)
                    count+=1
                    i+=j
                    break
            else:
                # print(i,j,file = sys.stderr)

                j-=1
        # print(j,file = sys.stderr)
        if j==0:
            temp=1
            break
    if temp==0:
        print(count)
    else:
        print(-1)

T = 1
# T = int(input())
for _ in range(1,T+1):
    print("Case #", _ , file = sys.stderr)
    solve()


import sys
import math

inp = [[int(j) for j in i.split(' ')] for i in sys.stdin.read().strip().splitlines()]

def gcd(x1, x2):
    if x1 == x2 or x2 == 0:
        return x1
    elif x2 > x1:
        return gcd(x2, x1)
    else:
        return gcd(x1%x2, x2)

n, m, x, y, a, b = inp[0]
res = []

g = gcd(a, b)
a /= g
b /= g

w = n - n%a
h = w * b / a

if h > m:
    h = m - m%b
    w = h * a / b

X = x - w/2.0
Y = y - h/2.0

xx = X
yy = Y
if xx < 0: xx = 0
if yy < 0: yy = 0
if xx > n-w: xx = n-w
if yy > m-h: yy = m-h

res = (xx, yy, xx+w, yy+h)

sys.stdout.write(' '.join([str(int(math.floor(i))) for i in res]))


import math

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

x, y = 10 ** 11, 0
for s in [(1 - a + MOD) % MOD, 1 + a]:
    for i in range(n):
        t = k * i + 1

        el1 = (t - b + MOD) % MOD
        if el1 == 0:
            el1 = MOD
        l1 = (el1 - s + MOD)
        m = MOD // math.gcd(l1, MOD)
        x, y = min(x, m), max(y, m)

        el2 = (t + b + MOD) % MOD
        if el2 == 0:
            el2 = MOD
        l2 = (el2 - s + MOD)
        m = MOD // math.gcd(l2, MOD)
        x, y = min(x, m), max(y, m)

print(x if x != 10 ** 11 else 0, y)


s1=input()
s2=input()
week=["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
if week[(week.index(s1)+31)%7]==s2:print("YES")
elif week[(week.index(s1)+28)%7]==s2:print("YES")
elif week[(week.index(s1)+30)%7]==s2:print("YES")
else:print("NO")


a = input()
b = input()

res = ''

i = 0
while i < len(a):
    if a[i]==b[i]:
        res += '0'
    else:
        res += '1'
    i +=1

print(res)


n = input()
chisla = set([i*(i+1)/2 for i in range(1, 50000)])

if any([(n - h) in chisla for h in chisla]):
    print "YES"
else:
    print "NO"


import math

N = int(input())
S = str(input())
K = len(S)
dp = []
ans = math.inf
for i in range(66):
	dp.append([])
	for j in range(66):
		dp[i].append(-1)
dp[K][0] = 0

def comp(x, y, v):
	if dp[x][y] == -1 or dp[x][y] > v:
		dp[x][y] = v

for i in range(K - 1, -1, -1):
	for j in range(1, K + 1):
		cur = 0
		if S[i] == '0':
			dp[i][j] = dp[i + 1][j - 1]
			continue
		for k in range(i, K):
			cur = cur * 10 + int(S[k])
			if cur >= N:
				break
			if dp[k + 1][j - 1] != -1:
				comp(i, j, cur * (N**(j-1)) + dp[k + 1][j - 1])

for i in range(1, K + 1):
	if dp[0][i] != -1:
		ans = min(ans, dp[0][i])
print(ans)


k = int(input())

if k==2: print(2)
else: print(1)


import math
n = int(input())
divisors = []
min_ = 10e18
for i in range(1, int(math.sqrt(n)) + 1):
    divisors.append((i, n // i, n % i))
for pair in divisors:
    if pair[0] + pair[1] + int(pair[2] != 0) < min_:
        #print(pair[0], pair[1], pair[2])
        min_ = pair[0] + pair[1] + int(pair[2] != 0)
print(min_)


def bad(s):
    if(len(s) > 1 and s[0] == '0'): return False
    if(int(s) > 1000000): return False
    return True

s = input()
n = len(s)
ans = -1
for i in range(1, n + 1):
    for j in range(i + 1, n):
        if(bad(s[:i]) and bad(s[i : j]) and bad(s[j :])):
            ans = max(ans, int(s[:i]) + int(s[i:j]) + int(s[j:]))

print(ans)


total_teams,team1,team2 = map(int,input().split())

count = 1
while True:
	if round((team1/2)+0.1)==round((team2/2)+0.1):
		break

	team1=round((team1/2)+0.1)
	team2=round((team2/2)+0.1)
	total_teams//=2
	count+=1

if total_teams==2:
  print('Final!')
else:

  print(count)


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

#days = sorted([*map(int, input().split())], reverse=True)
days = [*map(int, input().split())]
res = 0
next_day_candies = 0
for i in days:
	res += 1
	if i >= 8:
		k -= 8
		next_day_candies += i - 8
	elif next_day_candies >= 8:
		next_day_candies -= 8
		k -= 8
		next_day_candies += i
	elif next_day_candies > 0:
		next_day_candies += i
		if next_day_candies >= 8:
			next_day_candies -= 8
			k -= 8
		else:
			k -= next_day_candies
			next_day_candies = 0
	elif i > 0:
		k -= i

	#print(k)
	if k <= 0:
		print(res)
		break
else:
	print(-1)


import math
from collections import deque
def p(mid, arr, k):
	counter = 0
	#d = deque()
	totalSum = 0
	#sliding window
	#print (arr)
	size = 0
	for i in range(a, b+1):
		size += 1
		#d.append(arr[i])

		totalSum += arr[i]
		takeAway = 0
		if size > mid:
			takeAway = arr[i - mid]

		totalSum -= takeAway

		if size >= mid:
			if totalSum < k:
				return False

	if totalSum < k:
		return False
	return True

splitted = raw_input().split(" ")
a = int(splitted[0])
b = int(splitted[1])
k = int(splitted[2])

#generate primes up to b, using sieve
sieve = [True] * (b + 1)
primes = deque()
for i in range(2, b + 1):
	#print (i)
	if sieve[i]:
		primes.append(i)
	else:
		continue
	j = 2 * i
	while j < b + 1:
		sieve[j] = False
		j += i

arr = [0] * (b + 1)
for prime in primes:
	arr[prime] = 1
#print (primes)
#print (arr)
counter = 0
savedI = -1
low = 1
high = b - a + 1
while low + 1 < high:
	mid = low + (high - low)/2
	#print (str(low) + ", " + str(high))
	if p(mid, arr, k) == True:
		high = mid
		#print (str(mid) + " returned true")
	else:
		low = mid
		#print (str(mid) + " returned false")
if p(high, arr, k) == True:
	print (high)
else:
	print (-1)


import math

n = int(input())

val = []
min_size = []

for i in range(math.trunc(math.sqrt(1000000))+1):
    val.append(i*(i-1)+1)
    min_size.append(4*i)
    val.append(i*i+1)
    min_size.append(4*i + 2)

last = 0

for idx in range(len(val)):
    if n < val[idx]:
        print(last)
        break
    else:
        last = min_size[idx]


def generate_substring(s):
    list = []
    ll = len(string)
    for i in range(ll):
        for j in range(i, ll):
            list.append(s[i:j + 1])
    return list

n = input()
string = raw_input()
ans = 0
sumH = 0
sumW = 0

for x in generate_substring(string):
    sumH = 0
    sumW = 0
    for char in x:
        if char == "U":
            sumH += 1
        if char == "D":
            sumH -= 1
        if char == "L":
            sumW -= 1
        if char == "R":
            sumW += 1
    if sumH == 0 and sumW == 0:
        ans += 1

print ans


import sys,math
n=int(input())
s=input()
ans=0
i=n-1
flag=True
while(i>=0):
    if i%2==1 and s[:i//2+1]==s[i//2+1:i+1] and flag:
        ans+=1
        i//=2
        flag=False
    else:
        i-=1
        ans+=1
print(ans)


n = int(raw_input())
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())

if b > n or (b - c) >= a:
    print n // a
    exit(0)

num = n // (b - c)

r = n - num * (b - c)
if r < c:
    d = c - r
    adjustment = (d + (b - c) - 1) / (b - c)
    num -= adjustment
    r += (b - c) * adjustment

num += r // a
print num


n, p, k = map(int, input().split())
ans = ""
for num in range(p - k, p + k + 1):
    if n >= num > 0:
        if num == p:
            ans += "(" + str(num) + ")"
        else:
            ans += str(num)
        if num != p + k:
            ans += " "
# print(ans)
if p - k > 1:
    ans = "<< " + ans
if p + k < n:
    ans += " >>"
print(ans)


n=input()
a=map(int,raw_input().split())
d=a[1]-a[0]
for i in range(1,n):
    if a[i]-a[i-1]!=d:
        print a[-1]
        break
else:
    print a[-1]+d


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

if  x > 0 and y > 0:
    print(0, x + y, x + y, 0)
elif x < 0 and y > 0:
    print(-y + x, 0, 0,-x + y)
elif x > 0 and y < 0:
    print(0, y - x, x - y, 0)
else:
    print(x + y, 0,0, x + y)


a = input()
b = input()
c = input()
d = a + b + c
if a[0] == c[2] and a[1] == c[1] and b[0] == b[2] and a[2] == c[0]:
	print('YES')
else:
	print('NO')


a,b,c,d = map(int, input().split())
s1 = max(0.3 * a, int(a * (1 - c / 250)))
s2 = max(0.3 * b, int(b * (1 - d / 250)))
if s1 > s2:
	print('Misha')
elif s1 == s2:
	print('Tie')
else:
	print('Vasya')


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

def main():
    n=inint()
    a=inlist()
    sol=999999999
    for j in range(n):
        sol1=0;x=j
        for i in range(n):
            sol1+=a[i]*(abs(i-x)+i+x+abs(x-0)+abs(i-0)+abs(x-i))
        sol=min(sol,sol1)
    print(sol)

if __name__ == "__main__":
    #import profile
    #profile.run("main()")
    main()


#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def Ceil(a,b): return a//b+int(a%b>0)
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
# vsInput()

l,r=value()
ans=0

R=len(bin(r))-2

for i in range(61):
    if(l&(1<<i) ^ r&(1<<i)):
        ans=2**(i+1)-1

print(ans)


s, v = input(), set()
while s not in v:
    v.add(s)
    s = s[-1] + s[:-1]
print(len(v))


import math

def res(arr):
    diff = 0
    for i in range(3):
        diff =  diff ^arr[i]
    if diff == 0:
        return 1

    for i in range(2):
        if  brr[i]%arr[i] != 0:
            continue
        div = brr[i] // arr[i]
        count = 0
        for j in range(i+1,3):
            if brr[j]%arr[j] != 0:
                continue
            if div == brr[j]//arr[j]:
                count +=1
        if count > 1:
            return 2
def solution():

    n = int(input())
    low = math.floor(n**(1/10))
    st = 'codeforces'
    cal = low**(10)
    lo = [low for i in range(10)]
    for i in range(0,10):
        if cal >= n:
            break
        lo[i] = low+1
        cal = cal// low
        cal *= (low+1)
    # print(lo)
    for i in range(10):
        print(st[i]*lo[i],end= '')

solution()