#for input: list(int(i) for i in raw_input().split())
def main():
	n = map(int,raw_input().split())
	if n%2==0:
		print "white"
		print "1 2"
	else:
		print "black"

if __name__ == '__main__':
    main()


input_string=str(input())
word = "hello"
index = 0
for i in range(0,len(input_string)):
    if(index==5):
        print("YES")
    if(input_string[i]==word[index]):
        index+=1

if(index<5):
    print("NO")
else:
    print("YES")


import math

def sum2(s, e):
    return sum1(e) - sum1(s - 1) - (e - s)

def sum1(i):
    return i * (i + 1) / 2

n = int(input())
k = int(input())
if(n == 1):
    print(0)
elif(k > n):
    print(1)
elif(sum2(2,k) < n):
    print(-1)
else:
    c = 2 * n + k - k * k
    discriminant = math.sqrt(9 - 4 * c)
    res1 = math.floor((3 + discriminant) / 2)
    res2 = math.floor((3 - discriminant) / 2)
    res1 = max(res1, res2)
    print(int(k - res1 + 1));


import math
from decimal import Decimal

def sum2(s, e):
    return sum1(e) - sum1(s - 1) - (e - s)

def sum1(i):
    return i * (i + 1) / 2

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

if(n == 1):
    print(0)
elif(k > n):
    print(1)
elif(sum2(Decimal(2),k) < n):
    print(-1)
else:
    c = 2 * n + k - k * k
    discriminant = (9 - 4 * c).sqrt()
    res1 = math.floor((3 + discriminant) / 2)
    res2 = math.floor((3 - discriminant) / 2)
    res1 = max(res1, res2)
    print(k - res1 + 1);


import math
from decimal import Decimal

def sum2(s, e):
    return sum1(e) - sum1(s - 1) - (e - s)

def sum1(i):
    return i * (i + 1) / 2

line = raw_input().split()
n = Decimal(line[0])
k = Decimal(line[1])
if(n == 1):
    print 0
elif(k > n):
    print 1
elif(sum2(Decimal(2),k) < n):
    print -1
else:
    c = 2 * n + k - k * k
    discriminant = (9 - 4 * c).sqrt()
    res1 = math.floor((3 + discriminant) / 2)
    res2 = math.floor((3 - discriminant) / 2)
    res1 = max(res1, res2)
    print k - res1 + 1


import numpy as np
s=input().split(" ")
print(int(((int(s[3])-int(s[2]))/np.lcm(int(s[0]),int(s[1])))+1))


n = int(raw_input())

fib = [0] * 55

fib[0] = 0
fib[1] = 2
fib[2] = 3

for x in xrange(3, len(fib)):
    fib[x] = fib[x-1] + fib[x-2]

x = 0

while fib[x] <= n:
    x += 1

print x - 1


n = int(raw_input())

a = [1, 2]
while a[-1] <= n:
    a.append(a[-1] + a[-2])

while True:
    try:
        p = a.index(n)
        break
    except:
        n -= 1
        continue

print p
# print a


S = input()
s = set(S)
for i in range(len(S)):
    tmp = s[i:]+s[:i]
    s.add(tmp)
print(len(s))


s = input()
a = {[s[i:]+s[:i] for i in range(len(s))]}
print(len(a))


a=list(input())
c=len(a)
if len(set(a))==1:print(1)
elif c%2==1:print(c)
else:
	b,f=2,0
	while b<=c:
		if c%b==0:
			d=c//b
			k=[]
			for x in range(b):
				k.append(tuple(a[x*d:(x+1)*d]))
			if len(set(k))==1:
				print(d)
				f=1
				break
			else:b+=1
	if f==0:print("c")


s = input()
our = set()
for i in range(50):
    res.add(s)
    s = s[-1] + s[:-1]
print(len(res))


a=input()
m=set()
for i in len(a):
	m.add(a[i:]+a[:i])
print(len(m))


n = int(input())
strs = input()
s = 'xxx'
if s in strs:
    while True:
        strs.replace(s, 'xx')
        if s in strs:
            continue
        else:
            break
print(n - len(strs))


from functools import reduce
n,x,p=list(map(int,input().split()))
def fac(n):
    if(n==0):
        return 1
    return reduce(lambda x,y:x*y, range(1,n+1))

a=0
b=-1
left=0
right=n
while(left<right):
    middle=(left+right)//2
    if(p>=middle):
        left=middle+1
        b+=1
    else:
        right=middle
        a+=1

A=fac(x-1)//fac(x-b-1)
N=fac(n-x)//fac(n-x-a)
S=fac(n-a-b-1)
print((A*N*S)%(10**9+7))


import math
n = int(input())
print( (math.floor(i)+1) * (n-1) )


n=int(input())
while(n>=0):
    ans+=n
    n-=2
print(ans)


x = int(input())
if x%2 == 1:
	m = (x+1)/2
else:
	m = x/2
count = 0
for i in range(1,m+1):
	count += i
if x%2 == 1:
	print(count*2 - m)
else:
	print(count*2)


import math

def split(word):
    return [char for char in word]

fin = open("segment.in" , 'r')
fout = open("segment.out" , "w" )

gene = split(fin.readline().strip('\n'))
n = len(gene)
max = []
counter = 1

for i in range(1, n):
    if gene[i] == gene[i-1]:
        counter += 1
    else:
        max.append(counter)
        counter =1
max.append(counter)

answer = 0
for i in range(0, len(max) ):
    if max[i] %2 == 0:
        answer += 1
    else:
        answer += 0

print(answer)


# # import numpy as np
#
# def spliter(arr,low,high):
#     if(high-low==1):
#         # print("1")
#         return 1
#
#     if(arr[low:high]==sorted(arr[low:high])):
#         # print("here "+str(high-low))
#         return high-low
#     else:
#         mid=(high+low)//2
#         # print("----------")
#         # print((low,mid))
#         # print("---------")
#         # print((mid,high))
#         # print("-----------")
#         a=spliter(arr,low,mid)
#         # print("was here")
#         b=spliter(arr,mid,high)
#
#         # print((a,b))
#         if(a>=b):
#             return a
#         else:
#             return b
#
# def main():
#     n=int(input())
#     arr=list(map(int,input().split(" ")))
#     lenght = n
#     if arr==sorted(arr):
#         print(n)
#     else:
#         mid=lenght//2
#         a=spliter(arr,0,mid)
#         b=spliter(arr,mid,lenght)
#         if(a>b):
#             print(a)
#         else:
#             print(b)
#
# main()

# def main():
#     checker="nineteen"
#     # n="nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii"
#     n=input()
#     number={}
#     # print(set(n))
#     for i in n:
#         if i in checker:
#             number[i]=number.get(i,0)+1
#     # number=sorted(number.values())
#     # print(sorted(number.keys()))
#     for i in ["n","t","i","e"]:
#         if i not in number.keys():
#             break
#
#     else:
#         num=number["i"]
#         min=num
#         other_Dict={"n":3,"i":1,"e":3,"t":1}
#         if(number["n"]%3==2):
#             number["n"]=number.get("n",0)+number["n"]//3
#
#         for i in number.keys():
#             if (number[i]//other_Dict[i]>=num):
#                 pass
#             elif(number[i]//other_Dict[i]<=num):
#
#                 if(min>number[i]//other_Dict[i]):
#                     min=number[i]//other_Dict[i]
#         else:
#             print(min)
#             return
#     print(0)
# main()
        # return False
    # for i,j in number:
    #     if i=="n" and i
#     # print(number)
# print(main())
# main()
# d={}
# d[10]=1
# d[10]+=2
# d[10].append(10)
# 2//3
# d.get(10,5)
# d.keys()
# main()
# d={}
# for i in "nineteen":
#    d[i]=d.get(i,0)+1
# d
# "i" not in d.keys()
# some="nineoindojaoidjoiajdoiaoidjiadjkajoidjoiajdljadjoiadlkjaadj"
# list(some.split("nineteen"))
#
#
# def main():
#     n=list(map(int,input().split(" ")))
#     navigation=[]
#     for i in range(n[1]-n[2],n[1]):
#         if(i>0):
#             navigation.append(i)
#     for i in range(n[1],n[1]+n[2]+1):
#         if(i<=n[0]):
#             navigation.append(i)
#     if(navigation[0]>1):
#         navi=[0]*len(navigation)
#         navi[0]="<<"
#         navi[1:len(navigation)]=navigation
#         navigation=navi
#     if(navigation[len(navigation)-1]<n[0]):
#         navigation.append(">>")
#     string=""
#     for i in navigation:
#         if(str(i)==str(n[1])):
#             string+="({}) ".format(i)
#         else:
#             string+="{} ".format(i)
#     print(string[:-1])
# main()

# question number Inna and Alarm Clock
# import numpy as np
# def inna_and_alarm_clock:
#     n=int(input())
#     matrix=[]
#     display=[[0]*100]*100
#     display=np.array(display)
#     rows=[]
#     columns=[]
#     for _ in range(n):
#         matrix.append(map(int,input().split(" ")))
#     # matrix=data
#     for i,j in matrix:
#         # print((i,j))
#         display[j][i]=1
#     print(np.array(display))
#     vertical_steps=0
#     horizontal_steps=0
#     for i in range(100):
#         if 1 in display[:,i]:
#             horizontal_steps+=1
#     for i in range(100):
#         if 1 in display[i,:]:
#             vertical_steps+=1
#     if(horizontal_steps<vertical_steps):
#         print(horizontal_steps)
#     else:
#         print(vertical_steps)
#
# # data=np.array([[1,1],[1,2],[2,3],[3,3]])
# main()
#
# arr=[[1,1],[1,2],[2,3],[3,3]]

#
# def inna_and_diam():
#     n=int(input())
#     a=list(map(float,input().split(" ")))
#     b=list(map(float,input().split(" ")))
#     iterr=list(zip(a,b))
#     happiness=0
#     for x,y in iterr:
#         # print("x={},y={}".format(x,y),end=" ")
#         # print((x,y))
#         if(x<y/2 or y==1):
#             happiness-=1
#         elif(x==y/2):
#             happiness+=x*x
#         elif(x>y/2):
#             if(y%2==0):
#                 x=y//2
#                 happiness+=x*x
#             else:
#                 x=(y+1)//2
#                 happiness+=(x*(y-x))
#         # print(happiness)
#             # happiness+=x*x
#     print(int(happiness))
# main()

def encode_protein():
    n=list(input())
    l=len(n)
    i=0
    j=0
    count=0
    while(i<l-1):
        while(n[i]==n[j]):
            j+=1
        if(j%2==0):
           count+=1
        i=j
    print(count)

encode_protein()


n = input()
count = 1
ans = 0
j = 0
while j < len(n)-1:
    if n[j] == n[j+ 1]:
        while n[j] == n[j+1]:
            count += 1
            j += 1
        if count%2 == 0:
            ans += 1
            count = 1
    else:
        j += 1
print(ans)


q=lambda:map(int,input().split())
x=input()
count=[]
c=1
for a,b in zip(x,x[1:]):
    if a==b: c+=1
    else:
        count.append(c)
        c=1
if a==b:count.append(c)
#print(count,len(count),len(x))
print(len([i for i in count if i%2==0]))


def solve(s):
    n = len(s)
    arr = [val for val in s]
    ans = 0
    count = 1
    # print(arr)
    for i in range(n - 1):
        if arr[i] == arr[i + 1]:
            count += 1
        else:
            if count % 2 == 0:
                ans += 1
            count = 1
    if count %2 == 0:
        ans += 1
    return ans

n = int(input())

for i in range(n):
    s = input()
    ans = solve(s)
    print(ans)


a=input()
total=1
ans=0
for i in range(len(a)):
    if a[i]==a[i+1]:
        total+=1
    else:
        if total%2:
            ans+=1
        total=0
print(ans)


import sys

sys_in = sys.argv[1]

def counter(dna):
	count = 1
	even_count = 0
	previous = dna[0]
	dna = dna[1:]
	while(dna != ""):
		if dna[0] == previous:
			count += 1
		else:
			previous  = dna[0]
			if count % 2 == 0:
				even_count += 1
			count = 1
		dna = dna[1:]
	return even_count

print(counter(sys_in))


copy =code = input()

# nucleotids = ['A', 'T', 'C', 'G']
pieces = list()
i = 0
while len(code) != 0:
    piece = code[i]
    for j in range(len(code)):
        if code[j] in piece:
            piece += code[j]
        else:
            exit_index = j
            break

    code = code[exit_index:]
    pieces.append(len(piece) - 1)

even = sum(1 for _ in pieces if _ % 2 == 0)
print(even)


A, B = map(int, raw_input().split())
a = reduce(lambda x, y: x * y, [i for i in range(1, A + 1)])
b = reduce(lambda x, y: x * y, [i for i in range(1, B + 1)])
def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)
print gcd(a, b)


r1,c1,r2,c2= map(int,input().split())
if abs(r2-r1)== abs(c2-c1):
    k= abs(r2-r1)
    r= 1
else:
    k= abs(r2-r1)+abs(c2-c1)
    r = 0
if r1==r2 and c1==c2:
    b= 0
elif r1==r2 or c1==c2:
    b= 1
else:
    b= 2
print(b,r,k)


def prod(n):
    x=str(n)
    y=['0']*len(x)
    for i in range(len(x)):
        y[i]=str(9-int(x[i]))
    while y[0]=='0':
        if len(y)==1:
            return 0
        else:
           y=y[1:len(y)]
    return int(x)*int(''.join(y))

x=[int(i) for i in input().split()]

s=0

for i in range(x[0],x[1]+1):
    if prod(i)>s:
        s=prod(i)
print(s)


inp1, inp2  = [int(i) for i in input().split()]
lista = list()

def reverse(n):
    '''newStr = ""
    for c in str(n):
        newC = 9 - int(c)
        newStr += str(newC)
    '''
    l = len(str(n))
    d = "9"*l
    d = int(d)
    newStr = d - int(n)
    return int(newStr)

for i in range(inp1,inp2 +1):
    w = reverse(i) * i
    lista.append(w)

print(max(lista))


n,m=map(int,raw_input().split())
l=len(str(m))
r=len(str(n))
a1=5*10**(l-1)
if l>r:
	if a1<=m:
		print (a1)*(a1-1)
	else:
		print (10**(l)-1-m)*m
else:
	if a1 >= n and a1<=m:
		print (a1)*(a1-1)
	else:
		ax=abs(a1-m)
		az=abs(a1-n)
		if ax>az:
			print m*(10**(l)-1-m)
		else:
			print (10**(r)-1-n)*n


import math
l, r = map(int, raw_input().split(' '))
order = math.floor(math.log10(r))

x = int(min(5*10**order, r))
phi = int(''.join(map(lambda e: chr(48 + 57 - (48 + int(e))), str(x))))

print x * phi


num=int(input());cou=0;
for i in range(1,num+1):
    if(len(set([int(j) for j in str(i)]))<=2):
        cou+=1
print(cou)


"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outln(var): sys.stdout.write(str(var)+"\n")
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

temp = pow(10, 8)

def dfs(number):
    if 0 < number <= n:
        answer[0] += 1
    if number >= temp:
        return
    for i in range(10):
        if number * 10 + i > 0:
            if len(set(str(number * 10 + i))) <= 2:
                dfs(number * 10 + i)

n = int(data())
answer = [0]
dfs(0)
if n > temp:
    outln(answer[0] + 1)
    exit()
outln(answer[0])


n=int(input())
curr=list([i for i in range(1,100)])
curr=set(curr)
def isvalid(x):
    if x<1 or x>10**9:
        return 0
    if len(set(str(x)))<=2:
        return 1
cnt=0
while cnt<=4*(10**4 ):
    curr1=set()
    for i in curr:
        for j in range(10):
            if isvalid(i*10+j):
                curr1.add(i*10+j)
               # print('hi')
                cnt+=1
    #print(curr1)
    curr|=curr1
curr=sorted(list(curr))
#print(curr)
ans=0
for i in curr:
    if i>=1 and i<=n:
        ans+=1
    elif i>n:
        break
print(ans)


n=int(input())
curr=list([i for i in range(1,100)])
curr=set(curr)
def isvalid(x):
    if x<1 or x>10**9:
        return 0
    if x>n:
        return 0
    if len(set(str(x)))<=2:
        return 1
cnt=0
while cnt<=(9*(10**4)):
    curr1=set()
    for i in curr:
        for j in range(10):
            if isvalid(i*10+j):
                curr1.add(i*10+j)
               # print('hi')
                cnt+=1
    #print(curr1)
    curr|=curr1
curr=sorted(list(curr))
#print(curr)
ans=0
for i in curr:
    if i>=1 and i<=n:
        ans+=1
    elif i>n:
        break
print(ans)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

n = int(input())
if n < 100:
    print(n)
    sys.exit()
a = [[_,set(map(int,list(str(_))))] for _ in range(100)]
c = 99
for k in range(2,11):
    t = (10 ** (k-1))
    for aa in a:
        if aa[0] >= t:
            break
        aa[1] |= set([0])
    for i in range(1,10):
        t = i * (10 ** k)
        for ai, ae in a[:]:
            ac = ai + t
            if ac > n:
                print(c)
                sys.exit()
            if len(ae) < 2:
                ae = ae | set([i])
            if i in ae:
                c += 1
                a.append([ac,ae])


n = input()

if n <= 10:
	print n
else:
	cnt = 9
	le = len(str(n))
	i = 1
	while i < le-1:
		cnt += (81*(1<<i-1) + 9)
		i += 1

	d = {}

	for i in xrange(1,10):
		d[(int(str(i)*le))] = 1

	for i in xrange(1,10):
		for j in xrange(10):
			if i != j:
				mask = 0
				while mask < (1<<le-1):
					tmp = ""
					for k in xrange(le-1):
						if (mask&(1<<k)) > 0:
							tmp = str(i) + tmp
						else:
							tmp = str(j) + tmp
					tmp = str(i) + tmp
					d[(int(tmp))] = 1
					mask += 1

	for key in d:
		if key <= n:
			cnt += 1
	print cnt


'''

   			 ||Sri:||

                      __|
 ______________|_________________________
      |    |   ___|    |    |    ___|      |      |    |___
 /\  /\    |   |___    |    |   |___|      |      |    |___|
/  \/  \   |   ___|    |    |         |_/    |___|    |___

I am a beginner. Feel free to send tutorials/help to srinivasan1995@gmail.com.

Codeforces, SPOJ handle: desikachariar.
Hackerrank, Codechef handle: Prof_Calculus.

Advices/Help are welcome. You will definitely get a thanks in return. Comments to be avoided.

College: International Institute of Information Technology, Bangalore.

'''

import math
count = 0
n = 0
def distinct_digits(a):
	d= {}
	for i in a:
		d[i] = 1
	return len(d)

def fn(num):
	global count, n
	if (num > 0 and num <= n):
		count+=1
	if (num >= 10**8):
		return
  	for a  in range(0, 10):
    		if num*10+a > 0 and distinct_digits(str( num*10+a )) <= 2:
			        fn( num*10+a )

if __name__ == '__main__':
	n=input()
	fn(0)
	print count


a=int(input())
if(n%2==1):
    print('black')
else:
    print('white')
    print(1,2)


#!/usr/bin/env python3
# created : 2020. 12. 31. 23:59

import os
from sys import stdin, stdout

def solve(tc):
    n = int(stdin.readline().strip())
    if n%2:
        print("black")
    else:
        print("white")
        print("1 2")

tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1


n = int(input())
a = list(map(int, input().split()))
print('white\n1 2' if n & 1 == 0 else 'black')


from sys import stdin

def mex(arr):
	arr = set(arr)
	arr = list(arr)
	arr.sort()
	i = 0
	while i < len(arr):
		if arr[i] > i:
			return i
		i += 1
	return i

def check_1(x, y):
	if x - 2 < 1:
		return False
	elif y + 1 > 15:
		return False
	return True

def check_2(x, y):
	if x - 2 < 1:
		return False
	elif y - 1 < 1:
		return False
	return True

def check_3(x, y):
	if x + 1 > 15:
		return False
	elif y - 2 < 1:
		return False
	return True

def check_4(x, y):
	if x - 1 < 1:
		return False
	elif y - 2 < 1:
		return False
	return True

def myfunction(dp, x, y):
	arr = []
	if check_1(x, y):
		arr.append(myfunction(dp, x - 2, y + 1))
		dp[x-2][y+1] = arr[-1]
	if check_2(x, y):
		arr.append(myfunction(dp, x - 2, y - 1))
		dp[x-2][y-1] = arr[-1]
	if check_3(x, y):
		arr.append(myfunction(dp, x + 1, y - 2))
		dp[x+1][y-2] = arr[-1]
	if check_4(x, y):
		arr.append(myfunction(dp, x - 1, y - 2))
		dp[x-1][y-2] = arr[-1]
	dp[x][y] = mex(arr)
	return dp[x][y]

def print_r(dp):
	for i in range(1, 16):
		print(dp[i][1:])

# main starts
t = int(stdin.readline().strip())
while t > 0:
	dp = [[-1 for i in range(16)] for j in range(16)]
	x, y = list(map(int, stdin.readline().split()))
	if (myfunction(dp, x, y)):
		print('First')
	else:
		print('Second')
	#print_r(dp)
	t -= 1


def main():
    n,m=map(int,input().split())
    Edges=[[] for _ in range(7)]
    for _ in range(m):
        a,b=map(lambda x: int(x)-1,input().split())
        Edges[a].append(b)
        Edges[b].append(a)
    L=[0]*7
    for i,E in enumerate(Edges):
        L[i]=[len(E),i]
    L.sort(reverse=True)
    if L[0][0]!=6:
        return m
    cnt=6
    for num,idx in L:
        tmp=6
        if num!=6:
            break
        for to in Edges[idx]:
            tmp=min(tmp,len(Edges[to])-1)
        cnt=min(cnt,tmp)
    return m-cnt

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


n,m=map(int,input().split())
edges=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
    edges[i][0]-=1
    edges[i][1]-=1
from itertools import permutations
l=list(permutations(range(6)))
mx=0
for ij in l:
    for seven in range(6):
        cnt=[None]*10
        for xi in range(6):
            cnt[xi]=[0]*10
            for xj in range(xi,6):
                cnt[xi][xj]=1
        numbering=[0]*10
        for i in range(6):
            numbering[i]=ij[i]
        numbering[6]=seven
        curr=0
        for e in edges:
            u,v=numbering[e[0]],numbering[e[1]]
            u,v=min(u,v),max(u,v)
            if cnt[u][v]:
                cnt[u][v]=0
                curr+=1
        mx=max(mx,curr)
print(mx)


a = list(map(int, input().split()))
n = a[0]
m = a[1]
graph = {}
for i in range(n):
    graph[i + 1] = []
for i in range(m):
    a = list(map(int, input().split()))
    graph[a[0]].append(a[1])

if n < 7:
    print(m)
else:
    vertices = []
    for k in graph.keys():
        vertices.append((k, len(graph[k])))
    sorted_vertices = sorted(vertices, key=lambda x: x[1])
    minimum_dominoes = 0
    for i in range(1, len(sorted_vertices)):
        if sorted_vertices[0][0] in graph[sorted_vertices[i][0]]:
            minimum_dominoes += sorted_vertices[i][1] - 1
        else:
            minimum_dominoes += sorted_vertices[i][1] - 1

    res = 0
    nums = [1, 1, 1, 1, 1, 1, 1]

    DOMINOES = set()
    for i in range(1, 7):
        for j in range(i, 7):
            DOMINOES.add((i, j))

    max_dominoes = 0
    while True:
        not_used_dominoes = set(DOMINOES)
        count = 0
        ignored = 0
        for v in graph:
            for child in graph[v]:
                domino = (min(nums[v - 1], nums[child - 1]), max(nums[v - 1], nums[child - 1]))
                if domino in not_used_dominoes:
                    count += 1
                    not_used_dominoes.remove(domino)
                else:
                    ignored += 1
                    if ignored > m - minimum_dominoes:
                        break
        max_dominoes = max(max_dominoes, count)
        if max_dominoes >= m:
            break
        j = len(nums) - 1
        while nums[j] == 6:
            nums[j] = 1
            j -= 1
        if j < 0:
            break
        nums[j] = nums[j] + 1

    print(max_dominoes)


n, m, r = map(int, input().split())
b = sorted(list(map(int, input().split())))[0]
s= sorted(list(map(int, input().split())))[-1]
p, q = divmod(r, b)
print(p*s*q if p*s*q>r else r)


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

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

pri_min = min(l)

qut = r // pri_min
rem = r % pri_min
z = max(k)
#print(f"{pri_min} {qut} {rem} {z}")

if z * qut >= r:
    print(z * qut+ rem)

else:
    print(r)


import math
l,r,x,y=map(int,input().split())
count=0
for i in range(l,r+1):
    if (x*y)%i==0:
        if math.gcd(i,x*y//i)==x:
            count+=1
print(count)


from math import sqrt

def res(x,y,l,r):
    count = 0
    prod = x*y
    for num in xrange(l,min(r+1,int(sqrt(prod))+1)):
        if prod%num == 0:
            num1 = num; num2 = prod/num
            G = gcd(num1,num2)
            L = prod/G
            if G == x and L == y:
                if num1 == num2:
                    count += 1
                else:
                    count += 2
    return count

def gcd(a,b):
    if a == 0 or b == 0:
        return max(a,b)
    elif a > b:
        return gcd(a%b,b)
    else:
        return gcd(b%a,a)

l,r,x,y = map(int, raw_input().split())
print res(x,y,l,r)


'''input
1 2 1 2

'''

from collections import defaultdict as df
from bisect import bisect_left as bl
from itertools import combinations as c
import sys
from math import *
from random import randint as R
import heapq as hp

l,r,a,b=[int(x) for x in raw_input().split()]

num=a*b

p=[]
c=0
def gcd(a,b):
	if b==0:
		return a
	return gcd(b,a%b)

for i in range(1,int(num**0.5)+1):
	if num%i==0:
		if l<=i<=r and l<=num/i<=r:
			if gcd(i,num/i)==a and (a*b)/gcd(i,num/i)==b:
				c+=2
				#print i,num/i
				if i*i==num:
					c-=1
print c


x, y, l, r = map(int, raw_input().split())
A = [1]
tmp = 1
while tmp <= 1e18:
    tmp *= x
    A.append(tmp)
B = [1]
tmp = 1
while tmp <= 1e18:
    tmp *= y
    B.append(tmp)
unluckies = []
for a in A:
    for b in B:
        tmp = a + b
        if tmp in range(l, r+1):
            unluckies.append(tmp)
unluckies = sorted(set(unluckies))
if l not in unluckies:
    unluckies = [l-1] + unluckies
if r not in unluckies:
    unluckies.append(r+1)
n = len(unluckies)
print(max([unluckies[i] - unluckies[i-1] for i in range(1,n)])-1)


from string import*
n = int(input())
#n,m = map(int,input().split())
a = list(map(int,input().split()))
s = list(ascii_lowercase)[:n]
res = ''
'''x = set()
for i in range(n):
    if a[i] in x:
        f = a[i]+1
        res.append(f*s[i])
        x.add(f)
    else:
        res.append(a[i]*s[i])
        x.add(a[i])
print(len(''.join(map(str,res))))'''

a.sort(reverse=True)
for i in range(n):
    x = a.count(a[i])
    if x>1:
        a[i]-=(x-1)

for i in range(n):
    res+=(a[i]*s[i])
print(len(res))


n=input()
c=0
a=input()
while a.find("xxx")!=-1:
	a.replace('x','')
	c+=1
print(c)


n = int(input())
count = 0
for i in range(1, n+1):
  for j in range(i+1, n+1):
    for k in range(j+1, n+1):
      if i+k>j and k+j>i and i+j>k and i^j^k==0:
        count+=1

print(count)


n = int(input())
ans = 0
for a in range(1, n + 1):
    for b in range(a, n + 1):
        for c in range(b, min(a + b, n + 1)):
            if a ^ b ^ c == 0:
                ans += 1
print(ans)


n=input()
C=0
for a in range(1,n+1):
    for b in range(a,n+1):
        for c in range(b,n+1):
            if(a^b^c==0 and c<a+b):
                C+=1

print C


import sys

def checkGenerate(a, b, c):
    if a + b <= c or a + c <= b or b +c <= a:
        return False
    return True

count = 0
n = input() + 1
for a in range(1, n):
    for b in range(a, n):
        for c in range(b, n):
            if checkGenerate(a, b, c):
                if a ^ b ^ c == 0:
                    count+=1
print count


a,ta=map(int,raw_input().split())
b,tb=map(int,raw_input().split())
h,m=map(int,raw_input().split(":"))
time=(h-5)*60+m

start=[time-tb,0][time-tb<0]
end=min(time+ta,1139)

stemp=start/b+1 if time-tb>=0 else start/b
etemp=end/b if end%b!=0 else end/b-1

print etemp-stemp+1


from sys import stdin

def work():
    [a, ta] = stdin.readline().strip().split()
    [b, tb] = stdin.readline().strip().split()
    [hh, mm] = stdin.readline().strip().split(":")
    a = int(a)
    ta = int(ta)
    b = int(b)
    tb = int(tb)
    hh = int(hh)
    mm = int(mm)
    start = (hh - 5) * 60 + mm
    end = start + ta

    n_total = 0
    if end % b == 0: n_total = end / b
    else: n_total = end / b + 1

    n_reached = 0
    rest = start - tb
    if rest >= 0:
        n_reached = 1
        n_reached += rest / b

    return n_total - n_reached

if __name__ == "__main__":

    print work()


def get_start(start_a, freq):
    mod = (start_a %  freq)
    return start_a + [0, freq - mod][mod != 0]

def has_overlap(x1, y1, x2, y2):
    x = max(x1, x2)
    y = min(y1, y2)

    return x < y

start = 0
io = lambda c: map(int, raw_input().split(c))

a, ta = io(' ')
b, tb = io(' ')
t = io(':')

start_a = get_start((t[0] - 5) * 60 + t[1], a)
end_a = start_a + ta
start_b = 0
r = 0

while start_b < 18 * 60 + 59:
    if has_overlap(start_a, end_a, start_b, start_b + tb):
        r += 1
    start_b += b

print r


n = int(input())
y = (n - 3)//2
elif y <= 0 or n%2 == 0: print("NO")
else: print("{0} {1}".format(1, y))


# https://codeforces.com/problemset/problem/1184/A1
import math

r = int ( input () )

found = False

else:
    for x in range (1,int(math.sqrt(r))+1):
        y = ((r-1)/x - x - 1)/2
        if y == int(y) :
            print(x,int(y))
            found = True
            break

if not found :
    print("NO")


import sys

def main():
    for a in sys.argv:
        print(a)
    cha_count = 0
    seq_start = 0
    for i in range(1, len(dna)):
        if dna[i-1] != dna[i] or i == len(dna) - 1:
            if (i - seq_start)%2 == 0:
                cha_count += 1
                seq_start = i
    print(cha_count)
    return 0
main()


n , k , x = map(int,raw_input().split())

vetor = map(int,raw_input().split())
soma = 0
i = 0
while True:
    soma_atual = 0
    cresc = 0
    decr = 0
    if i + 1 >= n:
        break
    if vetor[i] == vetor[i+1] == x:
        decr = i - 1
        cresc = i + 2
        soma_atual += 2

        while True:
            if decr - 1 >= 0 and cresc +1 < n:
                 if vetor[decr - 1] == vetor[decr] == vetor[cresc] == vetor[cresc + 1]:
                    soma_atual += 4
                    decr -= 2
                    cresc += 2
            if decr - 1 >= 0:
                if vetor[decr - 1] == vetor[decr] == vetor[cresc]:
                    soma_atual += 3
                    decr -=2
                    cresc += 1
            if cresc + 1 < n:
                if vetor[decr] == vetor[cresc] == vetor[cresc +1]:
                    soma_atual += 3
                    decr -= 1
                    cresc += 2
            else:
                break
        if soma_atual > soma:
            soma = soma_atual
    i +=1
    if decr < 0 or cresc > n:
        break
print soma


infs = raw_input().split()
n = int(infs[0])
k = int(infs[1])
x = infs[2]
balls = raw_input().split()
positions = []
destroyed_balls = 0

for i in range(n-1):
  if balls[i] == x and balls[i+1] == x:
    positions.append(i + 1)

if len(positions) == 0:
  print 0
else:
  for i in positions:
    j = i - 2
    k = i + 1
    actual_balls = 2
    able = False
    while (j >= 0 and k < n):
      if balls[j] == balls[k] and able:
        actual_balls = actual_balls + 2
        j = j - 1
        k = k + j
      elif balls[j] == balls[k]:
        if j - 1 >= 0:
          if balls[j] == balls[j-1]:
            j = j - 1
            actual_balls = actual_balls + 1
            able = True
        if k + 1 < n:
          if balls[k] == balls[k+1]:
            k = k + 1
            actual_balls = actual_balls + 1
            able = True
      elif able:
        if j - 1 >= 0:
          if balls[j] == balls[j-1]:
            j = j - 1
            actual_balls = actual_balls + 1
            able = True
        if k + 1 < n:
          if balls[k] == balls[k+1]:
            k = k + 1
            actual_balls = actual_balls + 1
            able = True
      else:
        break

    destroyed_balls = max(destroyed_balls, actual_balls)

  print destroyed_balls


edges = []
n,m = map(lambda x:int(x), input().split())
for i in range(m):
    curr = [0,0]
    curr[0],curr[1] = map(lambda x:int(x)-1, input().split())
    edges.append(curr)

num_in = [1,1,1,1,1,1,1]
abs_max = 0
c=0
for num_in[0] in range(1, 7):
    for num_in[1] in range(1, 7):
        for num_in[2] in range(1, 7):
            for num_in[3] in range(1, 7):
                for num_in[4] in range(1, 7):
                    for num_in[5] in range(1, 7):
                        for num_in[6] in range(1, 7):
                            c+=1
                            used = []
                            curr_max = 0
                            for x in edges:
                                crr = [num_in[x[0]],num_in[x[1]]]
                                if crr[0] > crr[1]:
                                    crr[0],crr[1] = crr[1],crr[0]
                                if crr in used:
                                    continue
                                used.append(crr)
                                curr_max+=1
                            abs_max = max(abs_max,curr_max)
                            if abs_max == m:
                                print(m)
                                exit()
print(abs_max)


'''input
7 21
1 2
1 3
1 4
1 5
1 6
1 7
2 3
2 4
2 5
2 6
2 7
3 4
3 5
3 6
3 7
4 5
4 6
4 7
5 6
5 7
6 7
'''
from sys import stdin
from collections import defaultdict

# main starts
n, m = list(map(int, stdin.readline().split()))
graph = defaultdict(list)
for _ in range(m):
	u, v = list(map(int, stdin.readline().split()))
	graph[u].append(v)
	graph[v].append(u)

define = dict()
if len(graph) <= 6:
	print(m)
	exit()

else:
	print(min(16, m))


from itertools import permutations

def dfs(perm, edges, ind, n):
	global dominoes

	if ind == n:
		cur = set()

		for x, y in edges:
			a, b = perm[x], perm[y]

			if tuple(sorted((a, b))) in dominoes:
				cur.add(tuple(sorted((a, b))))

		return len(cur)
	else:
		ans = 0
		for i in range(6):
			perm[ind] = i

			ans = max(ans, dfs(perm, edges, ind + 1, n))

		return ans

dominoes = []

for i in range(6):
	for j in range(i, 6):
		dominoes.append((i, j))

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

edges = []

for i in range(m):
	x, y = map(int, input().split())

	x, y = x - 1, y - 1

	edges.append(sorted((x, y)))

perm = [0 for i in range(n)]

print(dfs(perm, edges, 0, n))


n = int(input())
stri = input()
count = 0
i = 0
while(i<len(stri)):
    temp = 0
    jtemp = 0
    for j in range(i,len(stri)):
        if(stri[j]=="x"):
            temp += 1
        else:
            jtemp = j
            break
        jtemp = j
    if(temp==3):
        count += 1
    elif(temp>3):
        count += temp - 2
    i = i+jtemp
print(count)


"""Problem B - File Name.

http://codeforces.com/contest/978/problem/B

You can not just take the file and send it. When Polycarp trying to send a
file in the social network "Codehorses", he encountered an unexpected problem.
If the name of the file contains three or more "x" (lowercase Latin letters
"x") in a row, the system considers that the file content does not correspond
to the social network topic. In this case, the file is not sent and an error
message is displayed.

Determine the minimum number of characters to remove from the file name so
after that the name does not contain "xxx" as a substring. Print 0 if the file
name does not initially contain a forbidden substring "xxx".

You can delete characters in arbitrary positions (not necessarily
consecutive). If you delete a character, then the length of a string is reduced
by $$$1$$$. For example, if you delete the character in the position $$$2$$$
from the string "exxxii", then the resulting string is "exxii".

Input:

The first line contains integer $$$n$$$ $$$(3 \le n \le 100)$$$ — the length
of the file name.

The second line contains a string of length $$$n$$$ consisting of lowercase
Latin letters only — the file name.

Output:

Print the minimum number of characters to remove from the file name so after
that the name does not contain "xxx" as a substring. If initially the file name
dost not contain a forbidden substring "xxx", print 0.

"""
import logging

ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)

def solve(s):
    return min_characters(s)

def min_characters(s, memo=None):
    if not isinstance(s, str):
        s = ''.join(s)
    if not memo:
        memo = {}
    if s in memo:
        return memo[s]
    if 'xxx' not in s:
        return 0
    msf = float('inf')
    for i, c in enumerate(s):
        if c == 'x':
            memo[s] = 1 + min_characters(s[:i] + s[i+1:])
            msf = min(msf, memo[s])
    return msf

def main():
    _ = int(input().strip())
    s = input().strip()
    result = solve(s)
    print(result)

if __name__ == '__main__':
    main()


#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement,product
from __builtin__ import xrange as range
from math import ceil, factorial, log,tan,pi,cos,sin,radians
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
from fractions import Fraction
from functools import reduce
from decimal import *
import copy
import string
import sys
import os
import re
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353

def factors(n):
    from functools import reduce
    return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sieve(n):
    arr=[1]*n
    for i in range(2,int(n**0.5)+1):
        if arr[i]==1:
            for j in range(i,n,i):
                arr[j]=i
    return arr

def isprime(x):
    if x<=3:
        return True
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

def check(arr):
    rev=[]
    for i in arr:
        rev.append(reversed(i))
    for i in range(len(arr)):
        if not(isprime(sum(arr[i])) and isprime(sum(rev[i]))):
            return False
    return True

def main():
    n,x,pos=map(int,input().split())
    def binary_search(x,n,pos):
        l=0
        r=n
        cnt=cnt2=0
        rem=n-1
        temp=1
        while l<=r:
            mid=(l+r)//2
            # print(mid)
            if mid==pos:
                # print(cnt,cnt2,rem,temp)
                l=mid+1

            elif mid<pos:
                temp*=(x-cnt-1)
                l=mid+1
                cnt+=1
            else:
                temp*=(n-x-cnt2)
                r=mid
                cnt2+=1
        return (factorial(rem-cnt-cnt2)*(temp))%mod
    print(binary_search(x,n,pos))

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    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("\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 FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    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()

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

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

# endregion

if __name__ == "__main__":
    main()


a=[j for j in range(201)]
for i in range(2,201):
    for j in range(i,201,i):
        if a[j]==j:
            a[j]=i
a[0]=-1

for _ in range(input()):
    n=input()
    for i in range(200):
        if (n+i)==a[n+i] and (i+1)!=(a[1+i]):
            break

    ans=[[1 for j in range(n)]for j in range(n)]
    for j in range(n):
        ans[j][j]=i+1
    for  k in ans:
        for  i in k:
            print i,
        print " "


import math
int(a), int(b) = input().split()

minimum = min(a, b)
leftover = math.floor((a + b) / 2) - minimum

print (f'{minimum} {leftover}')


    def count_days(r,b):
        hipster = min(r,b)  # 👲
        normal = abs(r-b)//2  # 👨
        return hipster, normal

    if __name__ == "__main__":
        red, blue = map(int, input().split())
        res = count_days(red, blue)
        print(" ".join(map(str, res)))


a,b = [int(j) for j in input().split()]
print(min(a, b), max(a,b)-min(a,b)//2 sep=' ')


w = input()
if (w % 2 != 0 or w == 2):
    print("NO")
else:
    print("YES")


w = input()
if w==2:
    print('NO')
elif w%2==0:
    print('YES')
else:
    print('NO')
# 1534605364538


dp = {}
alphabet = "abcdefghijklmnopqrstuvwxyz"
pos = {alphabet[i]:i for i in range(26)}

def compute(s):
	global dp
	if len(s)==1:
		return 0
	elif s in dp:
		return dp[s]
	else:
		ans = -1
		for i in range(len(s)):
			if (i!=0 and pos[s[i-1]]==pos[s[i]]-1) or (i!=len(s)-1 and pos[s[i+1]]==pos[s[i]]-1):
				new_s = s[:i]+s[i+1:]
				val = compute(new_s)
				if val > ans:
					ans = val
		dp[s] = ans+1
		return ans+1

input()
print(compute(input()))


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

l = []
for i in range(n):
	l.append(ord(s[i]))

c = 0

while len(l) > 0:
	m = max(l)
	i = 0
	while l[i] != m:
		i += 1
	if l[i] - l[i - 1] == 1 or l[i] - l[i + 1] == 1:
		l.pop(i)
		c += 1

print(c)


def gdc(a, b):
    if a == b:
        return a
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return a + b

def lcm(a, b):
    m = a * b
    return m // gdc(a, b)

mas = raw_input().split()

l = int(mas[0])
r = int(mas[1])
x = int(mas[2])
y = int(mas[3])

a = []
for i in range(l, r + 1):
    a.append(i)

k = 0

for i in range(len(a)):
    for j in range(len(a)):
        if gdc(a[i], a[j]) == x and lcm(a[i], a[j]) == y:
            k += 1

print(k)


import math
from fractions import gcd
l,r,x,y=map(int,raw_input().split())
n=x*y
ans=0
g=x
i=1
while i<=math.sqrt(n):
    #print i
    if n%i==0:
        x=i
        y=n/i
        if gcd(x,y)==g and x<=r and x>=l and y<=r and y>=l:
            if x==y:
                ans+=1
            else:

                ans+=2
    i+=1
print ans


from sys import stdin
from fractions import gcd

def factorize(n):  # o(sqr(n))
    c, ans = 1, 0
    while (c * c < n):
        if n % c == 0:
            if l <= c <= r and l <= n // c <= r and gcd(c, n // c) == x and lcm(c, n // c) == y:
                ans += 2
        c += 1

    if c * c == n:
        if l <= c <= r and c == x == y:
            ans += 1
    print(ans)

lcm = lambda a, b: a // gcd(a, b) * b
l, r, x, y = [int(x) for x in stdin.readline().split()]
factorize(x * y)


k = int(input())
a = ''
for _ in range(4):
    a = a + input()
f = 1

for el in set(a):
    if a.count(el) > 2*k:
        print("NO")
        f = 0
        break
if f:print("YES")


from collections import defaultdict
n = int(input())
a = []
for i in range(4):
    x = list(input())
    a.append(x)
d = defaultdict(lambda: 0)
for i in range(len(a)):
    for j in range(len(a[i])):
        d[a[i][j]]+=1

n = 2*n
for key in d:
    if(d[key] > n):
        print('NO')
        exit()
print('YES')


import math
import atexit
import io
import sys

# input = sys.stdin.readline
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def array_to_string(a):
    s = ""
    for i in a:
        s += str(i)
    return s

n = int(input())
d = dict()
for i in range(4):
    s = input()
    for j in s:
        if j == '.':
            continue
        val = int(j)
        if d.get(val):
            d[val] += 1
            continue
        d[val] = 1
m = n*2
# print(m)
f = 0
# print(d)
for k,v in d.items():
    if v>m:
        print(k,v)
        f = 1
        break
if f == 0:
    print("YES")
else:
    print("NO")


import sys

noOfPixels = int(input())

row=1
mini = sys.maxsize
ans = []

while True:
    if noOfPixels%row==0:
        col = noOfPixels//row

        if row > col:
            break
        mini = min(mini,(col-row))
        ans[:] = []
        ans.append(row)
        ans.append(col)

    row = row+1

print(ans[0],ans[1])


import math

def is_square(n):
    sqrt = math.sqrt(n)
    return (sqrt - int(sqrt)) == 0

pixel = int(input())

if is_square(pixel): result = (int(math.sqrt(self.pixel)),int(math.sqrt(self.pixel)))
else:
    lista =[]
    for i in range(1, pixel+1):
        if pixel%i == 0 :lista.append(i)
    pivot = int(len(lista)/2)-1
    row = lista[pivot]
    column = lista[pivot+1]
    result = (row,column)

 priint(f"{' '.join(map(str,result))}")


import math

n = int(input())

a = 1
b = n

m=int(math.sqrt(n))

for i in range(1, m+1):

    x = i
    if n % x == 0:
        y = n // x
        if b - a > y - x:
            a = x
            b = y

print(a, b)
/*
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>arr;
    vector<int>brr;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i*j==n)
            {
                arr.push_back(i);
                arr.push_back(j);
            }
        }
    }
    /*for(int i=0;i<arr.size();i++){
        cout<<arr[i]<<" ";
    }
    */
    /*cout<<endl;
    for(int j=0;j<brr.size();j++){
        cout<<brr[j];
    }*/
    //cout<<endl;
    int x;
    for(int i=0;i<arr.size();i+=2){
        x = arr[i+1]-arr[i];
        brr.push_back(abs(x));

    }

    sort(brr.begin(),brr.end());

    for(int j=0;j<arr.size();j++){
        if((arr[j+1]-arr[j])==brr[0])
        {
            cout<<arr[j]<<" "<<arr[j+1];
        }
    }
    */

}


def checkit(x1,y1,x2,y2):
    check = [[0 for i in range(8)]for j in range(8)]
    for i in range(1,9):
        if i%2 == 0:
            for j in range(1,9):
                if j%2 == 0:
                    check[i-1][j-1] = 1
        else:
            for j in range(1,9):
                if j%2!=0:
                    check[i-1][j-1] = 1
    if check[x1-1][y1-1] == check[x2-1][y2-1]:
        return True
    else:
        return False
x1,y1,x2,y2 = map(int,input().split())

rook = 0
bishop = 0
king = 0

if not checkit:
    bishop = 0
else:
    if y1>y2:
        x1,x2 = x2,x1
        y1,y2 = y2,y1

    if x2 > x1:
        while x1<9 and y1<9:
            x1+=1
            y1+=1
            if x1 == x2 and y1 == y2:
                break
        bishop = 1
    if x1 > x2:
        while x1>0 and y1<9:
            x1-=1
            y1+=1
            if x1 == x2 and y1 == y2:
                break
        bishop = 1
    else:
        bishop = 2

# Calculate rook and king
if x1 == x2 or y1 == y2:
    king = abs(x1-x2) + abs(y1-y2)
    rook = 1
else:
    rook = 2
    steps = 0
    if y1>y2:
        x1,x2 = x2,x1
        y1,y2 = y2,y1

    if x2>x1:
        while x1<9 and y1<9:
            x1+=1
            y1+=1
            steps+=1
            if x1==x2 or y1==y2:
                break
        if x1 == x2 or y1 == y2:
            steps += abs(x1-x2) + abs(y1-y2)
    else:
        while x1>0 and y1<9:
            x1-=1
            y1+=1
            steps+=1
            if x1==x2 or y1==y2:
                break
        if x1 == x2 or y1 == y2:
            steps += abs(x1-x2) + abs(y1-y2)
    king = steps
print(rook,bishop,king)


import sys
import math
import random
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if n == 1:
    print(0)
    sys.exit()
for i in range(0, n - 1):
    if a[i] == a[i + 1] == x:
        l = i
        while l >= 0 and a[i] == a[l]:
            l -= 1
        r = i + 1
        while r < n and a[r] == x:
            r += 1
        while (1):
            if l == -1 or r == n:
                break
            if a[l] != a[r]:
                break
            if l == 0 and r == n - 1:
                break
            if l == 0:
                if a[0] == a[r + 1]:
                    while r < n and a[r] == a[0]:
                        r += 1
                    l -= 1
                    continue
                else:
                    break
            if r == n - 1:
                if a[n - 1] == a[l - 1]:
                    while l >= 0 and a[l] == a[n - 1]:
                        l -= 1
                    r += 1
                    continue
                else:
                    break
            if a[l] == a[r + 1] or a[l - 1] == a[r]:
                t = a[l]
                while l >= 0 and a[l] == t:
                    l -= 1
                while r < n and a[r] == t:
                    r += 1
        ans = max(ans, r - l - 1)
print(ans)


w
if w%2==0 and w!=2:
    print("yes")
else:
    print( "no")


def primeFactor(N):
    i = 2
    ret = {}
    n = N
    mrFlg = 0
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    while i**2 <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        if i == 2:
            i = 3
        else:
            i += 2
        if i == 101 and n >= (2**20):
            def findFactorRho(N):
                def gcd(a, b):
                    if b == 0:
                        return a
                    else:
                        return gcd(b, a % b)
                def f(x, c):
                    return ((x ** 2) + c) % N
                semi = [N]
                for c in range(1, 11):
                    x=2
                    y=2
                    d=1
                    while d == 1:
                        x = f(x, c)
                        y = f(f(y, c), c)
                        d = gcd(abs(x-y), N)
                    if d != N:
                        if isPrimeMR(d):
                            return d
                        elif isPrimeMR(N//d):
                            return N//d
                        else:
                            semi.append(d)

                semi = list(set(semi))
                print (semi)
                s = min(semi)
                for i in [2,3,5,7]:
                    while True:
                        t = int(s**(1/i)+0.5)
                        if t**i == s:
                            s = t
                            if isPrimeMR(s):
                                return s
                        else:
                            break

                i = 3
                while True:
                    if s % i == 0:
                        return i
                    i += 2

            while True:
                if isPrimeMR(n):
                    break
                else:
                    mrFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                        ret[j] = k
                if n == 1:
                    break

    if n > 1:
        ret[n] = 1
    if mrFlg > 0:
        def dict_sort(X):
            Y={}
            for x in sorted(X.keys()):
                Y[x] = X[x]
            return Y
        ret = dict_sort(ret)
    return ret

def isPrime(N):
    if N <= 1:
        return False
    return sum(primeFactor(N).values()) == 1

def isPrimeMR(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for a in [2, 3, 5, 7, 11, 13, 17, 19]:
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

def findPrime(N):
    if N < 0:
        return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

def mxpow(m, a, e):
    if e == 1:
        return a
    if e % 2 == 0:
        tmp = mxpow(m, a, e//2)
        return mxprod(m, tmp, tmp)
    else:
        tmp = mxpow(m, a, e//2)
        return mxprod(m, mxprod(m, tmp, tmp), a)

def mxprod(m, a, b):
    ret = [[0]*m for _ in range(m)]
    for i in range(m):
        for j in range(m):
            for k in range(m):
                ret[i][j] += a[i][k] * b[k][j]
                ret[i][j] %= P
    return ret

def mxv(m, a, v):
    ret = [0]*m
    for i in range(m):
        for k in range(m):
            ret[i] += a[i][k] * v[k]
            ret[i] %= P
    return ret

def mx(m):
    ret = [[0]*m for _ in range(m)]
    for i in range(m):
        for j in range(i, m):
            ret[i][j] = inv(j+1)

    return ret

def vc(m):
    return [0] * (m-1) + [1]

def inv(a):
    return pow(a, P-2, P)

# ----- -----

P = 10**9 + 7

n, k = map(int, input().split())
# n = 6
# k = 2

pf = primeFactor(n)
# print(pf)

ans = 1
for p in pf:
    m = pf[p] + 1
    vvv = mxv(m, mxpow(m, mx(m), k), vc(m))

    t = 0
    for i in range(m):
        t += (vvv[i] * p ** i) % P
        t %= P

    ans *= t
    ans %= P
print(ans)


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

c = 0
for i in range(0, n - 2):
    for f in range(i + 2, n + 1):
        if s[i:f].count('R') == s[i:f].count('L') and s[i:f].count('U') == s[i:f].count('D'):
            c = c + 1
            r = 'S'
        else:
            r = ''
        #print (i, f, s[i:f], r)

print (c)


n=input()
s=raw_input()
c,i = 0,0

for i in range(n):

    path = 0

    if s[i] == 'U':
        path += 1
    elif s[i] == 'D':
        path += -1
    elif s[i] == 'R':
        path += +2
    elif s[i] == 'L':
        path += -2

    for j in range(i+1, n):

        if s[j] == 'U':
            path += 1
        elif s[j] == 'D':
            path += -1
        elif s[j] == 'R':
            path += +2
        elif s[j] == 'L':
            path += -2

        if path == 0:
            c += 1
           # break

print c


import sys
n,m=map(int ,raw_input().split(" "))
s=raw_input()
k={}
count=0
for i in range(0,len(s)):
        try:
                k[s[i]]+=1
        except:
                k[s[i]]=1
l=sorted(k.keys())
ck=False
for i in range(0,len(l)):
        if(k[l[i]]<m):
                print("NO")
                ck=True
                break
if(ck==False):
        print("YES")


n=int(input())
data=list(map(int,input().split()))
if data[0]%2!=1 or data[-1]%2!=1:
    print('No')
else:
    temp=[]
    for i,item in enumerate(data):
        if item%2==1:
            temp.append(i)
    if temp:
        count=1
        flag=0
        for i in range(1,len(temp)):
            if temp[i]-temp[i-1]==1:
                count+=1
            elif flag==0:
                flag=temp[i]
            elif (temp[i]-flag+1)%2==1:
                count+=1
                flag=0
    print('Yes' if count%2==1 else 'No')


n = int(input())

arr = input()

def problem5(n,arr):
    arr = arr.split()
    size = len(arr)
    if int(arr[0])%2 == 0 or int(arr[size-1])%2 == 0 or size%2==0:
        return "NO"
    else:
        return "YES"

print(problem5(n,arr)


n = 0
arr = []

def check1(i, j):
    return not (arr[i] % 2 == 0 or arr[j - 1] % 2 == 0)

def check2(i, j):
    for k in range(i + 1, j, 2):
        if check1(i, k) and check1(k, j):
            return True

    for k in range(i + 2, j - 1, 2):
        if check2(i, k) and check2(k, j):
            return True

    return False

def main():
    global n
    global arr
    n = int(input())
    arr = list(map(int, input().split(' ')))

    if n % 2 == 0:
        return False

    for k in range(1, n, 2):
        if check1(0, k) and check2(k, n):
            return True

    return False

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


n=int(input())
arr=list(map(int,input().split()))
if n==1:
  if n%2==0:
      print("No")
  else:
      print("Yes")
elif len(arr)%2==0:
  print("No")
elif arr[0]%2==0 or arr[len(arr)-1]%2==0:
  print("No")
else:
  print("Yes")


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

#On initie fibo
fibo = [0] * max(2, n);
fibo[0] = 1;
fibo[1] = 1;
for i in range(2, n):
    fibo[i] = fibo[i-1] + fibo[i-2];

def f(k):
    return fibo[k-1];

#Une pseudo fonction de dichotomie sur fibo (retourne l'indice de valeur inférieure)
def dico(n, v):
    i, j = 2, n;
    if f(j) <= v:
        return j, v;
    if v == 1:
        return 2, 1;
    while j-i > 1:
        m = j-i // 2;
        if f(m) < v:
            i = m
        elif f(m) == v:
            return m, v;
        else:
            j = m;
    return i, f(i);

#On détermine les positions des doublets
currentLine = 1;
pos = []
long = n; #La longueur retante après les doublets déjà mis

while currentLine != k:
    i, v = dico(long, k-currentLine);
    currentLine += v;
    pos.append(n-i+1);
    long = i-2;

#On construit la réponse
prec = 0;
for p in pos:
    for i in range(prec+1, p):
        print(i, end = " ");
    print(p+1, p, end = " ");
    prec = p+1;
for i in range(prec+1, n+1):
    print(i, end = " ");


import math
x=raw_input().split(' ')
n=int(x[0])
k=int(x[1])
arr=[0]
i=n
while i>=1:
    arr.append(i)
    i=i-1
brr=[]
while k>1:
    s=int(math.ceil(math.log(k,2)))
    brr.append(s)
    a=pow(2,s-1)
    k=k-a
i=len(brr)-1
while i>=0:
    ind=brr[i]
    temp=arr[ind]
    arr[ind]=arr[ind+1]
    arr[ind+1]=temp
    i=i-1
i=n
while i>=1:
    print arr[i],
    i=i-1


from itertools import *
n,m=map(int,input().split())
e = [tuple(int(s)-1 for s in input().split()) for _ in range(m)]
print(max(len(set(tuple(sorted([p[a],p[b]])) for a,b in e)) for p in product(range(6),repeat=n)))


dominos = []
for i in range(1,7):
	for j in range(i, 7):
			dominos.append((i,j))

dominos_start_from = {}

for val in dominos:
		a, b = val
		try:
			dominos_start_from[a].append((a,b))
		except KeyError:
			dominos_start_from[a] = [(a,b)]

		try:
			dominos_start_from[b].append((b,a))
		except KeyError:
			dominos_start_from[b] = [(b,a)]

nm = raw_input();
edges = []
n, m = nm.strip().split();
m = int(m)
n = int(n)

graph = {}

for i in range(m):
		uv = raw_input()
		u, v = uv.strip().split()
		u = int(u)
		v = int(v)
		edges.append((u,v))
		try:
			graph[u].append(v)
			graph[v].append(u)
		except KeyError:
			graph[u] = [v]
			graph[v] = [u]

ans = [0]
vertex = {}
nodes = graph.keys()
n_nodes = len(nodes)
def compute():
	val = 0;
	pairs = {}
	for val in edges:
		a,b = val
		a = vertex[a]
		b = vertex[b]
		a,b = min(a,b), max(a,b)
		pairs[(a,b)] = True
	ans[0] = max(ans[0], len(pairs.keys()))

def dfs1(idx):
	if idx >= n_nodes:
		compute()
		return
	node = nodes[idx]
	for val in range(1,7):
		vertex[node] = val
		dfs1(idx+1)
		del vertex[node]

dfs1(0);
print ans[0];


r1,c1,r2,c2 = [int(x) for x in raw_input().split(" ")]
if r1 == r2 or c1 == c2:
	print 1,
else:
	print 2,
dr = abs(r1-r2)
dc = abs(c1-c2)
if (dr%2) == 0 and (dc%2) == 0:
	if dr == dc:
		print 1,
	else:
		print 2,
else:
	print 0,
k = 0
while dr > 0 and dc > 0:
	dr -= 1
	dc -= 1
	k += 1
while dr > 0:
	dr -= 1
	k += 1
while dc > 0:
	dc -= 1
	k += 1
print k


from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())

def white(a,b):
    return (a % 2 == 1 and b % 2 == 1) or (a % 2 == 0 and b % 2 == 0)

def black(a,b):
    return (a % 2 == 0 and b % 2 == 1) or (a % 2 == 1 and b % 2 == 0)

def solver():

    r1,c1,r2,c2 = myread()
    ans_list = []
    #rook
    ans = 0
    if r1 != r2:
        ans += 1

    if c1 != c2:
        ans += 1

    ans_list.append(ans)

    ans = 0

    #bishop

    if (r1 - c1 == r2 - c2) or (r1 + c1 == r2 + c2):
        ans = 1
    else:
        ans = 2

    if white(r1,c1) and black(r2,c2):
        ans = 0

    if black(r1,c1) and black(r2,c2):
        ans = 0

    ans_list.append(ans)

    ans = 0
    #king

    ans = max(abs(r1-r2),abs(c1-c2))

    ans_list.append(ans)

    print ans_list[0],ans_list[1],ans_list[2]

if __name__ == "__main__":
    solver()


r1,c1,r2,c2=map(int,raw_input().split())
a=b=c=0
if r1==r2 or c1==c2:
    a=1
else:
    a=2
if (r1+c1-r2-c2)%2==0:
    b=0
elif abs(r1-r2)==abs(c1-c2):
    b=1
else:
    b=2
c=max(abs(c1-c2),abs(r1-r2))
print a,b,c


"""http://codeforces.com/contest/370/problem/0"""

r1,c1,r2,c2 = map(int,raw_input().split())
print r1,c1,r2,c2
rook = (0 if r1 == r2 else 1)+(0 if c1 == c2 else 1)
bishop = (1 if abs(c1-c2) == abs(r1-r2) else 2) if (abs(r1-r2)+abs(c1-c2))%2==0 else 0
king = max(abs(r1-r2),abs(c1-c2))
print rook, bishop, king


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n, m = mints()
f = list(mints())
f.sort()
r = 1e100
for i in range(m-n+1):
	r = min(r, f[i+n-1]-f[i])
print(r)


def main():
    a, b, c, d = map(int, input().split())
    c, d = c-a, d-b
    x, y = map(int,input.().split())

    if c%x != 0 or d%y != 0:
        print("NO")
    elif c/x % 2 == d/y %2:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


def main():
    a, b, c, d = map(int, input().split())
    c, d = c-a, d-b
    x, y = map(int,input().split())

    if c%x != 0 or d%y != 0:
        print("NO")
    elif c/x % 2 == d/y %2:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


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

q -= a
w -= b

if q % x == 0 and w % y == 0 and abs(w - q) % abs(x - y) == 0:
    print("YES")
else:
    print("NO")


import bisect

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

# n : number of integers
# m : mod

half_n = n // 2

a1, a2 = a[:half_n], a[half_n:]

def add(a, m):
    ans = []
    n = len(a)
    for i in range(2 ** n):
        tmp = 0
        b = format(i, 'b')
        for j, x in enumerate(reversed(b)):
            tmp += a[j] * int(x)
        ans.append(tmp % m)
    return sorted(ans)

r1, r2 = add(a1, m), add(a2, m)

ans = 0

for i, x in enumerate(r1):
    p = bisect.bisect_left(r2, m-x)
    tmp_ans = r2[p-1] + x
    if tmp_ans > ans:
        ans = tmp_ans

print(ans)


n,m=map(int,input().split())
a=[int(i)%m for i in input().split()]
x,y=set(),set()
def f(x,n,c):
    for i in range(1<<n):
        s=0
        for j in range(n):
            if i&(1<<j):
                s=(s+a[j+c])%m
        #if s == m - 1: exit(print(s))
        x.add(s)
f(x,n//2,0)
f(y,n-n//2,n//2)
y=sorted(y)
import bisect
k=0
print(max(i+y[bisect.bisect_left(y,m-i)-1]for i in x))


n,m=map(int,input().split())
a=[int(i) for i in input().split()]
x=set()
y=x
def f(x,n,i,s=0):
    if i==n:
        if s == m - 1: exit(print(s))
        x.add(s)
    else:
        f(x,n,i+1,(s+a[i])%m)
        f(x,n,i+1,s)
h=n//2
f(x,h,0)
f(y,n,h)
y=sorted(y)
import bisect
k=0
print(max(i+y[bisect.bisect_left(y,m-i)-1]for i in x))


n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
import bisect
a1,a2=[],[]
n1=n//2

def sums1(i,sum=0):
    if i==n1:
        a1.append(sum)
    else:
        sums1(i+1,(sum+a[i])%m)
        sums1(i+1,sum)

def sums2(i,sum=0):
    if i==n:
        a2.append(m-sum)
    else:
        sums2(i+1,(sum+a[i])%m)
        sums2(i+1,sum)

sums1(0)
sums2(n1)

ans=0
end=len(a2)-1

a1=sorted(set(a1))

for i in a2:
    j=bisect.bisect_left(a1,i)
    if ans<a1[j-1]+i:
        ans=a1[j-1]+i
print(ans)


def fckset( arr ):

    n = len(arr)
    halfsum = []

    # Bit Masking

    mx = 1 << n
    for i in range( mx ):
        hlf = 0
        for j in range( n ):

            if ( i & ( i << j ) != 0 ):
                hlf += arr[j]
                hlf %= m

        halfsum.append( hlf )

    return halfsum

n, m = map( int , input().split(" ") )
arr = list( map( int , input().split(" ") ) )

h1 = fckset( arr[:n//2] )
h2 = fckset( arr[n//2:] )

# h1.sort()
h2.sort()

import bisect

x = h1
y = h2

print(max(i+y[bisect.bisect_left(y,m-i)-1]for i in x))


import sys
import math
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input())) #integer
def inlt():
    return(list(map(int,input().split()))) #list
def insr():
    s = input()
    return(list(s[:len(s) - 1])) #string, returns list of characters
def invr():
    return(map(int,input().split()))  # For taking space seperated integer variable inputs.

alles = inlt()
anzahl = alles[0]
sticket_fahrten = alles[1]
kticket = alles[2]
ksticket = alles[3]
prize2=999999999
if ksticket/sticket_fahrten < kticket:
    asticket = anzahl/sticket_fahrten
    if round(asticket)==asticket:
        print(asticket*ksticket)
    else:
        x= False
        i=1
        asticket = anzahl / sticket_fahrten
        prize1 = math.ceil(asticket)
        while x == False:
            anzahl -= 1
            if round(asticket)==asticket:
                x=True
                prize2=int(asticket * ksticket +i*kticket)
            elif anzahl==0:
                x=True
                anzahl=alles[0]
                prize3=int(anzahl * kticket)
            i +=1
else:
    print(anzahl*kticket)
if prize1>prize2:
    print(prize2)
else:print(prize1)


from operator import itemgetter

def bin_search(lo, hi, key):
    while (lo < hi):
        md = (hi + lo) // 2
        if (md >= key(md)):
            hi = md
            #print("new hi:", hi)
        else:
            lo = md + 1
            #print("new lo:", lo)
    return lo   #or hi, they're equal at this point

def key_func(budget, prices):
    for k in range(1 + budget//prices[2]):
        budget2 = budget - k*prices[2]
        for j in range(1 + budget2//prices[1]):
            budget3 = budget2 - j*prices[1]
            i = budget3//prices[0]
            if survive(i, j, k):
                return budget - 1
    return budget + 1

def survive(i, j, k):
    global y, m, p, penumsorted
    toadd = [i, j, k]
    newy = list(y)
    newm = list(m)
    for i, item in enumerate(penumsorted):
        newy[item[0]] = y[item[0]] + toadd[i]
    #print(vars())
    while newy[0] > 0 and newm[0] > 0:
        newy[0] -= max(0, newm[1] - newy[2])
        newm[0] -= max(0, newy[1] - newm[2])
    if newm[0] <= 0 and newy[0] > 0:
        return True
    else:
        return False

y = list(map(int, input().split()))
m = list(map(int, input().split()))
p = list(map(int, input().split()))
psorted = sorted(p)
penum = list(enumerate(p))
penumsorted = sorted(penum, key=itemgetter(1))
print(bin_search(0, 30000, lambda x: key_func(x, psorted)))


import math
x, y, z = map(int, input().split())
a, b, c = map(int, input().split())
s, rs, ls = map(int, input().split())
def rec(ss):
    for i in range(0, 155, 1):
        for j in range(0, 155, 1):
            if(i * rs + j * ls <= ss):
                q = y + i;p = z + j; pq = x + ((int)((ss - i * rs - j *ls) / s))
                an1 = 1000000000000.0;an2 = 1000000000000.0
                if(b - p > 0):
                    an1 = math.ceil(((float) (pq)) / ((float)(b - p)))
                if(q - c > 0):
                    an2 = math.ceil(((float) (a)) / ((float)(q - c)))
                if(q > c and p >= b or an1 > an2):
                    return True
    return False
st = 0; en = 100000; mid = 0
while(st <= en):
    mid = (int)((st + en) / 2)
    if(rec(mid) == True):
        en = mid - 1
    else:
        st = mid + 1
print(en + 1)


hy, ay, dy = map(int, input().split())
hm, am, dm = map(int, input().split())
h, a, d = map(int, input().split())
s = 1 << 30
for da in range(max(0, dm - ay + 1), max(0, hm - ay + dm) + 1):
    for dd in range(max(0, am - dy) + 1):
        dh = max(0, hm * (am - dy - dd) // (ay + da - dm) - hy + 1)
        s = min(s, h * dh + a * da + d * dd)
print(s)


import sys
import string

#sys.stdin = open("41.in","r")

a = raw_input()
h = a[0]
a = a[1:]
i = a.find("at")
wei = a[i+2:]
a = a[:i+2]

#print h,a,wei

a = a.replace("dot", ".")
wei = wei.replace("dot", ".")
a = a.replace("at", "@")

print h+a+wei


from sys import stdout
n = int(input())
dp = [0 for i in range(n // 2 + 10)]
dp[0] = 1
dp[1] = 2

for i in range(2, n + 10):
    if dp[i - 1] > n:
        stdout.write(str(i - 2))
        break
    dp[i] = dp[i - 1] + dp[i - 2]


#!/usr/bin/env python
import sys
s, x = map(int, raw_input().split())

if (s - x) % 2 != 0:
    print 0
    sys.exit(0)
same = (s - x) / 2
if same & x != 0:
    print 0
    sys.exit(0)
counter = 0
different = x
temp = different
while different > 0:
    counter += 1
    different = (different - 1) & temp
counter += 1
if same == 0:
    counter -= 2
print counter


n = raw_input()
s = int(n.split(" ")[0])
x = int(n.split(" ")[1])
ans = 1
bits = []
bitx = []
s_ = s
while s_ >= 1:
	if s_ % 2 == 0:
		bits.append(0)
	else:
		bits.append(1)
	s_ = s_/2
x_ = x
while x_ >= 1:
	if x_ % 2 == 0:
		bitx.append(0)
	else:
		bitx.append(1)
	x_ = x_/2
# print bits,bitx
bits.reverse()
for i in range(len(bitx),len(bits)):
	bitx.append(0)
bitx.reverse()
i = 0
carry = 0
l = len(bits)
flag = False
if bits[i] == 1:
	if bitx[i] == 0: # it is not the start bit
		carry = 1
		i += 1
while i < l :
	# 8 conditions
	if carry == 0 and bits[i] == 0 and bitx[i] == 0:
		carry = 0
	elif carry == 0 and bits[i] == 0 and bitx[i] == 1:
		flag = True
		break
	elif carry == 0 and bits[i] == 1 and bitx[i] == 0:
		carry = 1
	elif carry == 0 and bits[i] == 1 and bitx[i] == 1:
		carry = 0
		ans *= 2
	elif carry == 1 and bits[i] == 0 and bitx[i] == 0:
		carry = 0
	elif carry == 1 and bits[i] == 0 and bitx[i] == 1:
		ans *= 2
		carry = 1
	elif carry == 1 and bits[i] == 1 and bitx[i] == 0:
		carry = 1
	elif carry == 1 and bits[i] == 1 and bitx[i] == 1:
		flag = True
		break
	i += 1

if flag == False and carry == 1:
	flag = True

if flag:
	print 0
else:
	if s == x:
		ans -= 2
	print ans


s, x = map(int, raw_input().split(' '))
num = 0

i = 0
while i <= s:
	j = s - i
	if i ^ j == x and i > 0 and j > 0:
		num += 1

	i += 1

print num


import sys
def i(): return sys.stdin.readline().strip()
sys.setrecursionlimit(99999999)
ii=lambda:map(int,i().split(" "))

a,b=ii()
bitsA,bitsB=[],[]
z=1
while z<=a*2:
    if z&a:
        bitsA.append(1)
    else:
        bitsA.append(0)
    if z&b:
        bitsB.append(1)
    else:
        bitsB.append(0)
    z*=2
#print bitsB

def g(adding,ind,acc):
    #print adding,acc,ind
    #if (acc%adding)^(a%adding)<>0:
        #return 0
    if ind==len(bitsB):
        if acc==a:
            return 1
        else:
            return 0
    if bitsB[ind]==1:
        a_=g(adding*2,ind+1,acc+adding)
        return 2*a_
    else:
        return g(adding*2,ind+1,acc)+g(adding*2,ind+1,acc+adding*2)

ans= g(1,0,0)
if a==b:ans-=2
print ans


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

if min(x) == min(y):
    print(min(x))
else:
    a, b = min(x), min(y)
    if a > b:
        a.b = b, a
    print(10 * a + b)


a,ta=map(int,input().split(' '))
#print (a,ta)
b,tb=map(int,input().split(' '))

time=input()

hour=int(time[0:2])
mint=int(time[3:5])
low=(hour-5)*60+mint
up=low+ta
ans=0
for i in range(0,19*60,b):
	l=i
	h=i+tb
	if l<up and h>=up:
		ans+=1
		#print(i)
	elif l <=low and h > low:
		ans+=1
		#print(i)
print (ans)
#print(hour)


[a,ta]=[int(i) for i in input().split()]
[b,tb]=[int(i) for i in input().split()]
[h,m]=[int(i) for i in input().split(':')]
basic=h*60+m-300
end=basic+ta
l=0
r=basic//b+1
while l!=r-1:
    temp=(l+r)//2
    if temp*b+tb<=basic:
        l=temp
    else:
        r=temp
answer=r
if tb>=basic:
    answer=0
answer=end//b-answer
print(answer)


def main():
    a, ta = map(int, input().split())
    b, tb = map(int, input().split())
    h, m = map(int, input().split(':'))
    t = h * 60 + m + b - 300
    print(max(min(t + ta - 1, 1140) // b - max((t - tb), 0) // b, 0))

if __name__ == '__main__':
    main()


THE_FIRST_BUS = 5 * 60
THE_LAST_BUS = 23 * 60 + 59

def solve(fab, tab, fba, tba, start):
    hours, minutes = map(int, start.split(':'))
    start_minutes = hours * 60 + minutes
    stop_minutes = start_minutes + tab
    first_ba = 300 + (1 + (start_minutes - 300 - tba) / fba) * fba

    first_bus = max(THE_FIRST_BUS, first_ba)
    last_bus = min(stop_minutes, THE_LAST_BUS)

    bus_no = 0
    while True:
        if first_bus + bus_no * fba >= last_bus:
            break
        bus_no += 1

    return bus_no

fab, tab = map(int, raw_input().split())
fba, tba = map(int, raw_input().split())
start = raw_input()

print solve(fab, tab, fba, tba, start)


s=input()
ans=1
rem=10
occured={}
for x in range(len(s)):
    if s[x] in 'ABCDEFGHIJ':
        if x==0:
            ans*=9
            rem=9
        else:
            if s[x] in occured:
                pass
            else:
                ans*=rem
                rem-=1
        occured[s[x]]=1
    elif s[x]=='?':
        ans*=10
print(ans)


input_str = input()
tmp = []
if input_str[0] == '?':
    result=9
    a = 11
    for c in input_str[1:]:
        if c == '?':
            result*=10
        elif 'A' <= c <= 'J' and tmp.count(c)==0:
            tmp.append(c)
            a-=1
            result*=a
elif 'A' <= input_str[0] <= 'J':
    tmp.append(input_str[0])
    result=9
    a=10
    for c in input_str[1:]:
        if c == '?':
            result*=10
        elif c == input_str[0]:
            result*=9
        elif 'A' <= c <= 'J' and tmp.count(c)==0:
            tmp.append(c)
            a-=1
            result*=a
else:
    a=11
    result=1
    for c in input_str[1:]:
        if c == '?':
            result*=10
        elif 'A' <= c <= 'J' and tmp.count(c)==0:
            tmp.append(c)
            a-=1
            result*=a
print(result)


from math import factorial

def nchk(n, k):
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans = ans * i
    return ans / factorial(k)

def ml(s, k):
    ans = 1
    for i in range(k):
        ans = ans * s
        s = s - 1
    return ans

str = input()

lset = set()

qc = 0

for c in str:
    if (c <= 'J' and c >= 'A'):
        lset.add(c)
    elif (c == '?'):
        qc = qc + 1

lc = len(lset)

#################

ans = 0

if (str[0] == '?'):
    ans = 9
    qc = qc - 1
    ans = ans * 10**qc
    ans = ans * ml(10, lc) * factorial(lc)
elif (str[0] > '?'):
    ans = 9
    lc = lc - 1
    ans = ans * 10**qc
    ans = ans * ml(9, lc) * factorial(lc)
else:
    ans = 1
    ans = ans * 10**qc
    ans = ans * ml(10, lc) * factorial(lc)

print(ans)


Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
[evaluate untitled-1.py]
1?AA
100


s = input()
num = [str(i) for i in range(10)]
any = 0
alpha = []
for i in s:
    if i == "?":
        any += 1
    elif i not in num and i not in alpha:
        alpha.append(i)
result = 1
if s[0] == "?" or s[0] in num:
    c = 10
    while alpha != []:
        result *= c
        alpha.pop()
        c -= 1
    result *= 10**any
    print(result)
else:
    result *= 9
    alpha.pop()
    c = 9
    while alpha != []:
        result *= c
        alpha.pop()
        c -= 1
    result *= 10**any
    print(result)


x = int(input())
f, x = x>=0, abs(x)

if x <= 45:
    print(0)
elif f:
    print(1)
else:
    print(3)


n = int(raw_input())
a = [(n + 90 * i) % 360 for i in xrange(4)]
a = [min(x, 360 - x) for x in a]
res = 0
for i in xrange(1, 4):
    if a[i] < a[res]:
        res = i
print res


#include <iostream>
#include <algorithm>
#include <list>
#include <math.h>
#include <set>
#include <cstring>
#include <map>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define endl "\n"
#define kn 300005
#define md 1000000007
#define x first
#define y second
#define pb push_back
#define ms(i,a) memset(a,i,sizeof(a))
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ff(i,x) for(int i=1;i<=x;i++)
#define _ff(i,x) for(int i=x;i>=1;i--)
#define _f(i,a,b) for(int i=b;i>=a;i--)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll ans[kn],n,k,_[20];
string s;

int main() {
	cin>>n>>k;
	ll sum=0,ans=0,num=0;
	_[0]=1;
	ff(i,18) _[i]=_[i-1]*10;
	while(sum<=k&&n>0&&ans<=18){
		int tmp=(n%10) %9; if(tmp!=0) tmp++;
		//772346242764cout<<tmp<<endl;
		sum+=tmp*_[ans];
		//cout<<"hi "<<sum<<endl;
		if(sum>k) break;
		//cout<<"n: "<<n<<endl;
		if(tmp>0) n-=tmp;
		n/=10;
		ans++;
		num++;
	}
	if(n) cout<<n;
	ff(i,num) cout<<"9";
}


user_len = input()
user_input = input()
x_string = 'xxx'
i = 0
while 'xxx' in user_input:
    user_input.replace('xxx','')
    i += 1
print(i)


num = int(input())
name = input()
if name.count("xxx")==0:
    print(0)
else:
    while True:
        s = name.replace("xxx","xx")
        if s.count("xxx")==0:
            print(name.count("x")-s.count("x"))
            break
        else:
            continue


size = int(input())
counts = [int(x) for x in input().split()]
counts.sort(reverse=True)
for i in range(1, size):
    if (counts[i]==counts[i-1]):
        counts[i] = counts[i] - 1
print(sum(counts)


import sys

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ok = False
    while not ok:
        ok = True
        a.sort()
        for i in range(1, n):
            if a[i] == a[i - 1]:
                a[i] = max(0, a[i - 1] - 1)
                ok = False
    ans = sum(a)
    print(ans)

main()


n=int(input())
i=0
a=[int(i) for i in input().split()]
while i<10:
    a.sort()
    for i in range(n):
        if a[i]==a[i-1] and a[i]!=0:
            a[i]-=1
    i+=1
print(sum(a))


import numpy as np
n = int(raw_input())
# input the array
ais [int(x) for x in raw_input().split()]
ais=np.array(ais)
dis=np.unique(ais)
print(np.sum(ais)- (len(ais)-len(dis)))


points_set = []
for i in range(8):
    points_set.append([int(i) for i in input().split()])

x_list = []
y_list = []
x_count = 0
y_count = 0
for i in points_set:
    if i[0] not in x_list:
        x_list.append(i[0])
        x_count += 1
    if i[1] not in y_list:
        y_list.append(i[1])
        y_count += 1
if x_count != 3 or y_count != 3:
    print('ugly')
    exit()
for i in range(3):
    if [x_list[0], y_list[i]] not in points_set or [x_list[2], y_list[i]] not in points_set:
        print('ugly')
        exit()
if [x_list[1], y_list[0]] not in points_set or [x_list[1], y_list[2]] not in points_set:
    print('ugly')
    exit()
print('respectable')


r = int(input())
if r % 2 != 0 and r >= 5:
    x = 1
    y = 0
    for i in range(1, r):
        y += 1
        if x ** 2 + 2 * x * y + x + 1 == r:
            break
    print(x, y)
else:
    print('NO')


import functools
import math
import sys
from collections import defaultdict

# input = sys.stdin.readline
rt = lambda: map(int, input().split())
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))

def solve(r):
    if r == 1:
        return f'{0  0}'
    x = 1
    while x*x < r:
        if (r - x*x - 1 - x) % (2*x) == 0:
            return f'{x} {(r - x*x - 1 - x) // (2*x)}'
        x += 1

    return "NO"

def main():
    r = ri()
    print(solve(r))

if __name__ == '__main__':
    main()


n = int(raw_input())
t = [int(ti) for ti in raw_input().split(' ')]
t.sort()
prev = t[0]
ok = False
for i in xrange(1,len(t)-1):
	curr = t[i]
	foll = t[i+1]
	if curr-prev == foll-curr ==1:
		ok = True
		break
if ok:
	print "YES"
else:
	print "NO"


n = input()
ans = 'helo'
x=''
b=0
for i in n:
    if i not in x:
        if i==ans[b]:
            x+=i
            b+=1
if ans in x:
    print("YES")
else:
    print("NO")


import math
def calculateDistance(x1,y1,x2,y2):
    dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return dist
def solve(r,x1,y1,x2,y2):
    x=calculateDistance(x1,y1,x2,y2)
    y=math.ceil(x/(2*r))
    print(y)

R=int(input())
X1=int(input())
Y1=int(input())
X2=int(input())
Y2=int(input())
solve(R,X1,Y1,X2,Y2)


from itertools import combinations
from collections import Counter
from math import factorial

def getLuckySubsetCount(mArr, luckySubset):
    width = len(mArr)
    A = map(lambda x: [0,0,0], range(width))
    for i in range(width):
        A[i][0] = 8 if not (i in luckySubset) else 2
        A[i][1] = len(filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mArr[i]), range(10)))
        A[i][2] = filter(lambda x: ((x != 7 and x != 4) if not (i in luckySubset) else (x == 7 or x == 4)) and (x <= mArr[i]), range(10))
        A[i][2] = (max(A[i][2]) == mArr[i]) if A[i][2] else False
    B = map(lambda x: [0,0], range(width))
    for i in range(width):
        if i == 0:
            B[i][0] = A[i][0]
            B[i][1] = A[i][1]
        else:
            B[i][0] = B[i - 1][0] * A[i][0]
            B[i][1] = (A[i][1] - 1) * B[i - 1][0] + (B[i - 1][1] if A[i][2] else B[i - 1][0])
    return B[width - 1][1]

def getLuckyCount(mArr, luckySize):
    maxWidth = len(mArr)
    result = 0
    for combination in combinations(range(maxWidth), luckySize):
        luckySubset = set(combination)
        result += getLuckySubsetCount(mArr, luckySubset)
    # do not count number '0'
    return result - (1 if luckySize == 0 else 0)

def sumCombinations(resultSum, members):
    if members == 1:
        yield [resultSum]
    else:
        for i in range(resultSum + 1):
            for combination in sumCombinations(resultSum - i, members - 1):
                yield [i] + combination

def combinationOrderedMod(fullSet, subset, modulo):
    return reduce(lambda r, x: (r * ((fullSet - x) % modulo)) % modulo, range(subset), 1)

def combinationMod(fullSet, subset, modulo):
    if fullSet >= subset:
        values = map(lambda i: fullSet - i, range(subset))
        value = reduce(lambda r, x: r * x, values, 1)
        value /= factorial(subset)
        return value % modulo
    return 0

def resultMod(lucky, modulo):
    result = 0
    for luckyDigits in range(1, len(lucky)):
        for combination in Counter(map(lambda x: tuple(Counter(x).items()), sumCombinations(luckyDigits - 1, 6))):
            subResult = lucky[luckyDigits]
            for k, v in combination:
                subResult *= combinationOrderedMod(lucky[k], v, modulo) % modulo
                subResult %= modulo
            result += subResult
            result %= modulo
    return result

def main():
    mArr = map(int, list(raw_input()))
#    m = 10 ** 9
#    mArr = map(int, list(str(m)))
#    mArr = map(int, list('7'))
    mArr.reverse()
    lucky = [0] * (len(mArr) + 1)
    for luckySize in range(len(mArr) + 1):
        lucky[luckySize] = getLuckyCount(mArr, luckySize)
#    print lucky
    print resultMod(lucky, (10 ** 9) + 7)

if __name__ == '__main__':
    main()


a,b , c =map(int,input().split())
t = 0
if a+b>c:
    t = 0
else:
    t = t+c-a-b
if b+c>a:
    continue
else:
    t = t+ a-b-c
if a+c>b:
    continue
else:
    t = t+ b - a-c
print(t)


l=sorted([int(i)for i in input().split()])
print(max(l[2-l[1]-l[0]+1,0))


a,b=2,1
c=0
while a<=int(input()):
    a,b=a+b,a
    c+=1
print(c)


def fib(n):
    if n==0 or n==1:
        return 1
    else:
       return fib(n-1)+fib(n-2)
n=int(input())
i=0
s=0
while True:
    s=s+fib(i)
    if s>=n:
        break
    else:
        i=i+1
print(i)


from math import *
player=int(input())

if ( player == 1 or player == 2 ):
    print ("1")
else:
    print ( math.ceil(math.log(player,2) ))


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

ans=0
for i in range(n):
	for j in range(i,n):
		for k in range(i,j+1):
			a[k] = 1-a[k]
		ans=max(len(filter(lambda x: x==1,a)))
		for k in range(i,j+1):
			a[k] = 1-a[k]
print(ans)


import re
n=int(input())
l=list(map(int, input().split()))
s=""
for x in l:
   s=s+str(x)

pat= r"1*0+1*"
li=[]

for i in range(n):
    li+=re.findall(pat, s[i:n])

m=len(li[0])

for x in li:
    if m<len(x):
        m=x

print(m)


#!/usr/bin/python

#
# Pew. Way too complicated for a problem A.
# Can me horribly insightless O(n^2) implementation pass without TLE?
#
import sys
from math import *

def Nf(): return tuple(map(float, sys.stdin.readline().split()))
def Ni(): return tuple(map(int, sys.stdin.readline().split()))
def Nil(): return map(int, sys.stdin.readline().split())
def Ns(): return sys.stdin.readline().split()

n = Ni()[0]
a = Nil()

def cansplit(ai, odd = True):
    # print "Can I split: ", a, "into an", "odd" if odd else "even", "number of segments?"
    if ai == n:
        return not odd

    # print a, even
    if a[ai] % 2 == 0 or a[n-1] % 2 == 0:
        return False

    if ai == n - 1:
        return odd

    for i in xrange(ai, n):
        if (i-ai) % 2 == 0 and a[i] % 2 == 1 and cansplit(i+1, not odd):
            return True

    return False

print "Yes" if cansplit(0) else "No"


def calcUtil(a,curr,p,n):
    if curr==n:
        if p%2==0:
            return True
        return False
    if a[curr]%2==1:
        for i in range(1,n,2):
            if curr+i>n:
                break
            if a[curr+i-1]%2==1:
                val=p
                if curr+i==n:
                    val=p
                else:
                    val=val+1
                if calcUtil(a,curr+i,val,n):
                    return True
    return False

def calc(a,n):
    if n==1:
        return True if a[0]%2==1 else False
    if n%2==1 and a[0]%2==1 and a[n-1]%2==1:
        return True
    if a[0]%2==0 or a[-1]%2==0:
        return False
    partition=0
    return calcUtil(a,0,partition,n)

n=int(input())
a=list(map(int,input().split()))
print("Yes" if calc(a,n) else "No")


a,b=map(int,input().split())
mi=min(a,b)
x=int(((a+b)-2*mi)/2)
print(mi,x)
//recheking time


R = lambda: map(int, input().split())
hy, ay, dy = R()
hm, am, dm = R()
ch, ca, cd = R()
res = 501 * (ch + ca + cd)
for hyp in range(501):
    for ayp in range(501):
        for dyp in range(501):
            if ay + ayp > dm:
                k = (hm + ay + ayp - dm - 1) // (ay + ayp - dm)
                if hy + hyp > k * max(0, am - dy - dyp):
                    res = min(res, ch * hyp + ca * ayp + cd * dyp)
print(res)


import math
r,x,y,x1,y1=map(int,input().split())
d=((x1-x)**2+(y1-y)**2)**0.5
angle=0
if x1-x==0:
    angle=math.pi/2
else:
    angle=math.atan((y1-y)/(x1-x))
print(int(math.ceil(d/(2*r*math.sin(angle)))))


n,k=map(int,input().split())
a=input()
b=[0]*123
for i in a:
    b[ord(i)]+=1
if max(b)>k:
    print("NO")
else:
    print("YES"


n,k=map(int,input().split())
s=input().lower()
letters=[0]*26
c=0
for i in s:
    nomer=ord(i)-97
    letters[nomer]+=1
letters.sort(reverse=True)
while 0 in letters:
    letters.pop()
for j in letters:
        b=j
        if b%k!=0:
            c=c+0

if c==0:
    print('YES')
elif
else:
    print('NO')


import sys

fin = sys.stdin
fout = sys.stdout
temp = fin.readline().strip()
n = int(temp[:len(temp) - 1])
s = temp[-1]
w1 = 1
w2 = 3
it = 1
ans = 0
while True:
    if w1 == n or w2 == n:
        if s == 'f':
            ans += 1
        elif s == 'e':
            ans += 2
        elif s == 'd':
            ans += 3
        elif s == 'a':
            ans += 4
        elif s == 'b':
            ans += 5
        elif s == 'c':
            ans += 6
        fout.write(str(ans))
        break
    ans += 6
    if it % 2 == 1:
        w1 += 1
        w2 += 1
        ans += 1
    else:
        w1 += 3
        w2 += 3
        ans += 3
    it += 1


#include <iostream>
#include <string>

using namespace std;

int main(){
	string inp;
	cin >> inp;
	unsigned long long int row;
	char sira = inp[inp.size()-1];
	string str = inp.substr(0,inp.size()-1);
	row = strtoull(str.c_str(), 0, 10);
	int array[6] = {4,5,6,3,2,1};
	unsigned long long qs = ((row - 1) / 8);
	row = row - (qs*8);
unsigned long long opo = qs * 32;

if (row == 2 || row == 4)
    opo += 7;
else if (row == 5 || row == 7)
    opo += 16;
else if (row == 6 || row == 8)
    opo += 23;

opo += array[sira - 'a'];

cout << opo;return 0;
}


money = int(input().split()[-1])
best_price = min(map(int, input().split()))
best_sell = max(map(int, input().split()))

actions = money // best_price
remaining = money % best_price

result = actions * best_sell + remaining
print(result)


n,m,r = map(int,input().split())
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))
if min(ai) >= max(bi):
    print(r)
else:
    a = r//min(ai)
    print(a*max(bi) + 1)


n=input().split()
buin=input().split()
buout=input().split()
buout.sort(reverse=True)
buin.sort()
if int(buin[0])>int(buout[0]):
    print(n[2])
    exit(0)
else:
    print(int(n[2])+int(int(n[2])/int(buin[0]))*(int(buout[0])-int(buin[0])))


stuff = input().split(" ")
n = int(stuff[0])
m = int(stuff[0])
list1 = sorted([int(x) for x in input().split(" ")])
list2 = [int(x) for x in input().split(" ")]

min1 = min(list1)
min2 = min(list2)

for i in range(n):
    for j in range(m):
        if list1[i] == list2[j]:
            print(list1[i])
            exit(0)
print(str(min(min1, min2)) + str(max(min1, min2)))


#!/usr/bin/python

n = 2**input()
square = n**2
sumn = (n**2 + n) / 2
n /= 2
num = 1
while True:
	if n == 1:
		break
	sumn += num *(n ** 2 + n ) / 2
	num *= 3
	n /= 2
print (square - sumn) % 1000003


#B.Simple Molecules
a,b,c = map(int,input().split())
if a<=(b+c) and b<=(a+c) and c=<(a+b) and (a+b+c)%2==0:
    print((a+b-c)//2,(b+c-a)//2,(c+a-b)//2)
else:
    print("Impossible")


a,b,c=map(int,input().split()):
s=(a+b+c)/2
if (a+b+c)%2 or s-a<0 or s-b<0 or s-c<0:print("Impossible")
else:print(s-c,s-a,s-b)


import sys
range = xrange
input = raw_input

n = int(input())

mem = [[-1]*(n+1) for _ in range(n+1)]
def f(a,b):
    if mem[a][b]==-1:
        if (b-a)<=1:
            score = 0
        else:
            score = 10**18
            r = b if a==0 and b==n else b+1
            for c in range(a+2,r):
                score = min(score,(a+1)*(a+2)*(c%n+1) + f(a+1,c) + f(c,b))
        mem[a][b] = score
    return mem[a][b]

print(f(0,n))


rom math import *
alf = list(reversed('abcdefghijklmnopqrstuvwxyz'))
def adj(a, b):
    return chr(ord(a) - 1) == b

n = int(input())
s = [i for i in input()]
for i in range(n):
    for a in alf:
        i = 0
        while i < len(s):
            if s[i] == a and i > 0 and adj(s[i], s[i-1]):
                s.pop(i)
            elif s[i] == a and i < len(s) - 1 and adj(s[i], s[i+1]):
                s.pop(i)
            else:
                i += 1

print(n - len(s))


d = dict()
ans = 1e8

def solve(x,n):
	global ans
	if x in d:
		return d[x]
	ans = min(ans,n)
	d[x] = n+1
	for i in range(n-1):
		if abs(ord(x[i])-ord(x[i+1])) == 1:
			if x[i] > x[i+1]:
				d[x] = min(d[x],solve(x[:i]+x[i+1:],n-1))
			else:
				d[x] = min(d[x],solve(x[:i+1]+x[i+2:],n-1))
	else:
		d[x] = n
	return d[x]

n = int(input())
s = input()
solve(s,n)
print(n-ans)


interval_a, travel_a = map(int, raw_input().split())
interval_b, travel_b = map(int, raw_input().split())
first = 5 * 60
last = 23 * 60 + 59

h, m = map(int, raw_input().strip().split(':'))
depart = h * 60 + m
arrive = depart + travel_a

# Buses that departed from B before the given bus arrived at B:
b_departures = 1 + (min(last, arrive) - first - 1) // interval_b

# Buses that arrived at A by the time the given bus departed from A:
a_arrivals = 0
if depart >= first + travel_b:
  a_arrivals = 1 + (depart - first - travel_b) // interval_b

#print(b_departures, a_arrivals)
print(b_departures - a_arrivals)


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

def read_line():
    return raw_input().strip()

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

MIN, MAX = 300, 24 * 60
a, ta = read_ints()
b, tb = read_ints()
hh, mm = read_line().split(':')
start = int(hh) * 60 + int(mm)
until = min(start + ta, MAX)

z = max(MIN, start - tb - 1)
x = z + (MIN - z) % tb
if x >= until:
    print 0
else:
    print 1 + (until - x - 1) / b


n = list(map(int, input().split()))
n.sort()
a = n[0]
b = n[1]
c = n[2]
print((b - a) + (c - b)


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

a = int(sum(x) / len(x))

print (abs(x[0] - a) + abs(x[1] - a) + abs(x[2] - a))


numeros=input(" ")
numeros=numeros.split(" ")
numeros.sort()
int(mini),int(med),int(maxi)=numeros
menor=200
for itera in range(maxi-mini):
	suma=0
	itera=itera+mini
	suma+=abs(mini-itera)
	suma+=abs(med-itera)
	suma+=abs(maxi-itera)
	if suma<=menor:
		menor=itera

print(menor)


x1, x2, x3 = map(int(input().split(' ')
m = 1000
for x in range(1, 101):
    mm = abs(x1 - x) + abs(x2 - x) + abs(x3 - x)
    if mm < m:
        m = mm
print(m)


arr=list(map(int, input().split()))
n=arr[0]
m=arr[1]
a=arr[2]
b=arr[3]
ans=0
if(n%m==0):
    print(n//m*b)
else:
    ext=n%m
    ext*=m
    ans+=n//m*b
    while(ext!=0):
        ans+=a
        ext-=a
    print(ans)


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

# In[59]:

import math

# In[100]:

inp = input()
#inp = '6 3 5 1'

# In[101]:

#n = number of rides
#m = number of rides per special ticket
#a = one ride price
#b = price of special ticket

# In[102]:

arr = inp.split()
n = int(arr[0])
m = int(arr[1])
a = int(arr[2])
b = int(arr[3])

# In[103]:

if a*m > b:
    einzelt = n % m
    specialt = n // m
    if einzelt * a < b:
        print(einzelt * a + specialt * b)
    else:
        print(b + specialt * b)
else:
    print(n * a)

# In[107]:

specialt

# In[ ]:


from math import gcd,factorial
a,b = map(int,input().split())
print(gcd(factorial(a),factorial(b)))


a = sorted([int(i) for i in input().split()]
print(max(0, a[2]-a[1]-a[0]+1))


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

def BubbleSort(arr):
    for pannum in range(n-1,0,-1):
        for i in range(pannum):
            if arr[i]>arr[i+1]:
                arr[i], arr[i+1] = arr[i+1], arr[i]

BubbleSort(t)
res = 'No'
for k in range(n-2):
    if t[k+2] - t[k] <= 2 and t[k+2] - t[k] > 0 and t[k+1] != t[k] and t[k+2] != t[k+1]:
        res = 'Yes'
        break
print (res)


#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <climits>
#include <map>
#include <iterator>
#include <queue>
#include <string>
#include <stack>
using namespace std;

int main() {
#ifdef  __linux__
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);

	return 0;
}


def lucky(x):
    s=str(x)
    return s.count('4')+s.count('7')==len(s)

def Gen_lucky(n):
    s=str(n)
    if(len(s)==1):
        if(s[0]>='7'):
            return 2
        if(s[0]>='4'):
            return 1
        return 0
    x=0
    for i in range(1,len(s)):
        x+=2**i
    if(s[0]<'4'):
        return x
    if(s[0]>'7'):
        return x+2**len(s)
    if(s[0]=='5' or s[0]=='6'):
        return x+(2**(len(s)-1))
    if(s[0]=='7'):
        x+=2**(len(s)-1)
    x+=Gen_lucky(s[1:])
    return x

def Form(X,k):
    if(k==0):
        return X
    for i in range(len(X)):
        if(k>=F[len(X)-i-1]):
            h=k//F[len(X)-i-1]
            r=k%F[len(X)-i-1]
            G=list(X[i+1:])
            G.remove(X[i+h])
            G=[X[i]]+G
            return Form(X[:i]+[X[i+h]]+G,r)

p=1

F=[1]
i=1
while(p<=10**15):
    p*=i
    F.append(p)
    i+=1

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

if(n<=14):
    if(k>F[n]):
        print(-1)
    else:
        L=Form(list(range(1,n+1)),k-1)
        x=0
        for i in range(n):
            if(lucky(i+1) and lucky(L[i])):
                x+=1
        print(x)
else:
    L=Form(list(range(n-14,n+1)),k-1)
    x=Gen_lucky(n-15)
    for i in range(n-14,n+1):
        if(lucky(L[i-n+14]) and lucky(i)):
            x+=1
    print(x)


def lucky(x):
    s=str(x)
    return s.count('4')+s.count('7')==len(s)

def Gen_lucky(n):
    s=str(n)
    if(len(s)==1):
        if(s[0]=='4' or s[0]=='7'):
            return 1
        return 0
    x=0
    for i in range(1,len(s)):
        x+=2**i
    if(s[0]<'4'):
        return x
    if(s[0]>'7'):
        return x+2**len(s)
    if(s[0]=='5' or s[0]=='6'):
        return x+(2**(len(s)-1))
    if(s[0]=='7'):
        x+=2**(len(s)-1)
    x+=Getlucky(s[1:])
    return x

def Form(X,k):
    if(k==0):
        return X
    for i in range(len(X)):
        if(k>=F[len(X)-i-1]):
            h=k//F[len(X)-i-1]
            r=k%F[len(X)-i-1]
            G=list(X[i+1:])
            G.remove(X[i+h])
            G=[X[i]]+G
            return Form(X[:i]+[X[i+h]]+G,r)

p=1

F=[1]
i=1
while(p<=10**10):
    p*=i
    F.append(p)
    i+=1

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

if(n<=15):
    L=Form(list(range(1,n+1)),k-1)
    x=0
    for i in range(n):
        if(lucky(i+1) and lucky(L[i])):
            x+=1
    print(x)
else:
    L=Form(list(range(n-13,n+1)),k-1)
    x=Gen_lucky(n-14)
    for i in range(n-13,n+1):
        if(lucky(L[i-n+13]) and lucky(i)):
            x+=1
    print(x)


def lucky(x):
  while x>0:
    d=x%10
    x/=10
    if d!=4 and d!=7:
      return False
  return True
n,k=map(int,raw_input().split())
k-=1
p=[1]*16
for i in xrange(13):p[i+1]=p[i]*(i+1)
a=[]
def n_th(x):
  if n-x<13:
    return a[x-1-n]+max(0,n-13)+1
  else:
    return x
if n<=13 and k>=p[n]:print -1
else:
  s=[1]*n
  for b in reversed(xrange(min(13,n))):
    u=0
    while k>=p[b]:
      k-=p[b]
      while not s[u]:u+=1
      u+=1
    while not s[u]:u+=1
    a.append(u)
    s[u]=0
  t=0
  for w in xrange(1,10):
    for x in xrange(1<<w):
      y=0
      for b in xrange(w):
        y=y*10+(7 if ((1<<b)&x) else 4)
      if y<=n and lucky(n_th(y)):t+=1
  print t


def lucky(x):
  while x>0:
    d=x%10
    x/=10
    if d!=4 and d!=7:
      return False
  return True
n,k=map(int,raw_input().split())
k-=1
p=[1]*16
for i in xrange(13):p[i+1]=p[i]*(i+1)
a=[]
def n_th(x):
  if n-x<13:
    return a[x-1-n]
  else:
    return x
if n<=13 and k>=p[n]:print -1
else:
  s=[1]*n
  for b in reversed(xrange(min(13,n))):
    u=0
    while k>=p[b]:
      k-=p[b]
      while not s[u]:u+=1
      u+=1
    while not s[u]:u+=1
    a.append(u+1)
    s[u]=0
  t=0
  for w in xrange(1,10):
    for x in xrange(1<<w):
      y=0
      for b in xrange(w):
        y=y*10+(7 if ((1<<b)&x) else 4)
      if y<=n and lucky(n_th(y)):t+=1
  print t


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

if avg%3==0:
    count=0
    avg = avg//3
    for i in a:
        count += abs(i-avg)
    print(count)
else:
    avg1 = (avg//3)+1
    avg = avg//3
    x = 0
    y=0
    for i in a:
        x += abs(i - avg1)
        y += abs(i-avg)
    print(min(x,y)


import math, sys
from collections import defaultdict, Counter, deque

INF = float('inf')
MOD = int(1e9) + 7

def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

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

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

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

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

def lucky(num, n):

	if len(str(num)) > n:
		return 0

	num1 = int(str(num) + '7')
	num2 = int(str(num) + '8')

	return lucky(num1, n) + lucky(num2, n) + 1

def main():
	n = int(input())

	print(lucky(0, n) - 1)

if __name__ == "__main__":
	t = 1
	# t = int(input())
	for _ in range(t):
		main()


import math

n = (int)(input())
print((int)math.pow(2, n + 1) - 2)


#https://codeforces.com/problemset/problem/630/C
import itertools
n=int(input())
c=0
l=[7,8]
for i in range(1,n+1):
	x=[p for p in itertools.product(l, repeat=i)]
	#print(list(x))
	c+=len(list(x))
print(c)


a = int(input())
su =0
for i in range(1, a+1)
       su += 2**i
print(su)