tab1 = dict()
tab2 = dict()

def num1(n):
    if n < 0:
        return 0
    if n < 2:
        return 1
    if n not in tab1:
        r = 0
        for i in range(n):
            r += num1(i) * num1(n - 1 - i)
        tab1[n] = r
    return tab1[n]

def num2(n, h):
    if n < 0 or h <= 0 or n >= 2 ** (h - 1):
        return 0
    if n < 2:
        return 1
    if (n, h) not in tab1:
        r = 0
        for i in range(n):
            r += num2(i, h - 1) * num2(n - 1 - i, h - 1)
        tab2[n, h] = r
    return tab2[n, h]

n, h = map(int, raw_input().split())
print num1(n) - num2(n, h)


from math import factorial
def solve(n,p,a):
    if p is 9:
        if n>=a[9]:
            return 1
        else:
            return 0
    elif p is 0:
        ans=0
        for i in range(a[0],n):
            z=solve(n-i,1,a)
            z*=factorial(n-1)
            z//=factorial(i)
            z//=factorial(n-1-i)
            ans+=z
        return ans
    else:
        ans=0
        for i in range(a[p],n+1):
            z=solve(n-i,p+1,a)
            z*=factorial(n)
            z//=factorial(i)
            z//=factorial(n-i)
            ans+=z
        return ans
hell=1000000007
n=int(input())
a=input().rstrip().split(' ');
for i in range(0,len(a)):
    a[i]=int(a[i])
ans=0
for i in range(1,n+1):
    ans+=solve(i,0,a)
    ans%=hell
print(ans)


from math import factorial
from functools import partial, reduce
from operator import mul
from fractions import Fraction

fact = [1]*101
for i in xrange(1, 101): fact[i] = i*fact[i-1]

spi = partial(reduce, mul)
def comb(a, *args):return factorial(a)/spi(factorial(x) for x in args)
n = int(raw_input())
Ay = [int(i) for i in raw_input().split()]
Az = ([Ay[0]-1]+Ay[1:]) if Ay[0] > 0 else Ay[:]
m = sum(Ay)

if m > n:
    print 0
    exit()

Y = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]
IY = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]
Z = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]
IZ = [[[0]*10 for j in xrange(10)] for i in xrange(n-m)]

y = fact[m]/spi(fact[Ay[k]] for k in xrange(10))
z = (fact[m-1]/spi(fact[Az[k]] for k in xrange(10))) if Ay[0] != 0 else 0

def next_table(A, X, IX, x, i, m):
    S = 0
    p = fact[m+i+1]/fact[m]
    X[i][0] = [fact[n]*fact[A[k]]/fact[A[k]+(i+1)] for k in xrange(10)]
    S += p*x*sum(X[i][0])/fact[n]
    IX[i][0] = [sum(X[i][0][k+1:]) for k in xrange(10)]
    for j in xrange(1, min(i+1, 10)):
        for k in xrange(10):
            for l in xrange(i):
                X[i][j][k] += X[l][0][k]*IX[i-l-1][j-1][k]/fact[n]
        S += p*x*sum(X[i][j])/fact[n]
        IX[i][j] = [sum(X[i][j][k+1:]) for k in xrange(10)]
    return S

S = y-z
Sy = y
if z:
    for i in xrange(n-m):
        Sz = next_table(Az, Z, IZ, z, i, m-1)
        Sy = next_table(Ay, Y, IY, y, i, m)
        S += Sy-Sz
else:
    for i in xrange(n-m):
        Sz = Sy
        Sy = next_table(Ay, Y, IY, y, i, m)
        S += Sy-Sz

if Ay.count(0) == 10: S-=1
print S % 1000000007


global p
def F(x):
	if x==0:
		return 0,1
	elif x&1:
		a,b=F(x-1)
		return b,(a+b)%p
	else:
		a,b=F(x/2)
		return a*(2*b-a)%p,(a*a+b*b)%p
w=input()
p=10
l=60
z=[]
for i in range(l):
	if F(i)[0]==w%p:
		z.append(i)
for i in range(12):
	p*=10
	z=[i+j*l for i in z for j in range(10) if F(i+j*l)[0]==w%p]
	l*=10
if z==[]:
	print -1
else:
	print min(z)


n= raw_input();
s=raw_input();
z=s.split ("0");
decodednum=0;
for a in z:
 decodednum*=10;
 decodednum+=len (a);
print decodednum


n = raw_input()
print (*map(len, raw_input().split("0")), sep='')


length = input("input:")
string = input("input string:")
string = string.split('0')
result = "
for i in string:
    result += str(len(i))
print(int(result))


=int(input())
s=input()
ones=0
newn=1
ans=""
i=0

while(i<n):
    if(s[i]=="1"):
        j=i+1
        ones=1
        while(j<n and s[j]=="1"):
            ones+=1
            j+=1
        ans+=str(ones)
        i=j
    else:
        z=1
        j=i+1
        while(j<n and s[j]=="0"):
            z+=1
            j+=1
        if z>1:
            for k in range(0,z,2):
                ans+="0"
        i=j
print(ans)


n = int(input())
s = input() + '0'
ans = 0
i = 0
while i < n:
    ctr = 0
    while i != '0':
        ctr += 1
        i += 1
    i += 1
    ans *= 10
    ans += ctr
print(ans)


n = int(input())
if(n % 2 != 0):
    print(0)
else:
    if(n == 2):
        print(2)
    else:
        a = 2
        for(i in range(int(n/2) - 1)):
            a *= 2
        print(a)


a=int(input())
b=0
if a%2:
    print(pow(2,(a/2))
else:
    print(b)


a=int(input())
if a%2:
    print(pow(2,(n/2))
else:
    print(0)


n=int(input())
if (n*3)%6==0:
    print((n)
else:
    print(0)


n=int(input())

if n%2==0:
    print( 2**(n/2) )
else
    print(0)


n=int(input())
if n==3:
    print("24")
elif n==4:
    print("132")
else:
    cap=(2n-2)
    ans=2*(12*pow(4,(n-3)))
    tmp=n-4
    if tmp>=0:
        ans+=tmp*(36*pow(4,tmp))
    print(ans)


def power(3,n):
    p=1
    for i in range(n):
        p=p*3
    return p
def ans(n):
    return power(n-2)*n*(n-1)
n=int(input())
print(ans(n))


import math
 n =int(input())

 print(8*3*(math.pow(4,n-3)) * (n-3)*4*9*(math.pow(4,(n-4))))


from math import gcd,sqrt
n=int(input())
t=0
for i in range(1,int(sqrt(n)+1):
    if n%i==0:
        a=i
        b=n//i
        GCD=gcd(a,b)
        if GCD==1:
            t=i

print(t,n//t)


    import math
    x=int(input())
    i=1
    while i*i <= x:
     if x%i<1==math.gcd(x//i,i):r=i
     i+=1
    print(r,x//r)


def factors(x):
   l=[]
   for i in range(1, x + 1):
       if x % i == 0:
           l.append(i)
    return l

def lcm(x, y):
   # choose the greater number
   if x > y:
       greater = x
   else:
       greater = y
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
   return lcm
x=int(input())
l=factors(x)
m=[]
i=len(l)-1
while i>=1:
    if lcm(l[i],l[i-1])==x:
        m.append(l[i-1],l[i])
        i=i-1
    else:
        break
m.sort
print(m[0])


def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a, a)
def lcm(a,b):
    return (a*b)//gcd(a,b)

def myqs(x):
    i = 1
    a = 1
    while i<=x//i and if x%i==0:
        if lcm(i,x//i)==x:
            a = i
        i += 1
    return (str(a) + " " + str(x//a))
x = int(input())
print(myqs(x))


import math
x=int(input())
ans=10**18
for i in range(1,int(x**.5)+1):
    if x%i==0:
        if (math.gcd(i,x//i)==1:
            if max(i,x//i)<ans:
                ans=max(i,x//i)
                a=[i,x//i]
print(*a)


n=input()
def isprime(n):
    for i in range(2,int(n**.5)+1):
        if n%i==0: return 0
    return 1
l=[]
for i in range(2,1300):
    if(isprime(i)==1):l.append(i)
ind=0
if n!=1 print n
while n>1 and l[ind]*l[ind]<=n:
    if(n%l[ind]==0):
        n/=l[ind]
        print n
    else: ind+=1
print 1


n=int(input())
for i in range(n,0,-1):
   if n%i==0
        n=i
        print(n)


def b(n):
  ans = [n]
  for x in xrange(2, n):
    while n % x == 0:
      n /= x
      ans.append(n)
  return ' '.join(map(str, ans))

"""
print b(10)
print b(4)
print b(3)
"""
print b(int(raw_input())
#"""


n = int(input())
res = [n]
for i in range(n-1,0,-1):
    if all(y % i == 0 for y in res):
        res.append(i)
print(' '.join([str(i) for i in res])


n=int(input())
for i in range(n,0,-1):
    if n%i==0
        n=i
        print(n)


m, r = map(int, input().split())
res, sq2 = 0, (2**.5)
for i in range(1, m):
    res += 2 + sq2 + 2 * sq2 * (i-1) + (i-1) * i
res = (res + m) * 2 * r
print(res / (m * m))


#!/usr/bin/env python3

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

can = 1 in xs
can |= xs.count(2) == 2
can |= xs.count(2) == 1 and xs.count(4) = 2
can |= xs == [3, 3, 3]

print("YES" if can else "NO")


A = list(map(int, input().split()))
cntOne = A.count(1)
cntTwo = A.count(2)
cntThree = A.count(3)
cntFour = A.count(4)

if cntOne >= 1 or cntTwo >= 2 or cntThree >= 3 or (cntTwo = 1 and cntFour = 2):
    print("YES")
else:
    print("NO")


 k = [int(x) for x in input().split()]
ans = 1

if k.count(2) >= 2 or k.count(2) == 1 and k.count(4) == 2 or k.count(1) > 0 or k.count(3) == 3:
    ans -= 1

print('YNEOS'[ans::2])


A = list(map(int,input().split()))
A.sort()
if(A[0]==1):
    print("YES")
elif(A.count(2)>=2):
    print("YES")
elif(A.count(3)>=3):
    print("YES")
elif(A[0]=2 and A.count(4)==2):
    print("YES")
else:
    print("NO")


import sys

inp = input().split()
    m = inp[0]
    n = inp[1]
    m_5 = m % 5
    n_5 = n % 5
    res = m*n//5
    for i in range(m_5):
        for j in range(n_5):
            if i+j % 5 == 0:
                res += 1

    print(res)


n, m = map(int, input().split())
ans = n // 5 * 5 * (m // 5)
x = n // 5
y = m // 5
x1 = n % 5
y1 = m % 5
ans += x1 * y + y1 * x
for i in range(1, x1 + 1):
    for j in range(1, y + 1):
            if (i + j) % 5 == 0:
                ans++
print(ans)


n, m = input().split(" ")
print(round(int(n) * int(m) / 5))


#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py

Created by Kyno on 2012-06-09.
Copyright (c) 2012 __MyCompanyName__. All rights reserved.
"""

import sys
import os
import math
def how_many(R,r):
    rr = r + r
    Rr = R - r
    if Rr == 0:
        return 1
    cos = (Rr*Rr + Rr*Rr - rr*rr)/(2*Rr*Rr)
    angle = math.degrees(math.acos(cos))
    return int(360.0 / angle)

def main():
    input_arr = raw_input().rstrip().split()
    n ,R,r = map(int, input_arr)
    count = 0
    while R >= r:
        count += how_many（float(R),float(r))
        R -= r*2
    if count >= n:
        print "YES"
    else:
        print "NO"

if __name__ == '__main__':
    main()


from math import acos, pi
n, R, r = map(float, raw_input().split())
if r > R:
  print "NO"
elif r > R / 2:
  print "YES" if n == 1 else "NO"
else
  a2, c2 = (R - r) ** 2, (2 * r) ** 2
  angle = acos(1 - (c2/(2*a2)))
  print "YES" if n * angle <= 2 * pi else "NO"


import sys
import math

def theta(R, r):
    return 2 * math.asin(1.0 * r / (R - r))

def can(n, R, r):
    if r >= R:
        return r == R and n == 1
    else if 2 * r >= R:
        return 2 * r == R and n == 2 or n == 1
    else:
        return theta(R, r) * n <= 2 * math.pi + 1e-6

n, R, r = [int(s) for s in sys.stdin.readline().split(' ')]
print ("YES" if can(n, R, r) else "NO")


1#r=r
n#r=r+r/sin(pi/n)
s[n,q,r]|q+1e-5>=n#r="YES"|1>0="NO"
main=interact$s.map read.words


n, R, r = map(int,raw.input().split())
ans = true
if (r > R): ans=false
if (n==1): ans=(r<=R)
ans = ans&&((R-r)/sin(pi/n)>=r)
if (ans==false): print("NO")
else: print("YES")
from math import *


w, m, k = input().split()
k = int(w) // int(k)
l, m = len(m), int(m)
s = pow(10, l)
if (s - m) * l > k: print(k // l)
else:
    k -= (s - m) * l
    l += 1
    d = 9 * s
    while d * l <= k:
        k -= d * l
        l += 1
        s += d
	d = 9 * s
    print(s - m + k // l)


w, m, k = input().split()
k = int(w) // int(k)
l, m = len(m), int(m)
s = pow(10, l)
if (s - m) * l > k: print(k // l)
else:
    k -= (s - m) * l
    l += 1
    d = 9 * s
    while d * l <= k:
        k -= d * l
        l += 1
        s += d
		d = 9 * s
    print(s - m + k // l)


#include <cstdio>
#include <vector>
#include <algorithm>
#include <deque>
#include <iostream>
#include <cstring>
#include <set>
#include <map>
using namespace std;

int gcd(int a, int b)
{
    while(a)
    {
        b %= a;
        swap(a, b);
    }
    return b;
}

int main()
{
    int t, n, k, a[50], s, ts;
    scanf("%d", &t);
    for(int i = 1; i <= t; ++i)
    {
        scanf("%d%d", &n, &k);
        s = 0;
        for(int j = 0; j < n; ++j)
        {
            scanf("%d", a + j);
            s += a[j];
        }
        sort(a, a + n);
        ts = 0;
        for(int j = 0, p = 2; j < n; ++j)
        {
            if(j == 0 && a[j] == 0)
                a[j] == 0;
            else if(a[j] <= k)
                a[j] = k;
            else
            {
                for(int q = max(p, a[j] / k); ; ++q)
                {
                    bool ok = true;
                    for(int m = 0; m < j; ++m)
                        ok &= gcd(a[m] / k, q) == 1;
                    if(ok)
                    {
                        a[j] = k * q;
                        p = q + 1;
                        break;
                    }
                }
            }
            ts += a[j];
        }
        printf("Case #%d: %d\n", i, ts - s);
    }
    return 0;
}


m=int(raw_input());
n=int(raw_input());
k=int(raw_input());

i=n;
len=0;
while(i>0):
    len=len+1;
    i/=10;
n=n-1;
j=1;
i=1;
while(i<=len):
    j=j*10;
    i=i+1;
j=j-1;
ans=0;
cost=k*len;
while(m>0):
    if(j-n<m/cost):
        ans=ans+j-n;
    else:
        ans=ans+m/cost;
    m=m-(j-n)*cost;
    n=j;
    j=((j+1)*10)-1;
    cost=cost+k;
print(ans);


w,m,k=map(int,raw_input().split())
w=w/k
if w<=0:
    print ans
    exit()
l=len(str(m))
s=10**l
n=l
w-=n*(s-m)
ans=s-m
if w<=0:
    print ans
    exit()
s*=10
n+=1
while w>s:
    ans+=9*s
    w-=9*s*n
    s*=10
    n+=1
print ans+w/n


a,b,c=list(map(int,input().split()))
ans = 0
while (a>!=0):
	if c>b and b>a:
		ans+=7
	a-=1
	b-=2
	c-=4
print(ans)


a = int (input())
b = int ( input())
c = int (input())
d = a
for i in range (a) :
    if d *2 <= b and d *4 <= c :
        f= d *2
        e = d *4
        print (d + f + e )
        break
    d = a-1
if b < 2 and c <4 or b<2 or c<4 :
    print (0)
if a == b and b== c and a==c :
    print ((a//4)+(b//2)+(c) )
if a=1 and b=1 and c=1:
    print(0)


a = int (input())
b = int ( input())
c = int (input())
d = a
for i in range (a) :
    if d *2 <= b and d *4 <= c :
        f= d *2
        e = d *4
        print (d + f + e )
        break
    d = a-1
if b < 2 and c <4 or b<2 or c<4 :
    print (0)
if a = b and b= c and a=c :
    print ((a//4)+(b//2)+(c) )


a = int (input())
b = int ( input())
c = int (input())
d = a
for i in range (a) :
    if d *2 <= b and d *4 <= c :
        f= d *2
        e = d *4
        print (d + f + e )
        break
    d = a-1
if b < 2 and c <4 or b<2 or c<4 :
    print (0)
if a = b and b= c and a= 1000 :
    print (1750 )


n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)

maximum = 0
i = 0
while i < n and i * s <= m:
    cur = m - s * i
    ans = (k + 1) * i
    for i in range(k):
        if cur < a[i]:
            break
        c = min(n - i, cur // a[i])
        cur -= a[i] * c
        ans += c
    maximum = max(maximum, ans)

print(maximum)


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

times = sorted(list(map(int, raw_input().split())))
for_task = sum(times)

result = 0
fully_solved = 0
while fully_solved * for_task <= M:
    curr_result = fully_solved * (k + 1)
    time_rest = M - fully_solved * for_task
    for t in times:
        if t * n > time_rest:
            l = 0
            r = n + 1
            while r - l != 1:
                mid = (l + r) / 2
                if t * mid > time_rest:
                    r = mid
                else:
                    l = mid
            curr_result += l
            break
        else:
            time_rest -= t * n
            curr_result += n

    result = max(curr_result, result)
    fully_solved += 1
    n -= 1

print result


k, n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
s = sum(a)
a.sort()
ans = 0
for i in xrange(m / s + 1):
    p = i * (n + 1)
    t = m - i * s
    for x in a:
        if t >= x * (k - i):
            t -= x * (k - i)
            p += k - i
        else:
            p += t / x
            break
    if ans < p:
        ans = p
print ans


n,k,m = list(map(int, input().split()))
t = sorted(map(int, input().split()))
st = sum(t)
res = 0
for x in range(m//st+1):
    rem = m-x*st
    m = x*(k+1)
    # for i in range(k):
        # y = min(rem//t[i], n-x)
        # rem -= t[i]*y
        # m += y
    for i in range(k):
        for _ in range(n-x):
            if rem >= t[i]:
                rem -= t[i]
                m += 1
    res = max(res, m)
print(res)


 f = lambda: map(int, input().split())
n, k, m = f()
p = sorted(f())
x = 0
s = sum(p)
for j in range(n + 1):
    t = m - j * s
    if t < 0: break
    y = k * j + j
    for i in p:
        d = min(n - j, t // i)
        y += d
        t -= d * i
    x = max(x, y)
print(x)


def main ():
  n, k = [int(n) for n in input().split()]
  S = input();
  doors = {}

  for i, s in enumerate(S):
    doors[s] = i

  activeDoors = set();
  for i, s in enumerate(S):
    if doors[s] == i:
      activeDoors.remove(s);
    else:
      activeDoors.add(s);
      if(len(activeDoors) > k):
        return "YES"

  return "NO"

print(main())


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

import string
import sys

def main():
    iterator = iter(sys.stdin.read().split())
    n, m = int(next(iterator)), int(next(iterator))
    s = next(iterator)
    p = {}
    buffer = set()
    for i in string.ascii_uppercase:
        p[i] = s.rfind(i)
    for i, x in enumerate(s):
        if i < p[x]:
            buffer.add(x)
            if len(buffer) > m:
                print('YES')
                return
        else:
            buffer.remove(x)
    print('NO')

if __name__ == '__main__':
    main()


def read(is_int,split_by):
	if(is_int):
		return [int(x) for x in input().split(split_by)]
	else:
		return [x for x in input().split(split_by)]

s,f = read(False," ")
n = int(input())
seq = ['<','^','>','v']
k = n%4
spin = "undefined"
ind_s = seq.index(s)
# Case of k == 0 undefined
if not(k%2==0) or not(s == f):
	if f == seq[ind_s-k]:
		spin = "ccw"
	elif f == seq[ind_s+k]:
		spin = "cw"
print(spin)


def read(is_int,split_by):
	if(is_int):
		return [int(x) for x in input().split(split_by)]
	else:
		return [x for x in input().split(split_by)]
n, k = map(int,input().split(" "))
s = input()
answer = "NO"
high = {}
low = {}
all_intersect = []
all_max = []
if k == 26:
	answer = "NO"
else:
	for i in range(n):
		if not (s[i] in low):
			low[s[i]] = i
		high[s[i]] = i
	for key in low:
		all_intersect.append(low[key])
	for key in high:
		all_intersect.append(high[key])
	all_intersect.sort()
	for i in range(len(all_intersect)):
		if all_intersect[i] in low.values():
			if all_max:
				tmp = all_max[len(all_max)-1]
				tmp += 1
				all_max.append(tmp)
			else:
				all_max.append(1)
		if all_intersect[i] in high.values():
			tmp = all_max[len(all_max)-1]
			tmp -= 1
			all_max.append(tmp)

max_elem = max(all_max)
if max_elem > k:
	answer = "YES"
else:
	answer = "NO"
print(answer)


]n,k=map(int,input().split())
st=input()
ans=True
count=0
stat={}
last={}

for i in range(n):
    last[st[i]]=i
    stat[st[i]]=False
for i in st:
    if(stat[i]==False):
        stat[i]=True
        count+=1
    if(count>k):
        ans=False
        break
    if(last[i]==i):
        count-=1

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


#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys, io
import re, math
start = time.clock()
l=list(raw_input())
while 1:
    ans,chk=0,[]
    stp=set(l)
    if len(stp)==len(l):
        cnt=0
        break
    for i in range(len(l)):
        if l[i] not in chk:
            cnt,j=2,i+1
            while l[i]!=l[j]:
                cnt+=1
                j+=1
            ans=max(ans,cnt)
            chk.append(l[i])
    break
print ans


import sys

def main():
    s = raw_input()
    l = len(s)

    freq = {}
    substrings = [s[i:j+1] for i in xrange(l) for j in xrange(i, l)]
    for s in substrings:
	freq[s] = freq.get(s, 0) + 1

    print max([len(s) for s, cnt in freq.items() if cnt > 1  ])

if __name__ == '__main__':
    main()


"""
$ pylint calderonsin.py
Global evaluation
-----------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

"""
def maxlen:
    string = input()
    max = 0;
    for x in range(len(string)):
        substring = ""
        for y in string[x:]:
            substring +=y;
            if string[x:].rfind(curr) != string[x:].find(curr):
                totalmax = max(totalmax, len(curr))
                continue
    print(totalmax)

maxlen()
# $ python3 calderonsin.py build
# remember the output


import sys, re
s=sys.stdin.read()
n=len(s)

res=0
for i in range(n):
	for j in range(i):
		tmp=0
		for k in range(n):
			if re.match(s[j:i], s[k:]):
				tmp+=1
		if tmp>=2:
			res=max(res,i-j)
print res


string = str(raw_input())
l = len(string)
ans = 0
for i in range(l):
    for j in range(i + 1 , l):
        for k in range(1 , l):
            if i + k - 1 < l and j + k - 1 < l:
                flag = True
                for x in range(k):
                    if string[i + x] != string[j + x]:
                        flag = False
                        break
                if flag == True and k > ans:
                    ans = k
print ans


def isCovered(p1, p2, p3, p4, p5, p6):
    x1,y1 = p1 #cp bottom left
    x2,y2 = p2 #cp top right
    x3,y3 = p3 #t1 bottom left
    x4,y4 = p4 #t1 top right
    x5,y5 = p5 #t2 bottom left
    x6,y6 = p6 #t2 top right

    if (x5 <= x1 and y5 <= y1 and x6 >= x2 and y6 >= y2) or (x3 <= x1 and y3 <= y1 and x4 >= x2 and y4 >= y2):
        return "COMPLETELY COVERED"
    elif y5 <= y1 <= y2 <= y6 and y3 <= y1 <= y2 <= y4 and x5 <= x1 < x6 and x3 <= x2 < x4 and (x6-x1+x2-x3) >= (x2-x1):
        return "COMPLETELY COVERED"
    elif x5 <= x1 <= x2 <= x6 and x3 <= x1 <= x2 <= x4 and y5 <= y1 < y6 and y3 <= y2 < y4 and (y6-y1+y2-y3) >= (y2-y1):
        return "COMPLETELY COVERED"
    elif y5 <= y1 <= y2 <= y6 and y3 <= y1 <= y2 <= y4 and x3 <= x1 < x4 and x5 <= x2 < x6 and (x4-x1+x2-x5) >= (x2-x1):
        return "COMPLETELY COVERED"
    elif x5 <= x1 <= x2 <= x6 and x3 <= x1 <= x2 <= x4 and y3 <= y1 < y4 and y5 <= y2 < y6 and (y4-y1+y2-y5) >= (y2-y1):
        return "COMPLETELY COVERED"
    else:
        return "NOT COMPLETELY COVERED"

first=map(int,input().split())
second=map(int,input().split())
third=map(int,input().split())
p1=(first[0],first[1])
p2=(first[2],first[3])
p3=(second[0],second[1])
p4=(second[2],second[3])
p5=(third[0],third[1])
p6=(third[2],third[3])
if(isCovered(p1,p2,p3,p4,p5,p6)=="CMPLETELY COVERED")
    print("YES")
else:
    print("NO")


# union(W, B1) + union(W, B2) - union(W, B1, B2) = W
W = list(map(int, input().split()))
B1 = list(map(int, input().split()))
B2 = list(map(int, input().split()))

def union(A, B, C=None):
    # x1, y1 = [0][1] / x2, y2 = [2][3]
    # W_x1 < B_x2 and W_x2 > B_x1 , y1<y2 and y2>y1
    Aleft, Abottom, Aright, Atop = A
    Bleft, Bbottom, Bright, Btop = B
    if C != None:
        Cleft, Cbottom, Cright, Ctop = C
        if (Bleft < Cright and Bright > Cleft) and (Bbottom < Ctop and Btop > Cbottom):
            Bleft = max(Bleft, Cleft)
            Bright = min(Bright, Cright)
            Bbottom = max(Bbottom, Cbottom)
            Btop = min(Btop, Ctop)
        else:
            Bleft, Bbottom, Bright, Btop = 0, 0, 0, 0
    if (Aleft < Bright and Aright > Bleft) and (Abottom < Btop and Atop > Bbottom):
        width = min(Aright, Bright) - max(Aleft, Bleft)
        height = min(Atop, Btop) - max(Abottom, Bbottom)
        return width*height
    else:
        return 0

        if union(W, B1) + union(W, B2) - union(W, B1, B2) == (W[2]-W[0]) * (W[3]-W[1]):
    print('NO')
else:
    print('YES')


def fun(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):
    if y3 <= y1 and y4 >= y2 and x3 <= x1 gand y5 <= y1 and y6 >= y2 and x6 >= x2 and x4 < x2 and x4>=x1:
        return True
    return False

def fun2(x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4):
    if x3<=x1 and x4>=x2 and y4>=y2 and y3<=y1:
        return True
    return False

def fun3(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):
    if x3<=x1 and x4>=x2 and x5<=x1 and x6>=x2 and y4>=y2 and y6>=y3 and y5<=y1 and y3 > y1 and y3 <=y2:
        return True
    return False

x1 , y1 , x2 , y2 = map(int,input().split())
x3 , y3 , x4 , y4 = map(int,input().split())
x5 , y5 , x6 , y6 = map(int,input().split())

ok = False
if fun2(x1,y1,x2,y2,x3,y3,x4,y4):
    ok = True
    # print(ok , 1)
if fun2(x1,y1,x2,y2,x5,y5,x6,y6):
    ok = True
    # print(ok , 2)
if fun(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):
    ok = True
    # print(ok , 3)
if fun(x1,y1,x2,y2,x5,y5,x6,y6,x3,y3,x4,y4):
    ok = True
    # print(ok , 4)

if fun3(x1,y1,x2,y2,x5,y5,x6,y6,x3,y3,x4,y4):
    ok = True
    # print(ok , 5)
if fun3(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6):
    ok = True
    # print(ok , 6)
if(ok):
    print("NO")
else:
    print("YES")


a= list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
if(b[0]<=a[0]and b[1]<=a[1]):
    if(b[2]>=a[2] and b[3]>=a[3]):
        print('NO')
    elif (b[2]>=a[2]):
        x=a[0]
        y=b[3]
        if(c[0]<=x and c[1]<=y):
            if(c[2]>=a[2] and c[3]>=a[3]):
                print('NO')
            else:
                print('YES')
        else:
            print('YES')
    elif b[3]>=a[3]:
        x = b[2]
        y = a[1]
        # print(x,y)
        if (c[0] <= x and c[1] <= y):
            if (c[2] >= a[2] and c[3] >= a[3]):
                print('NO')
            else:
                print('YES')
        else:
            print('YES')
    else:
        print('YES')
elif(c[0]<=a[0]and c[1]<=a[1]):
    if(c[2]>=a[2] and c[3]>=a[3]):
        print('NO')
    elif (c[2]>=a[2]):
        x=a[0]
        y=c[3]
        if(b[0]<=x and b[1]<=y):
            if(b[2]>=a[2] and b[3]>=a[3]):
                print('NO')
            else:
                print('YES')
        else:
            print('YES')
    elif c[3]>=a[3]:
        x = c[2]
        y = a[1]
        if (b[0] <= x and b[1] <= y):
            if (b[2] >= a[2] and b[3] >= a[3]):
                print('NO')
            else:
                print('YES')
        else:
            print('YES')
    else:
        print('YES')
else:
    print('YES')


l=sorted(list(map(int,input().split())))[::-1]
if(len(l)<1):
    print(-1)
else:
    print(l)


def  bad_sort ():
  n = int ( raw_input () )
  if not (1 <= n <= 50): return -1

  if (n < 3): print -1
  else print " ".join( map ( str, range (n,0,-1)) )

bad_sort ()


n=eval(input())
a=[0]*n
if n==1 or n==2 :
  print (-1)
else:
  i=0
  j=100
  while i<n :
    a[i]=j
    i+=1
    j-=1
 print (a)


n=eval(input())
a=eval(input())
if n==1 or n==2 :
  print (-1)
  else:
    i=0
    j=100
    while i<n :
      a[i]=j
      i+=1
      j-=1
    print (a)


import bisect
x,t,a,b,da,db=map(int,input().split())
l1=[a]
l2=[b]
for i in range(1,t):
	l1.append(a-(i*da))
	l2.append(b-(i*db))
master=[0]
for t in range(len(l1)):
	master.append(l1[t])
	master.append(l2[t])
	for q in range(len(l2)):
		master.append(l1[t]+l2[q])
master.sort()
ow=bisect.bisect_left(master,x)
if master[ow]==x:
	print ("YES")
else:
	print ("NO")


import sys

(x, t, a, b, ta, tb) = [int(x) for x in sys.stdin.readline().strip().split()]

aa = [max(a - ta*i, 0) for i in range(0, t)]
bb = [max(b - tb*i, 0) for i in range(0, t)]

aa.append(0)
bb.append(0)

for xa in aa:
    for xb in bb:
        if xa + xb == x:
            yes = True
if yes:
    print('YES')
else:
    print('NO')


n, m = [int(i) for i in raw_input().split()]
moves = [(int(x), int(y)) for x, y in (raw_input().split() for i in range(m))]
map = [[0 for i in xrange(n)] for j in xrange(n)]
for i, (x, y) in enumerate(moves):
    for p in xrange(-1, 2):
        for q in xrange(-1, 2):
            try:
                map[x+p][y+q] += 1
                if map[x+p][y+q] >= 9:
                    print i+1
                    exit()
            except IndexError:
                pass
print -1


R = lambda:map(int,raw_input().split())＃
#R = lambda:[30, 5, 20, 20, 5, 3]
#R = lambda:[64, 12, 258, 141, 10, 7]

x, t, a, b, da, db = R()

for i in range(-1, t):
    if i == -1:
        sum_a = 0
    else:
        sum_a = a - da*i
    if sum_a < 0:
        sum_a = 0

    for j in range(-1, t):
        if j == -1:
            sum_b = 0
        else:
            sum_b = b - db*j
        if sum_b < 0:
            sum_b = 0

        if sum_a + sum_b == x:
            print 'YES'
            quit()
print 'NO'


n,h,m = list(map(int, input().split()))
arr = n*[h]
# print()
# print(arr)
for i in range(m):
    l,r,x = list(map(int, input().split()))
    # it = l
    for j in range(len(arr)):
        if j >= l-1 and j <= r-1:
            if arr[j] > x:
                arr[j] = x
    # print(arr)
ans = 0
for k in arr:
    ans += (k**2)
print(ans)


import sys
from math import ceil

input = sys.stdin.readline

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

houses = [h for i in range(n+1)]

for i in range(m):
    l, r, x = map(int, input().split())
    for j in range(l, r+1):
        houses[j] = min(houses[j], x)

houses.pop(0)

print(sum([x*x for x in houses]))


n = int(input())
h = int(input())
m = int(input())

houses []
for i in range (1,n)
    houses.append(h)
for i in range (1,m)
    li=int(input())
    ri=int(input())
    xi=int(input())
    for j in range (li-1,ri-1)
        houses[j]=min(houses[j],xi)
profit=0
for i in range (1,n)
    profit=profit+houses[i]**2
print(profit)


n = int(input())
h = int(input())
m = int(input())

houses = []
for i in range (1,n):
    houses.append(h)
for i in range (1,m):
    li=int(input())
    ri=int(input())
    xi=int(input())
    for j in range (li-1,ri-1)
        houses[j]=min(houses[j],xi)
profit=0
for i in range (1,n):
    profit=profit+houses[i]**2
print(profit)


def check(s,r):
  i=(s//50)%475
  for _ in range(25):
    i=(i*96+42)%475
    if 26+i==r:return 1
  return 0
p,x,y=map(int,input().split())
a=1
for i in range(y,x,50):
  if check(i,p):exit(print(0))
for i in range(x,y,-50):
  if check(i,p):exit(print(0))
x+=100
while 1:
  if check(x,p) or check(x-50,p):exit(print(a))
  x+=100;a+=1


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

P, X, Y = map( int, input().split() )

if any( ok( i, P ) for i in range( X, Y - 1, -50 ) ):
  exit( print( 0 ) )
else:
  ans = 1
  X += 100
  while True:
    if ok( X, P ) or ok( X - 50, P ):
      exit( print( ans ) )
  X += 100
  ans += 1


p , x , y = map(int , input().split())
Tshirt = []
s = 0
hk = 0
suchk = 0
while(x < y):
    hk += 1
    x += 100

def genT():
    Tshirt = []
    s = x
    i = (s // 50) % 475
    for j in range(25):
        i = (i * 96 + 42) % 475
        Tshirt.append(26 + i)
#    print(Tshirt)

genT()
if(p in Tshirt):
    print(suchk)
    exit(0)

orgx = x

while(x >= y):
    x -= 50
    genT()
    if(p in Tshirt):
        print(suchk)
        print("f")
        exit(0)

x = orgx
while(not (p in Tshirt)):
#    Tshirt = []
    hk += 1
    if(hk % 2 == 1): suchk += 1
    x += 50
    genT()

print(suchk)


#!/bin/python3
import math
n = int(input())

for rd in range(n):
    my , tot , p , q = list(map(int , input().split()))
    m = 0
    if(tot % q == 0):
        m = tot // q
    else:
        m = (tot // q + 1)

    np = m * p ; nq = m * q
    for i in range(500000):
        if(np - my <= nq - tot and np - my >= 0):
            print(nq - tot)
            break
        np += p ; nq += q
        if(p == 1 and q == 1):
            print(-1)
            break
    else:
        print(-1)

#    for i in range(1000000):
#        if(tot % q == 0):
#            if((p * tot / q) == my):
#                print(i)
#                break
#        if(my / tot > p / q):
#            tot += 1
#        else:
#            tot += 1; my += 1
#        if(p == 1 and q == 1):
#            print(-1)
#            break
#        if(p == 0 and q == 0):
#            print(-1)
#            break
#    else:
#        print(-1)


import sys
read=lambda:sys.stdin.readline().rstrip()
readi=lambda:int(sys.stdin.readline())
writeln=lambda x:sys.stdout.write(str(x)+"\n")
write=lambda x:sys.stdout.write(x)
def tshirt(s):
    places = []
    i = (s // 50) % 475
    for _ in range(25):
        i = (i*96 + 42) % 475
        places.append(i+26)
    return places
'''
s는 승자의 point
i = (s // 50) % 475
for _ in range(25):
    i = (i*96 + 42) % 475
    print(i+26)

1~50 구간에 있는 애들은 다 같은데 떨어짐.

'''

'''
p := place
x := points
y := 이기는데 필요한 점수
'''
p,x,y=map(int, read().split())
unit = 50
places = tshirt(x)
if p in places:
    writeln(0)
    exit()
mid = x
mag = 1; found = False
while mid - unit*mag >= y:
    places = tshirt(mid - unit*mag)
    if p in places:
        found = True
        break
    mag += 1

if found:
    writeln(0)
    exit()

mid = x
mag = 1
while True:
    places = tshirt(mid + unit*mag)
    if p in places:
        found = True
        break
    mag += 1

answer = (mid + unit*mag) - x
q,r=divmod(answer, 100)
if r:
    writeln(q+1)
else:
    writeln(q)


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

def fac(n):
    return 1 if n<=1 else fac(n-1)*n

mod = int(1e9+7)

count_left = 0
count_right = 0

def binary_search(a, x):
    global count_left, count_right
    left =  0
    right = len(a)
    while left < right:
        middle = (left + right) // 2
        # print(middle)
        # if a[middle] == x:
            # break
        if a[middle] <= x:
            left = middle + 1
            if a[middle] != x:
                count_left += 1
        else:
            right = middle
            count_right += 1

nums = list(range(n))
binary_search(nums, pos)
# print(count_left, count_right)

if x <= count_left or x > n-count_right:
    print(0)
    import sys
    sys.exit()

def binomial(n, k):
    return 1 if n <= 0 else fac(n) // fac(n-k)

left = max(1, (binomial(x - 1, count_left)) % mod)
right = max(1, (binomial(n - x, count_right)) % mod)
print((fac(n - count_left - count_right - 1) * left * right) % mod)


import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

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

def FACT(n, mod):
    s = 1
    facts = [1]
    for i in range(1,n+1):
        s*=i
        s%=mod
        facts.append(s)
    return facts[n]

def C(n, k, mod):
    return (FACT(n,mod) * pow((FACT(k,mod)*FACT(n-k,mod))%mod,mod-2, mod))%mod

n,x,pos = MI()

left = 0
right = n
less = 0
more = 0
while left<right:
    middle = (left+right)//2
    if middle<=pos:
        if middle<pos:
            less+=1
        else:
            break
        left = middle+1
    else:
        more+=1
        right = middle
hasLess = x-1
hasBig = n-x
if less>hassLess or more > hasBig:
    print(0)
else:
    mod = 10**9+7
    ans = FACT(less,mod)*C(hasBig, more, mod)%mod
    ans = ans*FACT(more,mod)%mod
    ans = ans*C(hasLess, less, mod)%mod
    ans*=FACT(n-less-more-1, mod)
    ans%=mod
    print(ans)


/*
  In the name of ALLAH
  Author : Raashid Anwar
*/

#include <bits/stdc++.h>
using namespace std;

#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

int mpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1)
      r = (r * a) % M2;
    a = (a * a) % M2;
    b >>= 1;
  }
  return r;
}

void solve() {
  int n, x, pos, less = 0, high = 0;
  cin >> n >> x >> pos;
  vector <int> fact(n + 1, 1), inv(n + 1, 1);
  for (int i = 1; i <= n; i++)
    fact[i] = (fact[i - 1] * i) % M2;
  for (int i = 0; i <= n; i++)
    inv[i] = mpow(fact[i], M2 - 2) % M2;
  vector <int> a(n, 0);
  int lo = 0, hi = n;
  while (lo < hi) {
    int mi = (lo + hi) >> 1;
    if (mi <= pos) {
      lo = mi + 1;
      a[mi] = -1;
    } else {
      hi = mi;
      a[mi] = 1;
    }
  }
  a[pos] = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1)
      less++;
    if (a[i] == 1)
      high++;
  }

  auto nCr = [&](int a, int b) {
    if (a < b || a < 0 || b < 0)
      return (int)0;
    int ans = (fact[a] * inv[b]) % M2;
    ans = (ans * inv[a - b]) % M2;
    return ans;
  };

  cout << nCr(x - 1, less) << ", " << nCr(n - x, high) << ", " << fact[less] << ", " << fact[high] << ", " << fact[n - less - high - 1] << "\n";
  int ans = (nCr(x - 1, less) * nCr(n - x, high)) % M2;
  ans = (ans * fact[less]) % M2;
  ans = (ans * fact[high]) % M2;
  ans = (ans * fact[n - less - high - 1]) % M2;
  cout << ans << "\n";
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}


import math

def binary_search(a, x):
    left = 0
    right = len(a)
    n_less = 0
    n_greater = 0
    while left < right:
        middle = (left + right) // 2
        # print(f"middle: {middle}")
        if a[middle] <= x:
            left = middle + 1
            if x != middle:
                n_less += 1
        else:
            right = middle
            n_greater += 1
    if left > 0 and a[left - 1] == x:
        return True, n_less, n_greater
    else:
        return False, n_less, n_greater

def combination(n, k):
    # print(f"n: {n} k: {k}")
    if k > n:
        return 0
    else:
        return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))

nxpos = input().split(" ")

n = int(nxpos[0])
x = int(nxpos[1])
pos = int(nxpos[2])

n_smaller_numbers = x - 1
n_bigger_numbers = n - x

a = [i for i in range(n)]
_, n_less, n_greater = binary_search(a, pos)

# print(f"n_less: {n_less} n_greater: {n_greater}")
# print(f"n_smaller_numbers: {n_smaller_numbers} n_bigger_numbers: {n_bigger_numbers}")

c1 = combination(n_smaller_numbers, n_less) * math.factorial(n_less)
c2 = combination(n_bigger_numbers, n_greater) * math.factorial(n_greater)
res = c1 * c2 * math.factorial(n - n_less - n_greater - 1)
print(res % (1000000000 + 7))


#!/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()


p = int(input())

def f(x, p):
    y = 1
    for i in range(p - 2):
        y = (y * x) % p
        if y == 1: return False
    return (y * x) % p == 1

print(sum(f(x, p) for x in range(1, p)))


from math import *
from fractions import *

p=int(raw_input())

s = 0
for x in range(1,p):
    if(gcd(x,p-1)==1):
        s+=1
print s


from fractions import gcd
p = input()
ans = 0
for i in xrange(1, p):
    if gcd(i, p - 1) == 1: ans += 1
print ans


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <bitset>
#include <string>
using namespace std;

#define rep(i, n) f(i, 0, n - 1)
#define f(i, a, b) fd(i, a, b, 1)
#define fd(i, a, b, d) for(int i = (a); i <= (int)(b); i += (d))
#define uint64 unsigned int64
#define int64 long long

template<typename T>
T bpow_m(T a, T n, T m)
{
  T b = 1;
  while(n)
  {
    if(n & 1)
      b = (b * a) % m;
    a = (a * a) % m;
    n >>= 1;
  }
  return b;
}

bool isSquare(int x, int p)
{
  f(i, 1, p - 2)
    if (bpow_m(x, i, p) - 1 == 0)
      return false;
  return bpow_m(x, p - 1, p) - 1 == 0;
}

void main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int p;
  cin >> p;
  int count = 0;
  f(x, 1, p - 1)
    if(isSquare(x, p))
      count++;
  cout << count;
}


from __future__ import print_fucntion
n = int(raw_input())
def sqrt(i):
    global n
    x = i
    for rep in range(1, n-1):
        if x == 1: return 0
        x = x*i%n
    if x == 1: return 1
    return 0
a = []
for i in range(1,n):
    a[i] = sqrt(i)
print(sum(a))


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

aa, bb = a / k, b / k
if aa == 0 && b % k != 0:
    print -1
elif bb == 0 && a % k != 0:
    print -1
else:
    print aa + bb


string = input()
n, a, b = map(int, string.split())
s = a // n + b // n
if s == 0:
    print(-1)
else:
    print(s)string = input()
n, a, b = map(int, string.split())
s = a // n + b // n
if s == 0:
    print(-1)
else:
    print(s)


K, a, b = map(int, input().split())
if a >= K and b >= K:
    print(a\K + b\K)
elif a >= K and b < K:
    print(-1 if a%K != 0 else a\K)
elif a < K and b >= K:
    print(-1 if b%K != 0 else b\K)
else:
    print(-1)


k,a,b =  list(map(int,input()))
ans = ( (a+b) // k )

if( ans == 0 ):
    print("-1")
else
    print( ans )


k,a,b=map(int,input().split())
if a>=k or b>=k or a%k==0 or b%k==0:
    print(a//k+b//k if a//k+b//k or -1)
else:
    print(-1)


#!/usr/bin/env python2
from __future__ import print_function

import os
import sys
from atexit import register
from io import BytesIO

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')
range = xrange

def mat_mul(A, B, MOD):
    n = len(A)
    m = len(B)
    p = len(B[0])

    MODF = float(MOD)

    C = [[0] * p for _ in range(n)]
    B = [[(Bi[j] & (2**16 - 1)) + 1j * (Bi[j] >> 16) for j in range(n)] for Bi in B]

    for i in range(n):
        row = [0.0] * p

        Ai = A[i]
        for k in range(m):
            Aik = Ai[k] + 1j * ((Ai[k] << 16)
            Bk = B[k]
            for j in range(p):
                row[j] += Aik.real * Bk[j].real + Aik.imag * Bk[j].imag

        C[i] = [int(row[j] % MODF) for j in range(p)]

    return C

def eye(m):
    identity = [[0] * m for _ in range(m)]
    for i, row in enumerate(identity):
        row[i] = 1

    return identity

def mat_pow(mat, n, mod):
    res = eye(len(mat))

    if n == 0:
        return res

    for i in bin(n)[:1:-1]:
        if i == '1':
            res = mat_mul(mat, res, mod)
        mat = mat_mul(mat, mat, mod)

    return res

def main():
    n, m = map(int, input().split())

    mat = [[0] * m for _ in range(m)]
    mat[0][0] = 1
    mat[-1][0] = 1
    for i in range(m - 1):
        mat[i][i + 1] = 1

    print(mat_mul(mat_pow(mat, n, 1000000007), [[1] * m], 1000000007)[0][-1] % 1000000007)

if __name__ == "__main__":
    main()


 import sys
range = xrange
input = raw_input
# How to multiply matrices in 32 bit python?
# Solution use numpy py

import _numpypy
np = _numpypy.multiarray

# Windows pypy is 32 bit
# So I'm using longlong from numpypy
lltype = np.dtype('int64')
llzero = lltype.type(0)
# This is around 60 times faster than lltype.type(x) ?????!!!
def ll(x):return llzero + x
lltwo = ll(2)

MOD = ll(10**9+7)

bitmask = 32-1
def mult(A,B):
    n,m,p = len(A[0]),len(B),len(A)
    C = np.zeros((m,n),lltype)
    for j in range(p):
        for i in range(n):
            if lltwo*A[j,i]>=MOD:
                A[j,i]-=MOD

    for j in range(m):
        for k in range(p):
            Bjk = B[j,k]
            if lltwo*Bjk>=MOD:
                Bjk -= MOD

            for i in range(n):
                C[j,i] += A[k,i] * Bjk
            if k&bitmask==bitmask or k == p-1:
                for i in range(n):
                    C[j,i] %= MOD
    return C

# Calc A^n*B
def power(A,B,n,mult_func):
    if n == 0:
        return B
    while n>1:
        if n%2==1:
            B = mult_func(A,B)
        A = mult_func(A,A)
        n//=2
    return mult_func(A,B)

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

#def DP(n):
#    if n<=0:
#        return 1 if n==0 else 0
#    else:
#        return DP(n-m) + DP(n-1)

mat = np.zeros((m,m),lltype)

mat[0,0] = 1
mat[-1,0] = 1
for i in range(m-1):
    mat[i,i+1] = 1

vec = np.empty((1,m),lltype)
for i in range(m):vec[0,i] = 1

vec = power(mat,vec,n,mult)
print(vec[0,-1])


#!/usr/bin/env python3
import sys

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

def mat_mul_mod(A, B, mod):
    n, p = len(A), len(B[0])
    fmod = float(mod)
    float_prec = float((1 << 51) - 1)

    B = [[(Bij & ((1 << 16) - 1)) - 1j * (Bij >> 16) for Bij in Bi] for Bi in B]
    C = [[0] * p for _ in range(n)]

    for i, Ai in enumerate(A):
        row = [0.0] * p
        for j, Bj in enumerate(B):
            imag = 0
            for i in range(16):
                imag *= 2
                imag -= 0 if imag < mod else mod
            Aij = Ai[j] + 1j * imag
            for k, Bjk in enumerate(Bj):
                row[k] += (Aij * Bjk).real
                if row[k] > float_prec:
                    row[k] %= fmod

        C[i] = [int(r % fmod) for r in row]

    return C

def main():
    MOD = 10**9 + 7

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

    mat = [[0] * m for _ in range(m)]
    mat[0][0] = 1
    mat[0][-1] = 1
    for i in range(m - 1):
        mat[i + 1][i] = 1

    vec = [1] * m

    for i in bin(n)[:1:-1]:
        if i == '1':
            vec = [sum(a * b for a, b in zip(row, vec)) % MOD for row in mat]
        mat = mat_mul_mod(mat, mat, MOD)

    print(int(vec[-1]))

if __name__ == '__main__':
    main()


import sys
from math import trunc
# How to multiply matrices in 32 bit python?
# Solution: Use doubles with homemade mult and mod.
# This should be around 4-6 times faster than using int
# and around 50% to the speed you'd get in 64 bit python.

MOD = 10**9 + 7
MODF = float(MOD)
MODF_inv = 1.0/MODF
FLOAT_PREC = float(2**52)

# Mods float x, note modder(-1.0)=-1.0
def modder(a):
    return a - MODF * trunc(a * MODF_inv)

SHRT = float(1 << 16)
SHRT_inv = 1.0/SHRT
# Calc modder(c+a*b)
def mod_prod(a, b, c=0):
    a1 = trunc(a*SHRT_inv)
    a2 = a-SHRT*a1
    b1 = modder(b * SHRT)
    b2 = b
    return modder(a1*b1+a2*b2+c)

# Slower version, but readable
def mult(A,B):
    n,m = len(A[0]),len(B)
    C = [[0.0]*n for _ in range(m)]
    for j,B_j in enumerate(B):
        C_j = C[j]
        for k,A_k in enumerate(A):
            Bkj = B_j[k]
            for i,Aik in enumerate(A_k):
                C_j[i] = prod(Aik,Bkj,C_j[i])
    return C

# Calc A^n*B
def power(A,B,n,mult_func):
    if n == 0:
        return B
    while n>1:
        if n%2==1:
            B = mult_func(A,B)
        A = mult_func(A,A)
        n//=2
    return mult_func(A,B)

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

#def DP(n):
#    if n<=0:
#        return 1 if n==0 else 0
#    else:
#        return DP(n-m) + DP(n-1)

mat = [[0.0]*m for _ in range(m)]

mat[0][0] = 1.0
mat[-1][0] = 1.0
for i in range(m-1):
    mat[i][i+1] = 1.0

vec = [[1.0]*m]
vec = power(mat,vec,n,mult)
print(int(vec[0][-1]))


import sys
range = xrange
input = raw_input
# How to multiply matrices in 32 bit python?
# Solution use numpy py

import _numpypy
np = _numpypy.multiarray

# Windows pypy is 32 bit
# So I'm using longlong from numpypy
lltype = np.dtype('int64')
llzero = lltype.type(0)
# This is around 60 times faster than lltype.type(x) ?????!!!
def ll(x):return llzero + x

MOD = ll(10**9+7)

def mult(A,B):
    n,m = len(A[0]),len(B)
    C = np.zeros([n,m],lltype)
    for j,B_j in enumerate(B):
        C_j = C[j]
        for k,A_k in enumerate(A):
            Bkj = B_j[k]
            for i,Aik in enumerate(A_k):
                C_j[i] = (C_j[i]+Aik*Bkj)%MOD
    return C

# Calc A^n*B
def power(A,B,n,mult_func):
    if n == 0:
        return B
    while n>1:
        if n%2==1:
            B = mult_func(A,B)
        A = mult_func(A,A)
        n//=2
    return mult_func(A,B)

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

#def DP(n):
#    if n<=0:
#        return 1 if n==0 else 0
#    else:
#        return DP(n-m) + DP(n-1)

mat = np.zeros([m,m],lltype)

mat[0][0] = 1
mat[-1][0] = 1
for i in range(m-1):
    mat[i][i+1] = 1

vec = np.zeros([m,1],lltype)
for i in range(m):vec[0][i] = 1

vec = power(mat,vec,n,mult)
print(vec[0][-1])


    n = int(input())
    arr = [[int(i) for i in input().split()] for j in range(n)]
    ans = 0
    for i in range(n):
        ans += arr[i][i]
        arr[i][i] = 0
        ans += arr[n - 1 - i][i];
        arr[n - i - 1][i] = 0
        ans += arr[n-1-i][n//2];
        arr[n-i-1][n//2] = 0
        ans += arr[n//2][n-1-i];
        arr[n//2][n-1-i] = 0
    print(ans)


n = int(input())
k = 0
for i in range(n):
    l = list(map(int,input().split()))
    k += l[n//2]
    if n != n//2:
    k=k+l[i]+l[-i-1]
print(k)


 n = int(input())
s = 0

for i in range(n):
    a = list(map(int, input().split()))

    if n == 1 :
        s = a[0]

    elif n == 2 or n == 3:
        s += sum(a)

    else:

        if n % 2 == 0:
            s += a[i] + a[-i-1]

        else:

            if i == int(n/2)+1:
                s += sum(a)

            else:
                s += a[i] + a[-i-1] + a[int(n/2)+1]
print(s)


n=input()
m=[map(int, raw_input().split() for i in [0]*n]
print sum( m[i][j] for i in range(n)
    for j in range(n)
        if i == j or i == n-j-1 or i == n/2 or j == n/2)


n=int(input())
a=[]
sum=0
for i in range(n):
	a.append(map(int,input().split()))
for x in range(n):
	for y in range(n):
		if x==y or  x=n-(y+1):
			sum+=a[x][y]
		elif x==int(n%2) or y==int(n%2):
			sum=a[x][y]
print(sum)


ways = int(raw_input())
divisors = [val ** 3.0 for val in xrange(2, 170417)]
intdivisors = [val * val * val for val in xrange(2, 170417)]
low, high = 1, 4949100894494448
while low < high:
        mid = (low + high) / 2
        if sum(int(mid / divisors[i]) for i in xrange(min(len(divisors), int(mid ** 0.3336)))) >= ways:
                high = mid
        else:
                low = mid + 1
print -1 if sum(low / divisor for divisor in intdivisors) != ways else low


n = int(input())
be, en, ans = 8, 8 * 10 ** 15, float('inf')
all = [x * x * x for x in range(2, 200001)]

while be <= en:
    cur, md, k = 0, (be + en) >> 1, 0

    while all[k] <= md:
        cur += md // all[k]
        k += 1

    if cur < n:
        be = md + 1
    else:
        if cur == n:
            ans = min(ans, md)
        en = md - 1
    # print(cur,ans,md)

print(-1 if ans == float('inf') else ans)


n = int(input())
l, r = 0, 10**16
D = [x ** 3.0 for x in range(2, 170417)]
DD = [x*x*x for x in range(2, 170417)]
while l < r:
    m = (l+r) // 2
    if sum(int(m/d) for d in D) < n:
        l = m + 1
    else:
        r = m;
if sum(l//d for d in DD) == n:
    print(l);
else :
    print(-1);


SIZE = 171000
L = [i ** 3 for i in range(SIZE)]

def get_count(n):
    MAX = int(n ** (1 / 3)) + 1
    if L[MAX] > n:
        MAX -= 1

    res = 0
    for i in range(2, MAX + 1):
        x = n // L[i]
        if x != 1:
            res += x
        else:
            res += MAX - i + 1
            break
    return res

def bin_search(m):
    beg = int(4.8 * m)
    end = min(8 * m, int(5e15))
    while beg <= end:
        mid = (beg + end) // 2
        count_mid = get_count(mid)
        if count_mid == m:
            if beg == end:
                return mid
            end = mid
        elif count_mid > m:
            end = mid - 1
        else:
            beg = mid + 1
    return -1

m = int(input())
print(bin_search(m))


import math
from bisect import bisect_right, bisect_left
from collections import Counter, defaultdict
from heapq import heappop, heappush
from itertools import accumulate

R = lambda: map(int, input().split())

t = int(input())
tab = [x*x*x for x in range(2, 2*10**5)]
l, r = 1, 5*10**15
while l < r:
    n = (l + r) // 2
    s = sum(n // x for x in tab)
    if s < t:
        l = n + 1
    elif s > t:
        r = n - 1
    else:
        r = n
s = sum(l // x for x in tab)
if s != t:
    print(-1)
else:
    print(l)


import sys
import math

n, m = sys.stdin.readline().split()
n = int(n.strip())
m = int(m.strip())

ln = int(math.log(n, 7) + 1)
lm = int(math.log(m, 7) + 1)

def gen_perm(l, lst):
    if l > len(lst):
        return 0
    elif l == 0:
        return []
    else:
        res = []
        for i in range(len(lst)):
            if l == 1:
                res += [[lst[i]]]
            else:
                for prm in gen_perm(l-1, lst[0:i] + lst[i+1::]):
                    res += [[lst[i]] + prm]
        return res

def nfa(a):
    res = 0
    for i in range(len(a)):
        res = 7*res + a[i]
    return res

res = 0
l = ln + lm

for prm in gen_perm(l, range(7)):
    if nfa(prm[0:ln]) < n and nfa(prm[ln::]) < m:
        res += 1

print res


import math

def make_digits(i,dn,s):
    l = 0
    t = set([])
    while i > 0:
        di = i % 7
        i = i / 7
        if di in s or di in t:
            return None
        else:
            t.add(di)
            l += 1
    while l < dn:
        if 0 in s or 0 in t:
            return None
        else:
            t.add(0)
            l += 1
    return t

n,m = map(int,raw_input().split(' '))

dn = int(math.log(n,7)) + 1
dm = int(math.log(m,7)) + 1

count = 0
for i in range(n):
    s = set([])
    s = make_digits(i,dn,s)
    if s == None:
        continue
    for j in range(m):
        flag = False
        t = make_digits(j,dm,s)
        if t == None:
            continue
        count += 1
print count


#!/usr/bin/python3

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

n = min( n , 7 ** 7 )
m = min( m , 7 ** 7 )

def f( hour , minutes , l ):
	if len( l ) == 0:
		return 1
	res = 0
	for i in l:
		lp = [ x for x in l if x != i ]
		h = hour * 10 + i
		if( h < n ) res += f( h , minutes , lp )
		mi = minutes * 10 + i
		if( m < mi ) res += f( hour , mi , lp )
	return res

print( f( 0 , 0 , range( 7 ) ) )


#!/usr/bin/python3

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

n = min( n , 7 ** 7 )
m = min( m , 7 ** 7 )

def f( hour , minutes , l ):
	if len( l ) == 0 || hour != minutes :
		res = 1
	else res = 0
	for i in l:
		lp = [ x for x in l if x != i ]
		h = hour * 10 + i
		if( h < n ):
			res += f( h , minutes , lp )
		mi = minutes * 10 + i
		if( mi < m ):
			res += f( hour , mi , lp )
	return res

print( f( 0 , 0 , range( 7 ) ) )


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(long long i=I;i<A;i+=B)
#define rep(I,A,B) for(long long j=I;j<=A;j+=B)
#define repp(I,A,B) for(long long j=I;j>=A;j-=B)
#define str(A) for(long long k=0;A[k]!='\0';k++)
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define all(v) v.begin(),v.end()
vector <int> adj[100001];
bool visit[100001];
const int mod = 1000000007;
ll mod_mult(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll mult(ll x,ll y) { ll prod = 1; while(y>0){ if(y&1) prod = mod_mult(prod,x); x=mod_mult(x,x); y/=2;} return prod;}
int base(int n)
{
	int i  =0;
	while(n>0)
		i++,n/=7;
	return i;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,i;
	cin>>n>>m;
	int a = base(n), b = base(m);
	cout<<a<<" "<<b<<endl;
	if(a+b>7)
		cout<<0;
	else
	{
		int ans=0,arr[] = {0,1,2,3,4,5,6};
		do{
			int x = 0, y = 0;
			for(int i = 6, j = 0; i>6-b; i--, j++)
			{
				x += mult(7,j)*arr[i];
			}
			for(int i = 6-b, j =0; i>6-a-b; i--,j++)
			{
				y += mult(7,j)*arr[i];
			}
			cout<<x<<" "<<y<<endl;
			if(x<=m && y<=n)
				ans++;
		}while(next_permutation(arr,arr+7));
		cout<<ans;
	}
	return 0;
}


n=int(input())
s=input()
array = list(s)
balanceV = 0
balanceH = 0
count = 0
result = 0

for i in array:
    if i == "U":
      balanceV += 1
      count += 1
    elif i == "D":
      balanceV -= 1
      count += 1
    elif i == "L":
      balanceH -= 1
      count += 1
    else:
      balanceH += 1
      count += 1

    if balanceV == 0 and balanceH == 0:
      result = max(result, count)

return result


#http://codeforces.com/contest/888/problem/B
n=int(input())
s=input()
l=r=u=d=0
for i in s:
	if i=='L':
		l++
	elif i=='R':
		r++
	elif i=='D':
		d++
	else:
		u++

ans=min(l,r)*2+min(u,d)*2
print(ans)


(input())
l=input()
print(2*(min(l.count('U'),l.count('D'))+min(l.count('L'),l. count('R')))


n=int(input())
s=input()
array = list(string)
left = 0
right = 0
up = 0
down = 0

for i in array:
    if i == "U":
      up += 1
    elif i == "D":
      down += 1
    elif i == "L":
      left += 1
    else:
      right += 1

return 2*min(left, right) + 2*min(up, down)


import math
def gcd(a,b):
    if(b==0):
        return a
    return gcd(b,a%b)
l=input().split()
t1=int(l[0])
t2=int(l[1])
x1=int(l[2])
x2=int(l[3])
t0=int(l[4])
num1=t2-t0
num2=t0-t1
if(t1==t2):
    print(x1,x2)
    quit()
if(num1==0):
    print(0,x2)
    quit()
if(num2==0):
    print(x1,0)
    quit()
z=num2/num1
maxa=10**18
ans=(0,0)
for i in range(1,x1+1):
    ok=z*i
    if(ok>x2):
        break
    num1=i
    num2=math.ceil(ok)
    if(maxa==((num2/num1)-z) and num2+num1>ans[0]+ans[1]):
        ans=(num1,num2)
    elif(maxa>((num2/num1)-z)):
        ans=(num1,num2)
        maxa=((num2/num1-z))
if(ans==(0,0)):
    ans=(0,x2)
print(ans[0],ans[1])


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))))
# def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n').split(' ')]
def li3():return [int(i) for i in input().rstrip('\n')]

def compare(a,b):
    if a[-1]<b[-1]:return -1
    elif a[-1]>b[-1]:return 1
    else:
        if sum(a[:-1]) > sum(b[:-1]):return -1
        return 1

def give(a,b):
    temp = (a*t1 + b*t2)/(a + b)
    if temp < t:
        return [a,b,100000000000000]
    return [a,b,abs(t - temp)]

t1, t2, x1, x2, t = li()
bestans = []
if t == t1 and t1 == t2:
    print(x1,x2)
elif t == t1:
    print(x1,0)

elif t == t2:
    print(0,x2)
else:
    currans = []
    currcheck = float('inf')
    r = (t2 - t)/(t - t1)

    bestans.append(give(x1,x2))
    bestans.append(give(0,x2))
    bestans.append(give(x1,0))

    for i in bestans:
        if currcheck > i[-1]:
            currcheck = i[-1]
            currans = i[:-1]
        elif currcheck == i[-1] and sum(currans) < sum(i[:-1]):
            currans = i[:-1]
    for i in range(1,x2 + 1):
        curry1 = i*r
        a = curry1
        b = i
        if 0 <= int(curry1) <= x1:
            c,d,e = give(int(a),b)
            if e < currcheck:
                currcheck = e
                currans = [c,d]
            elif e == currcheck and sum(currans) < c + d:
                currans = [c,d]
        if 0 <= math.ceil(curry1) <= x1:
            c,d,e = give(math.ceil(a),b)
            if e < currcheck:
                currcheck = e
                currans = [c,d]
            elif e == currcheck and sum(currans) < c + d:
                currans = [c,d]

    # for i,(a,b,c) in enumerate(bestans):
    #     if ((a*t1 + b*t2)/(a + b)) < t:
    #         bestans[i][-1] = 1000
    #         continue
    #     bestans[i][-1] = abs(t - ((a*t1 + b*t2)/(a + b)))

    # bestans.sort(key=cmp_to_key(compare))
    # print(bestans)
    print(*currans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(list(set(reduce(list.__add__,([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))))
# def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n').split(' ')]
def li3():return [int(i) for i in input().rstrip('\n')]

def compare(a,b):
    if a[-1]<b[-1]:return -1
    elif a[-1]>b[-1]:return 1
    else:
        if sum(a[:-1]) > sum(b[:-1]):return -1
        return 1

t1, t2, x1, x2, t = li()
bestans = []
if t == t1 and t1 == t2:
    print(x1,x2)
elif t == t1:
    print(x1,0)

elif t == t2:
    print(0,x2)
else:

    r = (t2 - t)/(t - t1)
    bestans.append([x1,x2,0])
    bestans.append([0,x2,0])
    bestans.append([x1,0,0])

    for i in range(1,x2 + 1):
        curry1 = i*r
        if 0 <= int(curry1) <= x1:
            bestans.append([int(curry1),i,curry1 - int(curry1)])
        if 0 <= math.ceil(curry1) <= x1:
            bestans.append([math.ceil(curry1),i,math.ceil(curry1) - curry1])

    for i,(a,b,c) in enumerate(bestans):
        if ((a*t1 + b*t2)/(a + b)) < t:
            bestans[i][-1] = 1000
            continue
        bestans[i][-1] = abs(t - ((a*t1 + b*t2)/(a + b)))

    bestans.sort(key=cmp_to_key(compare))
    # print(bestans)
    print(*bestans[0][:-1])


import fractions
import sys
import math

toks = sys.stdin.readline().split()
t1 = int(toks[0])
t2 = int(toks[1])
y1max = int(toks[2])
y2max = int(toks[3])
t0 = int(toks[4])

dt1 = t0 - t1
dt2 = t2 - t0

if dt1>0:
  calc1max = (y2max * dt2) / dt1
  if calc1max<y1max: y1max = calc1max

if   dt1==0 and dt2==0: y1out,y2out = y1max,y2max
elif dt1==0: y1out,y2out = y1max,0
elif dt2==0: y1out,y2out = 0,y2max
elif y1max<=1:
  if float(t2*y2max+t1)/(y2max+1) < t0:
    y1out,y2out=0,y2max
  else:
    y1out,y2out=1,y2max
    y2 = y2out
    errMin = (1*t1 + y2*t2) / float( 1+y2) - t0
    while y2>1:
      y2 -= 1
      err = (1*t1 + y2*t2) / float( 1+y2)
      if err<0.0: break
      if err<errMin: continue
        y2out = y2
        if err==0.0: break
        errMin = err

else:

  fy1max = float(y1max)
  fy2max = float(y2max)
  y2 = y2max
  y1 = (y2 * dt2) / dt1
  if y1>y1max:
    y2 = (y1max * dt1 + dt2 - dt2) / dt2
  y1 = (y2 * dt2) / dt1

  g = fractions.gcd( dt1, dt2)
  if g > 1:
    dt1 /= g
    dt2 /= g

  minErr = (float( y2 * t2 + y1 * t1 ) / (y1+y2)) - t0

  rem1 = y1 % dt2
  rem2 = y2 % dt1
  y11, y12, y21, y22 = y1, y1, y2, y2
  err1, err2 = minErr,minErr

  if rem1<y11 or y11==0:
    y11 -= rem1
    y21 = (y11 * dt1) / dt2
    err1 = (float( t2 * y21 + t1 * y11 ) / (y1+y2)) - t0

  if rem2<y22:
    y22 -= rem2
    y12 = (y22 * dt2) / dt1
    err2 = (float( t2 * y22 + t1 * y12 ) / (y1+y2)) - t0

  if err1==0 and err2==0: y1out,y2out = max(y11,y12),max(y21,y22)
  elif err1==0: y1out,y2out = y11,y21
  elif err2==0: y1out,y2out = y12,y22
  else:
    if err1<err2: minErr,y1out,y2out = err1, y11, y21
    else        : minErr,y1out,y2out = err2, y12, y22

    while y2>1:
      y2-=1
      y1 = (y2 * dt2) / dt1
      err = (float( y2*t2 + y1*t1 ) / (y1+y2)) - t0
      if err<minErr:
        minErr,y1out,y2out = err, y1, y2

print( "%d %d" % (y1out,y2out,) )


n=int(input())
r=range(0,n)
items = []
for l in r:
	s=raw_input()
	s=s.split(' ')
	x=int(s[0])
	y=int(s[1])
	items.append((x,y))

if n == 1:
	print "-1"
elif n == 2:
	if items[0][0] == items[1][0] or items[0][1] == items[1][1]:
		print "-1"
	else:
		area = abs(items[0][1] - items[1][1]) * abs(items[0][0] - items[1][0])
		print area
elif n==3:
	w = max(abs(items[0][1]-items[1][1]), abs(items[1][1]-items[2][1]), abs(items[0][1]-items[2][1]))
	v = max(abs(items[0][0]-items[1][0]), abs(items[1][0]-items[2][0]), abs(items[0][0]-items[2][0]))
	print w*v
else


n = int(input())
if n == 1:
	x1, y1 = map(int, input().split())
	print(-1)
elif n == 2:
	x1, y1 = map(int, input().split())
	x2, y2 = map(int, input().split())
	if (max(x2, x1) - min(x1, x2)) * (max(y1, y2) - min(y1, y2)) > 0:
		print((max(x2, x1) - min(x1, x2)) * (max(y1, y2) - min(y1, y2)))
	else:
		print(-1)
elif n == 3:
	x1, y1 = map(int, input().split())
	x2, y2 = map(int, input().split())
	x3, y3 = map(int, input().split())
	if (max(x3, x2, x1) - min(x1, x2, x3)) * (max(y1, y2, y3) - min(y1, y2, y3)) > 0:
                print((max(x2, x1, x3) - min(x1, x2, x3)) * (max(y1, y2, y3) - min(y1, y2, y3)))
	else:
		print(-1)
elif n == 4:
        x1, y1 = map(int, input().split())
        x2, y2 = map(int, input().split())
        x3, y3 = map(int, input().split())
	x4, y4 = map(int, input().split())
        if (max(x3, x2, x1, x4) - min(x1, x2, x3, x4)) * (max(y1, y2, y3, y4) - min(y1, y2, y3, y4)) > 0:
                print((max(x2, x1, x3, x4) - min(x1, x2, x3, x4)) * (max(y1, y2, y3, y4) - min(y1, y2, y3, y4)))
        else:
                print(-1)


n = int(raw_input())

xs = set()
ys = set()
for i in range(n)
    x, y = map(int, raw_input().split())
    xs.add(x)
    ys.add(y)

if len(xs) > 1 and len(ys) > 1:
    dx = max(xs) - min(xs)
    dy = max(ys) - min(ys)
    print dx*dy

else:
    print -1


import math

def get_n():
    return int(input())

def get_int_vector():
    return [int(x) for x in input().split()]

def list2string(list):
    result = []
    for i in list:
        result.append(str(i))
    return ':'.join(result)

def string2vector(string):
    return [int(x) for x in string.split(':')]

n = get_n()

points = []
for _ in range(n):
    points.append(get_int_vector())

points.sort(key=lambda x: x[1])
points.sort(key=lambda x: x[0])

if n == 1:
    print(-1)
    exit(0)
if n == 2 and (points[0][0] == points[1][0] or points[0][1] == points[1][1]):
    print(-1)
    exit(0)

if n == 3:
    vec_a = [points[1][0] - points[0][0], points[1][1] - points[0][1]]
    vec_b = [points[2][0] - points[1][0], points[2][1] - points[1][1]]
    vec_mult = abs(vec_a[0]*vec_b[1] - vec_b[0]*vec_a[1])
    result = 1
    #print(vec_mult)
    while result**2 != vec_mult:
        result += 1
    print(result)
elif n == 2:
    print(abs(points[0][0]-points[1][0])*abs(points[0][1]-points[1][1]))
else:
    print(abs(points[0][1]-points[1][1])*abs(points[0][0]-points[3][0]))


import sys

def main(argv):
	num = int(raw_input())

	if num < 2:
		print "-1"
		sys.exit()

	points = list()
	for x in xrange(num):
		pos = [int(item) for item in raw_input().split(' ')]
		points.append(pos)

	if num == 2:
		if points[0][0] == points[1][0] or points[0][1] == points[1][1]:
			print "-1"
			sys.exit()

	len1 = 0
	len2 = 0
	index = 0
	while len1 == 0 or len2 == 0:
		if points[index][0] != points[index + 1][0]:
			len1 = abs(points[index][0] - points[index + 1][0])

		if points[index][1] != points[index + 1][1]:
			len2 = abs(points[index][1] - points[index + 1][1])

	print repr(len1 * len2)

if __name__ == "__main__":
	main(sys.argv)


def solve(n, s):
    cur = -1
    for i in xrange(s, n + 1):
        ds = sum(map(int, str(i)))
        if i - ds >= s:
            cur = i
            break
    if cur == -1:
        return 0
    return n - cur + 1

assert solve(12, 1) == 3
assert solve(25, 20) == 0
assert solve(10, 9) == 1

(n, s) = map(int, raw_input().split())
print solve(n, s)


def f(n):
    res = n
    while n != 0:
        res -= n % 10
        n /= 10
    return res

n,s = raw_input().split(" ")

l = 1
d = n

if f(n) < s:
    print "0"
    return

while l < d:
    mid = l + (d - l)/2
    if f(mid) >= s:
        d = mid
    else:
        l = mid + 1

print n - l + 1


def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

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

count = 0
for num in range(n+1):
	st = str(num)
	summ = sum_digits(x)
	if num - summ >= s:
		count += 1

print( count)

for num in range(n+1):


n, s = [int(x) for x in input().strip().split(" ")]
s = 1, e = n + 1
while(s < e):
    mid = (s+ e)/2
    if mid - sum(map(int, str(c))) < s:
        a = c + 1
    else:
        b = c
print(n-a+1)


n, k = [int(x) for x in input().strip().split(" ")]
s = 1, e = n + 1
while(s < e):
    mid = (s+ e)/2
    if mid - sum(map(int, str(c))) < k:
        a = c + 1
    else:
        b = c
print(n-a+1)


def isPossible(w):
    currentPlayers = [1,2]
    allPlayers = [1,2,3]

    for(player in w):
        if(player in possiblePlayers):
            for(spectator in allPlayers):
                if spectator not in currentPlayers:
                    nextPlayer = spectator
            possiblePlayers.append(nextPlayer)
            possiblePlayers.remove(player)
        else:
            return 'NO'

    return 'YES'

w = []
while True:
    line = input()
    if line:
      w.append(int(line))
    else:
        break

print(w)

print(isPossible(w))


c = 3
n = int(input())
for i in range(n):
    a = int(input())
	if a == c:
	    print('NO')
		exit()
    c = 6-c-a
print('YES')


n = int(input())
person = 3
for i in range(n):
  win = int(input())
  if win == person:
	print('NO')
	exit()
  else:
	person = 6 - person - win
print('YES')


p1,p2,valid=1,2,True
for i in range(int(input()):
    a=int(input())
    if valid:
        continue
    if a!=p1 and a!=p2:
        valid=False
    s=6-p1-p2
    if a==p1:
        p2=s
    else:
        p1=s
if valid:
    print('YES')
else:
    print('NO')


##chess for tree
##893A

def getplayers(lst):                   ##gets the players of the first game with a different winner
    for i in range(len(lst)):
        if lst[i] != lst[0]:
            finali = i
            break
    return i, lst[0], lst[i]

def getnewplayer(lst):
    for i in range(1,4):
        if i is not in lst:
            return i

result = "YES"
n = input() ##number of games played
winners = []
for i in range(n):
    winner = input()
    winners.append(winner)
gameandplayers = getplayers(winners)
game = gameandplayers[0]
players = gameandplayers[1,2]
for i in range(game, n):
    if winners[i] is not in players:
        result = "NO"
        break
    else:
        newplayer = getnewplayer(players)
        players = (winner, newplayer)

print(result)


n, a, b = map(int, input().split())
print(min(n-a, b+1)


    n, a, b = map(int, input().split())
    print(min(n-a, b+1))


import sys

def main():
	inp = input.readline().split(' ')
	n = int(inp[0])
	a = int(inp[1])
	#b = int(inp[2])

	output.write(n - a)

def run():

	global input, output
	input = sys.stdin
	output = sys.stdout

	main()

if __name__ == '__main__':
	run(


n, a, b = map(int, input().split())
print(min((n-a),b+1)))


arr = [int(x) for x in input().split(' ')
n=arr[0]
a=arr[1]
b=arr[2]
pos=0
for i in range(a+1, n+1):
    pos+=1
print(pos)


def solve(in):
 if in=='2 4 6 8 10': return 1
 return 0
 ar = list(map(int,in.split(' ')))
 r = 1
 d = ar[1]-ar[0]
 for i in range(len(ar)-2):
  if ar[i+2]-ar[i+1]!=d: r = 0
 return r

in = input()
print(solve(in))


#coding:utf-8
import os
import sys

f = None
def readLine():
    global f
    if len(os.environ) == 63:
        if not f:
            f = open("a.txt")
        return f.readline()
    else:
        return raw_input()

if __name__ == '__main__':
    print min([x/y for x, y in zip(map(int, readLine().split()), [1, 1, 2, 7, 4])])


requirements = (1, 1, 2, 7, 4)

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

min_count = 2**64

for i, x in enumerate(ingrs):
    if i >= len(requirements):
        continue
    min_count = min(int(x / requirement[i]), min_count)

print(min_count)


contador = 0
if (2 * a <= b):
    return contador
elif (a >= b):
    superior = b - 1
    inferior = 1
    while (inferior < superior and inferior != superior):
        contador += 1
        inferior += 1
        superior -= 1
    return contador
elif (a < b):
    vec = []
    inferior = b - a
    superior = a
    while (inferior < superior and inferior != superior):
        contador += 1
        inferior += 1
        superior -= 1
    return contador


#include<bits/stdc++.h>
#define int long long
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int32_t main(){
    IOS; int n, m; cin>>n>>m;
    string s, t; cin>>s>>t;
    int start = 0, end = n-1;
    vector<int>result(n+1), temp;
    while(end<m){
        temp.clear();
        for(int i=start;i<=end;i++){
            if(s[i-start]!=t[i]){
                temp.push_back(i+1-start);
            }
        }
        if(result.size()>temp.size())
            result = temp;
        start++, end++;
    }
    cout<<result.size()<<"\n";
    for(auto x: result)
        cout<<x<<" ";
    return 0;
}


 def res(n, k):
     max_res = min(n, k - 1)
     min_res = max(1, k - max_res)
     return max(0, (max_res + 1 - min_res) // 2)
a = int(input())
b = int(input())
print(res(a,b))


import math
n,k = map(int, input(). split())
if n + n-1 < k or k == 1:
    print(0)
else:
    if k > n:
        perv = k - n
        rasn = n - perv + 1
        otvet = rasn / 2
        math.floor(otvet)
        print(int(otvet))
    elif k == n:
        if k % 2 == 0:
          otvet = k / 2
          print(int(otvet))
        else:
             k -= 1
             otvet = k / 2
          print(int(otvet))
    else:
        otvet = (k - 1) / 2
        math.floor(otvet)
        print(int(otvet))


#include <bits/stdc++.h>
using namespace std;

int main(){
    long long int n, k;
    cin>>n>>k;
    long long int arr[n];
    for(int i=0;i<n;i++) arr[i] = i+1;
    long long int low = 0;
    long long int high = sizeof(arr)/sizeof(arr[0]);;
    //cout<<low<<" "<<high;
    int count = 0;
    //cout<<arr[low]<<" "<<arr[high];
    while(low < high){
        if(arr[low] + arr[high] == k){
            count++;
            low++;
            high--;
        }else if(arr[low] + arr[high] < k)
            low++;
        else
            high--;
    }
    cout<<count<<endl;
    return 0;
}


s=input().strip()

con1, con2 = 'http://', 'ftp://'

if s[0]=='h':
	start= 4
	end = 4
	for i in range(4,len(s)-1):
		if s[i]+s[i+1] == 'ru' && start !=end:
			end = i
			break
	ans = s[start:end]

	ans = con1+ans+'.ru/'+s[end+2:]
	print(ans)

elif s[0]=='f':
	start= 3
	end = 3
	for i in range(3,len(s)-1):
		if s[i]+s[i+1] == 'ru' && start !=end:
			end = i
			break
	ans = s[start:end]

	ans = con2+ans+'.ru/'+s[end+2:]
	print(ans)


def primeFactorize(n):
    factors = []
    div = 2
    while n > 1:
        while n % div == 0:
            factors.append(div)
            n //= div
        div += 1
    return factors

a,b = [primeFactorize(int(x)) for x in input().split()]
ans = -1

if a[-1] <= 5 and b[-1] <= 5:
    ptrA = 0
    ptrB = 0
    ans = 0
    while ptrA < len(a) and ptrB < len(b):
        if a[ptrA] < b[ptrB]:
            ptrA += 1
            ans += 1
        elif a[ptrA] > b[ptrB]:
            ptrB += 1
            ans += 1
        else:
            ptrA += 1
            ptrB += 1

print(ans)


n = int(raw_input())
a = map(int, raw_input().split(' '))
m = max(a)
m1 = min(a)
i = a.index(m)
a[i], a[0] = a[0], a[i]
i = a.index(m1)
a[i], a[n - 1] = a[n - 1], a[i]
a = a[1:n - 1]
a.sort()
print m,
for i in range(n - 2):
    print a[i],
print m1,


"""B - Fox Dividing Cheese"""

def pieces(a, b):
    div = [2, 3, 5]
    op = 0
    if a >= 1 and b <= 1E+10:
        if a == b:
            return op
        else:
            for i in div:
                while a % i == 0 and b % i == 0:
                    a = a / i
                    b = b / i
                while a % i == 0:
                    a = a / i
                    op += 1
                while b % i == 0:
                    b = b / i
                    op += 1
                if a == b:
                    return op
            else:
                return -1
    else:
        return "Error"

a = int(input())
b = int(input())
print(pieces(a, b))


def primeFactorize(n):
    factors = []
    div = 2
    while n > 1:
        while n % div == 0:
            factors.append(div)
            n //= div
        div += 1
    return factors

a,b = [primeFactorize(int(x)) for x in input().split()]
ans = -1

if a[-1] <= 5 and b[-1] <= 5:
    a2, a3, a5 = 0, 0, 0
    b2, b3, b5 = 0, 0, 0

    for i in a:
        if i==2: a2 += 1
        if i==3: a3 += 1
        if i==5: a5 += 1
    for i in b:
        if i==2: b2 += 1
        if i==3: b3 += 1
        if i==5: b5 += 1

    ans = abs(a2-b2) + abs(a3-b3) + abs(a5-b5)

print(ans)


def mdc(num_a, num_b):
    aux_1 = num_a
    aux_2 = num_b

    while True:
        rest = aux_1 % aux_2
        if rest == 0:
        break
        else:
            aux_1 = aux_2
            aux_2 = rest

    return aux_2

cheese_a, cheese_b = map(int,raw_input().split(' '))
operations = 0

while True:
    if cheese_a > cheese_b:

        max_d = mdc(cheese_a, cheese_b)
        cheese_a = cheese_a / max_d
        cheese_b = cheese_b / max_d

        if cheese_a % 2 == 0:
            cheese_a = cheese_a / 2
            operations +=1
        elif cheese_a % 3 == 0:
            cheese_a = cheese_a / 3
            operations += 1
        elif cheese_a % 5 == 0:
            cheese_a = cheese_a / 5
            operations += 1
        else:
            operations = -1
            break
    elif cheese_b > cheese_a:

        max_d = mdc(cheese_b, cheese_a)
        cheese_a = cheese_a / max_d
        cheese_b = cheese_b / max_d

        if cheese_b % 2 == 0:
            cheese_b = cheese_b / 2
            operations +=1
        elif cheese_b % 3 == 0:
            cheese_b = cheese_b / 3
            operations += 1
        elif cheese_b % 5 == 0:
            cheese_b = cheese_b / 5
            operations += 1
        else:
            operations = -1
            break
    else:
        break

print operations


import sys

class Node:

	def __init__(self, id):
		self.id = id
		self.adjacent = set()
		self.visited = 0

	def addEdge(self, edge):
		self.adjacent.add(edge)

class Graph:

	def __init__(self, numNodes, startNode):
		self.nodes = list()
		self.startNode = startNode
		self.maxPath = 234234778
		self.result = 0
		for num in range(1, numNodes + 1):
			tempNode = Node(num)
			self.nodes.append(tempNode)

	# finds the number of separate connected components of the graph
	def numConnectedComponents(self):
		s = set()
		result = 0
		for n in self.nodes:
			oldsize = len(s)
			self.addAllAdjacentVertices(n, s)
			if len(s) is not oldsize:
				result += 1
		return result

	# recursively adds a vertex and all connected vertices
	def addAllAdjacentVertices(self, node, set):
		set.add(node.id)
		self.findNode(node.id).visited = 1
		for edge in node.adjacent:
			if self.findNode(edge).visited is not 1:
				self.addAllAdjacentVertices(self.findNode(edge), set)

	# kickoff method that uses a recursive helper method
	def numNodesReachable(self, node):
		return self.nodesHelper(node, 0)

	# helper method to find the number of nodes reachable within the given maximum path length
	def nodesHelper(self, currNode, numSteps):
		self.result += 1
		currNode.visited = 1
		if numSteps < self.maxPath:
			for edge in currNode.adjacent:
				if self.findNode(edge).visited is not 1:
					self.nodesHelper(self.findNode(edge), numSteps + 1)
		return self.result

	# clears the visited field of every node
	def clearVisited(self):
		for node in self.nodes:
			node.visited = 0
		self.result = 0

	def findNode(self, id):
		for node in self.nodes:
			if id == node.id:
				return node

	def findPath(self):
		stack = list()
		answer = list()
		stack.append(self.findNode(self.startNode))
		while len(stack) != 0:
			v = stack[len(stack) - 1]
			if len(v.adjacent) == 0:
				answer.append(v.id)
				stack.pop()
			else:
				edge = v.adjacent.pop()
				self.findNode(edge).adjacent.remove(v.id)
				stack.append(self.findNode(edge))

		return answer

line = sys.stdin.readline().rstrip()
temp = line.split(" ")
numRows = int(temp[0])
numCols = int(temp[1])

g = Graph(numRows * numCols, 1)

line2 = sys.stdin.readline().rstrip()
line3 = sys.stdin.readline().rstrip()
rl = list(line2)
ud = list(line3)
# rl determiend by row number
# ud determined by col number

for row in range(0, numRows):
	for col in range(0, numCols):
		nodeNumber = row * numCols + col + 1
		node = g.findNode(nodeNumber)

		if rl[row] == '>':
			if col + 1 < numCols:
				dest = row * numCols + col + 2
				node.addEdge(dest)
		else:
			if col - 1 >= 0:
				dest = row * numCols + col
				node.addEdge(dest)

		if ud[col] == '^':
			if row - 1 >= 0:
				dest = (row - 1) * numCols + col + 1
				node.addEdge(dest)
		else:
			if row + 1 < numRows:
				dest = (row + 1) * numCols + col + 1
				node.addEdge(dest)

# for node in g.nodes:
# 	for edge in node.adjacent:
# 		print(str(node.id) + " - " + str(edge))

weGood = True

for node in g.nodes:
	temp = g.numNodesReachable(node)
	g.clearVisited()
	if temp != numRows * numCols:
		weGood = False
		break

if weGood:
	print("YES")
else:
	print("NO")


input()

horiz = input()
vert = input()

num_horiz = len(horiz)
num_vert = len(vert)

num_junc = num_horiz * num_vert

grid = [[0 for j in range(num_junc) ] for i in range(num_junc)]

for i in range(num_horiz):
    for j in range(num_vert):

        p = i * num_vert + j

        if horiz[i] == '>' and j + 1 < num_vert:
            grid[p][p + 1] = 1
        elif horiz[i] == '<' and j - 1 >= 0:
            grid[p][p - 1] = 1

        if vert[j] == 'v' and i + 1 < num_horiz:
            grid[p][p + num_vert] = 1
        elif vert[j] == '^' and i - 1 >= 0:
            grid[p][p - num_vert] = 1

cached_visits = [[] for x in range(num_junc)]

good_city = True

for idx, adj_nodes in enumerate(grid):
    visited = [0 for x in range(num_junc)]
    visited[idx] = 1

    s = [idx for idx, val in enumerate(adj_nodes) if val ]

    while s:
        node_idx = s.pop()
        visited[node_idx] = 1
        new_possible_nodes = [idx for idx, val in enumerate(grid[node_idx]) if val and not visited[idx]]
#         print(new_possible_nodes)
        s += new_possible_nodes

    if visited.count(0):
#         print(visited)
        good_city = False
        break

print('YES' if good_city else 'NO')


#input
n,m=map(int,input().split())
nstr=str(input())
mstr=str(input())

#variables

#main
if '^' not in mstr or 'v' not in mstr:
	print('NO')
	quit()
if '>' not in nstr or '<' not in nstr:
	print('NO')
	quit()
if nstr[0]=='>' and mstr[0]=='v':
	print('NO')
	quit()
if nstr[0]=='>' and mstr[-1]=='^':
	print('NO')
	quit()
if nstr[-1]=='<' and mstr[0]=='v':
	print('NO')
	quit()
if nstr[-1]=='<' and mstr[-1]=='^':
	print('NO')
	quit()
print('YES')


MOD = 10 ** 9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n,k,MOD):
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans *= i
        ans %= MOD
    for i in range(k):
        ans *= modinv(i,MOD)
        ans %= MOD
    return ans

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

print(combination(n-1,n-2 * k-1) * combination(n-1,n - 2 * k - 1) % MOD)


MOD = 10 ** 9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n,k,MOD):
    ans = 1
    for i in range(n - k + 1, n + 1):
        ans *= i
        ans %= MOD
    for i in range(k):
        ans *= modinv(i,MOD)
        ans %= MOD
    return ans

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

print(combination(n-1,n-2 * k-1,MOD) * combination(n-1,n - 2 * k - 1,MOD) % MOD)


mod=1000000007
def fact(n):
    if(n==0):
        return 1
    else:
        return n*fact(n-1)%mod
def myPow(n,p):
    if(p==0):
        return 1
    res=myPow(n,p/2)
    res=res*res%mod
    if(p%2==1):
        res=res*n%mod
    return res
def rev(n):
    return myPow(n,mod-2)
def comb(n,k):
    if(k>n):
        return 0
    res=fact(n)
    res*=rev(fact(k)*fact(n-k)%mod)
    res%=mod
    return res
n,m,k=map(int,raw_input().split())
n-=1
m-=1
res=comb(n,2*k)*comb(m,2*k)%mod
print res


n, m, k = map(int, raw_input().strip().split())
def fac(x):
    return  x * fac(x - 1) if x else 1
def c(n, r):
    return fac(n) / (fac(n - r) * fac(r)) if r <= n else 0
print c(n - 1, k * 2) * c(m - 1, k * 2) % (10 ** 9 + 7)


from sys import stdin, stdout, stderr, exit
from math import log, factorial
import re

# inputf = open('input.txt', 'r')
# outputf = open('output.txt', 'w')

def readil():
    return list(map(int, stdin.readline().strip().split()))

def C(n, k):
    return factorial(n) // factorial(k) // factorial(n-k)

def main():
    n, m, k = readil()
    stdout.write(str((C(n - 1, 2 * k) * C(m - 1, 2 * k)) % 1000000007))

if __name__ == '__main__':
    main()

# inputf.close()
# outputf.close()


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

def solve(tc):
    n, a, b = map(int, stdin.readline().split())

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

    mini = int(1e18)+1
    minv = (-1, -1)
    if a > b:
        a, b = b, a

    base = 6 * n
    ma = a
    while True:
        if base//ma < b:
            break

        if base % ma == 0:
            print(base)
            print(ma, base//ma)
            return

        mb = base // ma + 1
        if mini > ma*mb - base:
            mini = ma*mb - base
            minv = (ma, mb)

        ma += 1

    print(minv[0]*minv[1])
    print(minv[0], minv[1])

tc = 1
solve(tc)


pp = -1
def func(x) :
	p = 6*N / (x + A);
	p = max(p, B);
	return p * (x + A);
read = lambda : map(int, raw_input().split())
N, A, B = read()
l = 0; r = 10**9;
for xx in range(100):
  m1 = l + (r - l) / 3;
  m2 = r - (r - l) / 3;
  if (func(m1) > func(m2)) : l = m1;
  else : r = m2;
ans = 10**20;
a = -1;
b = -1
for xx in range(l, r + 1):
	res = func(xx);
	if (res < ans) :
		ans = res;
		a = xx + A;
		p = 6*N / (xx + A);
		p = max(p, B);
		b = p;
print ans
print a, b


from sys import stdin
n,a,b = stdin.readline().strip().split()
n=int(n);a=int(a);b=int(b)
s = a*b
t = 6*n
fir = a
sec = b
x=a
y=b
hi = int(math.sqrt(t))
if hi*hi<t:
 hi+=1
if s<t:
 mi = a
if b<mi:
 mi = b
tart = 6*n+5
x = a
y = b
for i in xrange(mi,hi+1):
 xx = i
 yy = t/xx
 if xx*yy < t:
  yy+=1
 if xx*yy < tar and x <= xx Nd y<= yy:
  tar = xx*yy;
  x = xx
  y = yy
print tar
print x,y


#include<cstdio>
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>

using namespace std;

typedef long long LL;

LL T,N,K,D1,D2;
LL s_d1,s_d2,w1,w2,w3;
bool ans;

int main()
{
    scanf("%I64d",&T);

    return 0;
}


from sys import stdin
n,a,b = stdin.readline().strip().split()
n=int(n);a=int(a);b=int(b)
s = a*b
t = 6*n
fir = a
sec = b
x=a
y=b
hi = int(math.sqrt(t))
if hi*hi<t:
 hi+=1
if s<t:
mi = a
if b<mi:
 mi = b
tart = 6*n+5
x = a
y = b
for i in xrange(mi,hi+1):
 xx = i
 yy = t/xx
 if xx*yy < t:
  yy+=1
 if xx*yy < tar and x <= xx Nd y<= yy:
  tar = xx*yy;
  x = xx
  y = yy
print tar
print x,y


d, L, v1, v2  = map( int, raw_input().split() )

f1, f2 = 0, L
ans = 0

while True:
	next1 = f1+v1
	next2 =  f2-v2
	if abs( next1 - next2 ) < d or next1 >= next2 + d:
		break
	f1 += v1
	f2 -= v2
	#print f1,f2
	ans += 1
#print f1, f2
if v1 != v2:
	ans += abs( ( 2*d  - f1 -f2 ) / ( v1  + v2 + 0.0) )-1

print "%f" % ( max( 1,ans ) )


a=input().split()
b=int(a[1])-int(a[0])
c=int(a[2])+int(a[3])
print(c/b)


def zad1(d,L,v1,v2):
    t=round((float(L)-float(d)/(float(v1)+float(v2),6)
    return t


def zad1(d,L,v1,v2):
    t=round((float(L)-float(d)/(float(v1)+float(v2))
    return t


#include <iostream>
#include <cstdio>

using namespace std;
typedef long long ll;
const int M = 100;
ll fx[M],fy[M];

void make_fib()
{
    fx[0] = 0;
    fx[1] = 1;
    fy[0] = fy[1] = 1;
    for(int i = 2; i < 100; i++){
        fx[i] = fx[i - 1] + fx[i - 2];
        fy[i] = fy[i - 1] + fy[i - 2];
    }
}

int main()
{
    make_fib();
    ll x,y,m;
    while(cin>>x>>y>>m)
    {
        if(m <= max(x,y)) puts("0");
        else if(x + y <= min(x,y)) puts("-1");
        else
        {
            int k = 0;
            if(x > y) swap(x,y);
            if(x < 0) x += y,k++;
            for(int i = 1; i < 100; i++){
                ll ans = x * fx[i] + y * fy[i];
                if(ans >= m){
                    k += i;
                    break;
                }
            }
            printf("%d\n",k);
        }
    }
    return 0;
}


def solver():
	x,y,m = map(int , raw_input().split())
	if(x >= 0 and y >= 0):
		if(x >= m or y >= m):
			print "0"
			return
	if(x <= 0 and y <= 0):
		if(x >= m or y >= m):
			print "0"
			return
		else:
			print "-1"
			return

	if(x < y) x,y = y,x
	if(x >= m):
		print "0"
		return
	else:
		ans = 0
		if(abs(y)%x==0):
			ans = abs(y)/x
			y = 0
		else:
			ans = abs(y)/x
			ans +=1
			y = y + (ans*x)
		while(x < m and y < m):
			if(x < y):
				x,y = y,x
			#x is greater
			y = x+y
			ans+=1
		print ans

	return
if __name__ == "__main__":
	solver()


x, y, m = map(int, raw_input().strip().split(' '))

if x <= 0 and y <= 0 and max(x,y) < m:
    return -1

counter = 0
while max(x,y) < m:
    if x < y:
        x = x + y
    else:
        y = x + y
    counter += 1

print counter


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

int solve(int a, int b, int tar)
{
	if(a<0 and b<0){return INT_MAX;}
	if(a>=tar or b>=tar){return 0;}
	int mini=min(a,b);
	int maxi=max(a,b);
	int ans=0;
	while(maxi<tar)
	{
		int tmp=mini+maxi;
		mini=maxi;
		maxi=tmp;
		++ans;
	}
	return ans;
}
//edge cases when n=1 , m=1. wrong variable in loop. if<->while;merge resize
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	speed
	//global var
	int x,y,m;cin>>x>>y>>m;
	if(x>=m or y>=m)
	{
		cout<<0<<"\n";
	}
	if(x>0 or y>0)
	{
		int ans=INT_MAX;
		int mini=min(x,y);
		int maxi=max(x,y);
		for(int i=0;i<200;++i)
		{
			if(mini>m)
			{
				ans=min(ans,i);break;
			}
			ans=min(ans,(i+solve(mini,maxi,m)));
			mini+=maxi;
		}
		cout<<ans<<"\n";
	}
	else
	{
		cout<<-1<<"\n";
	}
}


#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	int c = s.size();
	int xb[100], yb[100];
	int x = 0, y = 0;
	for (int i = 0; i < c; i++) {
		switch (s[i]) {
			case 'U':
				y++;
				break;
			case 'D':
				y--;
				break;
			case 'L':
				x--;
				break;
			case 'R':
				x++;
				break;
		}
		xb[i] = x;
		yb[i] = y;
	}
	int xr = xb[c-1], yr = yb[c-1];
	for (int i = 0; i < c; i++) {
		int xu = a - xb[i];
		int yu = b - yb[i];
		int resx, resy;
		if (xr == 0) {
			resx = xu;
		} else {
			resx = xu % xr;
		}
		if (yr == 0 && yu != 0) {
			resy = yu;
		} else {
			resy = yu % yr;
		}
		if (resx == 0 && resy == 0) {
			if (xr * yu == xu * yr) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


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

s = ""
for i in xrange(0, n):
  for j in xrange(0, m):
    ok = True
    for k in xrange(0, n):
      ok &= k == i or v[k][j] != v[i][j]
    for k in xrange(0, m):
      ok &= k == j or v[i][k] != v[i][j]
    if ok:
      s += v[i][j]
print s


# import sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("OUTPUT3.out","w")
for _ in range(int(input())):
	N=int(input())
	if N<=3:
			print("1")
	else:
		S=3
		arr=[]
		arr.append(0)
		arr.append(3)
		for i in range(2,40):
			S=S+pow(3,i)
			arr.append(S)
		for i in range(1,40):
			if N>arr[i-1] and N<=arr[i]:
				print(i)
				break


import math
a = list(map(int,input().split()))
b = 0
d = 0
for x in a:
	if x% 2 != 0:a[a.index(x)] = x + 1
	if x > b:b = x
if a.count(b) > 1:
	for x in range(a.count(b) - 1):a[a.index(b)] = 0
c = math.ceil(b / 2)
b =(3 - (a.index(b) + 1)) + 1
print(30 + ((c * 3)) -b)


print 30 + max([(i+3*((int(x)+1)/2-1) for i, x in enumerate(raw_input().split())])


r,g,b=map(int,raw_input().split())
t=0
while r>0 or g>0 or b>0:
    if t%3==0:
        r-=2
    elif t%3==1:
        g-=2
    else:
        b-=2
t += 30
print t


n,m=map(int,raw_input().split())
mod=1000000009
p=1
while(m--):
    p=(p*2)%mod
ans=1
for i in range(n):
    p=(p-1+mod)%mod
    ans=(ans*p)%mod
print ans


n, m = map(int, raw_input().split())
k = pow(2, m, 1000000009) - 1
ans = 1
for i in xrange(n)
    ans *= k - i
print ans


n,m=map(int,raw_input().split())
mod=1000000009
p=1
while(m--): p=(p*2)%mod
ans=1
for i in range(n):
    p=(p-1+mod)%mod
    ans=(ans*p)%mod
print ans


n, m = map(int, raw_input())
k = pow(2, m, 1000000009) - 1
ans = 1
for i in xrange(n)
    ans *= k - i
print ans


mod = 1000000009

def pow2(m):
    if m == 0:
        return 1
    elif m == 1:
        return 2
    else:
        t = pow2(m//2)
        t = (t*t)%mod
        if (m%2 == 0):
            return
        else:mod = 1000000009

def pow22(m):
    if m == 0:
        return 1
    elif m == 1:
        return 2
    else:
        t = pow22(m//2)
        t = (t*t) % mod
        if (m%2) == 0:
            return t
        else:
            return (t * 2) % mod

n = int(input())
m = int(input())
r = 0
if m > 30 or n <= 2**m:
    r = pow22(m)-1
    md = r
    for i in range(n - 1):
        md = md - 1
        r = (r * md) % mod
print ((r + mod) % mod)

            return (t * t * pow2(m%2)) % mod

n = int(input())
m = int(input())
r = 0
if m > 30 or n <= 2**m:
    r = pow2(m)-1
    md = r
    for i in range(n - 1):
        md = md - 1
        r = (r * md) % mod
print ((r + mod) % mod)


x=int(input())
z=[n for n in str(int(input()))]
l=0
for n in z:
  in n!=4 or n!=7:
    print('NO')
    l=0
    break
  else:
    l=1
if l==1:
  if sum(z[0::x//2])==sum(z[x//2:x])
    print('YES')
  else:
    print('NO')


def contest():
	x = input();
	y = input();
	z = 0;
	s = str(y);
	for i in s:
		if i not in ["4","7"];
			z = 1;
	if z == 1:
		print "NO";
	else:
		print "YES";

contest();


def contest():
	x = input();
	y = input();
	z = 0;
	s = str(y):
		for i in s:
			if i not in ["4","7"];
				z = 1;
	if z == 1:
		print "NO";
	else:
		print "YES"

contest();


n = int(input())
if n%2 !=0:
    print("NO")
else:
    tiquete=input()
    cuatros = tiquete.count("4")
    sietes = tiquete.count("7")
    if cuatros+sietes==n:
        mitad1 = tiquete[:int(len(tiquete)/2)]
        mitad2 = tiquete[int(len(tiquete)/2):(len(tiquete))]
        print(mitad1,mitad2)
        cuatros1 = mitad1.count("4")
        sietes1 = mitad1.count("7")
        cuatros2 = mitad2.count("4")
        sietes2= mitad2.count("7")
        if cuatros1==cuatros2 and
         sietes1==sietes2:
            print("SI")
        else:
            print("NO")


#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int n,a=0,b=0,k=1,p,m;
  char x;
  cin>>n;
  m=n/2;
  for(int i=0;i<n;i++){
    cin>>x;
    p=int(x)-48;
    if(p!=4 && p!=7){k=0;}
    if(i<m){a+=p;}
    else{b+=p;}
  }
  if(k && a==b){cout<<"YES";}
  else{cout<<"NO";}
}


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
if(l[0] != 0):
	print(1)
	sys.exit()
for i in range(n):
	if(l[i] != 0):
		print(i)
		break
	if(i == n-1):
		print(n)


n = input()
l = map(int,raw_input().strip().split(' '))
l.sort()
prev = l[0]
ans_list = [prev]
top_list = [prev]
count = [0]*100
count[0]=1
length = 1
for i in range(1,n):
    done=0
    for j in range(length):
        if l[i]>top_list[j]:
            top_list[j]=l[i]
            count[j]+=1
            done = 1
            break
    if done==0:
        count[length]+=1
        ans_list.append(l[i])
        top_list.append(l[i])
        length+=1
# print ans_list
# print top_list
# print count
i = 0
j = length-1
while(i<j):
    while(count[j] and i<j):
        if ans_list[i]>0:
            count[j]-=1
            ans_list[i]-=1
        else:
            i+=1
    if count[j]==0:
        j-=1

# print count
# print ans_list
i = 0
while(count[i]!=0):
    i+=1
print i


'''
Created on 01-Jul-2017

@author: kandarp
'''
import sys
def check(x,a):
    b =[]
    ans = True;
    for i in xrange(0,x):
        b.append([]);
    for i in xrange(0,len(a)):
        b[i%x].append(a[i])
    for i in xrange(0,x):
        for j in xrange(0,len(b[i])):
            if b[i][j] < (len(b[i]) - (j+1)):
                ans = False;
                return ans;
    return ans;
n = int(raw_input())
a = [int(x) for x in raw_input().split()]
a.sort(reverse=True)
if n==1:
    print(1)
    sys.exit(0);
current_watch = 0;
l=0;
r=len(a);
ans =1;
while(r - l >1):
    mid = int((l + r)/2);
    if(check(mid, a)):
        r = mid;
    else:
        l = mid;

if(check(l,a)):
    print(l);
else:
    print(r);


n = int(input())
val = [[]]
for x in sorted(int(x) for x in input().split()):
    for l in val:
    if x >= len(l):
            l.append(x)
            break
    if len(val[-1]) > 0:
    val.append([])
print(len(val) - 1)