players = {1, 2, 3}
not_playing = 3
cases = int(input())
trial = cases
for x in range (cases):
  winner = int(input())
  if winner == not_playing:
    print ("NO")
    break
  for y in players:
    if y != winner and y!= not_playing:
      not_playing = y
      break
  trial -= 1
if trial == 0: print("YES")


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


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

def s(x):
    xStr = str(x)
    sum = 0
    for c in xStr:
        sum += int(c)
    return sum

rightSide = []
M = 9*9+1
for k in range(1,M):
    rightSide.append(b*k**a + c)

myList = []
sol = 0
for x in rightSide:
    if(x>0 and x<int(1e9) and x==b*s(x)**a + c):
        sol += 1
        myList.append(x)

myList.sort()
print(sol, end='\n')
for num in myList:
    print(num, sep=' ', end=' ')


import sys, itertools as it
# sys.stdin = open("main.inp", "r")
# sys.stdout = open("main.out", "w")

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

ans = []
for d in range(1, 82): # 1->81
    x = b*(d**a)+c
    if x > 0 and x < 1e9 and sum(map(int, list(str(x)))) == d:
        ans.append(x)

print(len(ans))
for res in ans: print(res, end=" ")


n,m=map(int,input().split())
l=list(map(int,input().split()))
li=[0]*(n+1)
for i in l:
    for j in range(i,n+1):
        if li[j]==0:
            li[j]=i
for i in range(1,n+1):
    print(li[i],end=" ")


n , m = map(int,input().split())
l = list(map(int,input().split()))
a = []

for i in range(1,n+1):
    for j in l :
        if j <= i :
            a.append(j)
            break

print(*a)


class A:

    def rotate_keypad(self, keypad):
        reversed_rows = list(reversed(keypad))
        return ["".join(list(reversed(x))) for x in reversed_rows]

    def solve(self):
        keypad = [input(), input(), input()]
        if keypad == self.rotate_keypad(keypad):
            print("YES")
        else:
            print("NO")

A().solve()


def solve():
    keys = []
    rev = []
    for i in range(3):
        keys += list(raw_input().strip())
    for i in keys:
        rev.insert(0,i)
    if keys == rev:
        print 'YES'
    else:
        print 'NO'

solve()


def palindromeString(n):
    s = str(n)
    myList = list(s)
    for i in range(0, len(s)):
        myList.append(s[len(s) - i - 1])
    return int(''.join(myList))
inputLine = input()
inputList = inputLine.split(' ')
k = int(inputList[0])
p = int(inputList[1])
sum = 0
for i in range(1, k + 1):
    sum += palindromeString(i)
print(sum % p)


k,p=map(int,input().split())
s=0
for i in range(1,k+1):
    s+=int(str(i)+str(i)[::-1])
print(s%p)


#import resource
#import sys
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#sys.setrecursionlimit(0x10000000)
from sys import stdin, stdout
def GCD(x, y):
   while(y):
       x, y = y, x % y
   return x
def BS(arr, l, r, x):
    if r >= l:
        mid = l + (r - l)/2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return BS(arr, l, mid-1, x)
        else:
            return BS(arr, mid+1, r, x)
    else:
        return -1
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import math
a=input()
b=raw_input()
e=[]
for i in range(2,a):
    if(a%i==0):
        e.append(i)
for i in range(len(e)):
    d=b[:e[i]]
    d=d[::-1]+b[e[i]:]
    b=d[:]
print b[::-1]


from math import ceil,sqrt
n = int(input())
s = input()
div = []
for i in range(2,ceil(sqrt(n))+1):
    if n%i == 0:
        div.append(i)
        div.append(n//i)
div = sorted(list(set(div)))
for i in div:
    a = s[:i]
    s = a[::-1] + s[i:]
if n != 2:
    print(s[::-1])
else:
    print(s)


import math

k, n, s, p = raw_input().split()
paperEachNeed = math.ceil(float(n) / float(s))
totalPapers = paperEachNeed * float(k)
packsToBuy = math.ceil(totalPapers / float(p))
print(int(packsToBuy))


import math
people, planesperperson, planespersheet, sheetsperpack = [int(i) for i in input().split(' ')]
sheetsperperson = math.ceil(planesperperson / planespersheet)
sheetstotal = sheetsperperson * people
packstotal = math.ceil(sheetstotal / sheetsperpack)
print(packstotal)


def playingCubes(n,m):
	print((m+n-1) - min(m,n) ,min(m,n))

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


"""
by goyal.aman
https://codeforces.com/problemset/problem/599/A

note:
patrick can visit first any shop
"""

a,b,c = map(int, input().split())
"""
a : home -> shop1
b : home -> shop2
home c : shop1 - shop2
"""

"""
possible routes:
          home
        /       \
     shop1 ---- shop2

home - shop1 - shop2 - home

home - shop1 - shop2 - shop1 - home
home - shop2 - shop1 - shop2 - home

home - shop1 - home - shop2 - home <2 ways>
"""

route1 = a + c + b
route2 = a + c + c + a
route3 = b  + c + c + b
route4 = a + a + b + b
# print("printing routes")
# print(route1)
# print(route2)
# print(route3)
# print(route4)
# print("ending routes")
# print('min', end=' ')

print(min(route1, route2, route3, route4))


tracking = sorted(list(map(int, input().split())))
x, y, z = tracking
if x * 2 >= y and y * 2 >= z:
    result = x + y + z
else:
    result = (tracking[0]+tracking[1]) * 2
print(result)


import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil
# from bisect import bisect_left, bisect_right

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7
# mod=998244353

# def BinarySearch(a,x):
# 	i=bisect_left(a,x)
# 	if(i!=len(a) and a[i]==x):
# 		return i
# 	else:
# 		return -1

# def sieve(n):
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n):
# 		if (prime[p]==True):
# 			for i in range(p*p,n+1,p):
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s

# def gcd(a, b):
# 	if(a==0):
# 		return b
# 	return gcd(b%a,a)

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

#____________________________________________________________________________________________________________________________________

# for _ in range(1):
# 	n=int(input())
# 	ans=0
# 	s=set()
# 	for i in range(1,n):
# 		for j in range(i,n):
# 			if(i^j>n):
# 				continue
# 			a=i
# 			b=j
# 			c=i^j
# 			p=sorted([a,b,c])
# 			t=(p[0],p[1],p[2])
# 			if(a+b>c and a+c>b and b+c>a and t not in s):
# 				ans+=1
# 				s.add(t)
# 	print(ans)

for _ in range(1):
	n=int(input())
	ans=0
	for i in range(1,n+1):
		for j in range(i+1,n+1):
			if(i^j>n or i^j>i or i^j>j):
				continue
			a=i
			b=j
			c=i^j
			if(a+b>c and a+c>b and b+c>a):
				ans+=1
				#print(a,b,c)
	print(ans)


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

print count


n,c=map(int,input().split())
l=list(map(int,input().split()))
d=list(map(int,input().split()))
x,y=0,0
s,ka,t,h=0,0,0,0
for i in range(n):
    t=t+d[i]
    m=max(0,l[i]-c*t)
    s=s+m
for i in range(n-1,-1,-1):
    h=h+d[i]
    m=max(0,l[i]-c*h)
    ka=ka+m
if(s==ka):
    print("Tie")
elif(s>ka):
    print("Limak")
else:
    print("Radewoosh")


import sys
import math
import itertools as it
import operator as op

n, c = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))
T = list(map(int, sys.stdin.readline().split()))

tl = tr = sl = sr = 0
for i in range(n):
  tl += T[i]
  tr += T[n-1-i]
  sl += max(0, P[i] - c*tl)
  sr += max(0, P[n-1-i] - c*tr)

if sl > sr:
  print('Limak')
elif sl == sr:
  print('Tie')
else:
  print('Radewoosh')


n = int(input())
arr =  list(map(int,input().split()))
arr.sort()
minIns = 0
for k in range(len(arr)-1):
    minIns+=arr[k+1]-arr[k]
for i in range(0,2*n):
    for j in range(i+1,2*n):
        newArr = arr[0:i]+arr[i+1:j]+arr[j+1:]
        #print(i,j,newArr)
        #Ins = 0

        minIns=min(minIns,sum(newArr[k+1]-newArr[k] for k in range(0,len(newArr)-1,2)))

print(minIns)


n=int(input())
n=n*2
arr=[int(x) for x in input().split()]
arr=sorted(arr)
x=arr[n-1]
for i in range(0,n):
    for j in range(i+1,n):
        # i,j 选中的single
        a,h,q=0,0,0
        while h<n:
            if h==i or h == j:
                pass

            else:
                if q%2==0:
                    a-=arr[h]
                else:
                    a+=arr[h]
                q+=1
            h+=1
        # print(a)
        x=min(x,a)
print(x)


from math import log

def calculateExp(x, y, z, k):
	if(k == 1):
		return x**(y**z), "x^y^z"
	elif(k == 2):
		return x**(z**y), "x^z^y"
	elif(k == 3 or k == 4):
		return x**(z*y), "(x^y)^z"
	elif(k == 5):
		return y**(x**z), "y^x^z"
	elif(k == 6):
		return y**(z**x), "y^z^x"
	elif(k == 7 or k == 8):
		return y**(x*z), "(y^x)^z"
	elif(k == 9):
		return z**(x**y), "z^x^y"
	elif(k == 10):
		return z**(y**x), "z^y^x"
	elif(k == 11 or k == 12):
		return z**(x*y), "(z^x)^y"

def calculateLogLog(x, y, z, k):
	if(x > 1):
		if(k == 1):
			return z * log(y) + log(log(x)), "x^y^z"
		elif(k == 2):
			return y * log(z) + log(log(x)), "x^z^y"
		elif(k == 3 or k == 4):
			return log(y) + log(z) + log(log(x)), "(x^y)^z"

	if(y > 1):
		if(k == 5):
			return z * log(x) + log(log(y)), "y^x^z"
		elif(k == 6):
			return x * log(z) + log(log(y)), "y^z^x"
		elif(k == 7 or k == 8):
			return log(x) + log(z) + log(log(y)), "(y^x)^z"

	if(z > 1):
		if(k == 9):
			return y * log(x) + log(log(z)), "z^x^y"
		elif(k == 10):
			return x * log(y) + log(log(z)), "z^y^x"
		elif(k == 11 or k == 12):
			return log(x) + log(y) + log(log(z)), "(z^x)^y"

	return False, ""
def getAns(x, y, z):
	if(max(x,y,z) < 1):
		maxNum, ans = 0, ""
		for i in index:
			t = calculateExp(x, y, z, i)
			if(t[0] > maxNum):
				ans = t[1]
				maxNum = t[0]
		return ans
	elif(max(x, y, z) == 1):
		if(x == 1):
			return "x^y^z"
		elif(y == 1):
			return "y^x^z"
		else:
			return "z^x^y"
	else:
		maxNum, ans = None, ""
		for i in index:
			t = calculateLogLog(x, y, z, i)
			if(t[0] != False):
				if(maxNum == None or t[0] > maxNum):
					ans = t[1]
					maxNum = t[0]
			# print(t, ans)

		return ans

index = [1, 2, 3, 5, 6, 7, 9, 10, 11]
if(__name__ == "__main__"):
	x, y, z = [float(t) for t in raw_input().split(' ')]

	print(getAns(x, y, z))


from math import log
from decimal import *
x, y, z = map(Decimal, raw_input().split())
ln = lambda x : Decimal(log(x))
ans = sorted([(-ln(x) * y ** z, "x^y^z"),
	(-ln(x) * z ** y, "x^z^y"),
	(-ln(x) * y * z, "(x^y)^z"),
	(-ln(y) * x ** z, "y^x^z"),
	(-ln(y) * z ** x, "y^z^x"),
	(-ln(y) * x *z, "(y^x)^z"),
	(-ln(z) * x ** y, "z^x^y"),
	(-ln(z) * y ** x, "z^y^x"),
	(-ln(z) * x * y, "(z^x)^y")
	], key = lambda lst : lst[0])
print ans[0][1]


ax, bx = map(str, input().split())
d = max([ord(c) - ord('0') for c in ax] + [ord(c) - ord('0') for c in bx]) + 1
ad, bd = 0, 0
for dig in ax:
  ad = ad * d + (ord(dig) - ord('0')) % 10
for dig in bx:
  bd = bd * d + (ord(dig) - ord('0')) % 10
c = ad + bd
ans = 0
while c > 0:
  ans += 1
  c //= d
print(ans)


import sys

def digitsNum(x, base):
    ret = 0
    while x>0:
        ret += 1
        x //= base
    return ret

n, m= sys.stdin.read().split()

base = int(max(max(n), max(m)))+1
n = int(n, base)
m = int(m, base)

print(digitsNum(n+m, base))


#Finaly

num=input()

if(ord(num[0])>=ord('5') and num[0]!='9'):
    ans=chr((9-(ord(num[0])-ord('0')))+ord('0'))
else:
    ans=num[0]

for i in range(1,len(num)):
    if ord(num[i])>=ord('5'):
        ans+=chr((9-(ord(num[i])-ord('0')))+ord('0'))
    else:
         ans+=num[i]

print(ans)


t = int(raw_input())
ret = 0
pows= 1
digit = 0
while t > 0:
    digit = t%10
    if digit > 4:
        ret = ret + (9-digit)*pows
    else:
        ret = ret + digit*pows
    pows *= 10
    t /= 10

if digit == 9:
    ret = ret + digit*pows/10
print ret


n=list(map(int,input().split()))
n1=list(map(int,input().split()))
lst=[]
s=0
for i in n1:
    lst.append(i)
n1.reverse()
for i in range(len(n1)):
    if(lst[i]!=n1[i] and lst[i]!=2 and n1[i]!=2):
        s=-1
        break
    elif(lst[i]==2 and n1[i]==0):
        lst.insert(i,0)
        lst.remove(lst[i+1])
        s=s+n[1]
    elif(lst[i]==2 and n1[i]==1):
        lst.insert(i,1)
        lst.remove(lst[i+1])
        s=s+n[2]
    else:
        if(n1[i]==2 and lst[i]==2):
            if(n[1]<n[2]):
                lst.insert(i,0)
                lst.remove(lst[i+1])
                s=s+n[1]
            else:
                lst.insert(i,1)
                lst.remove(lst[i+1])
                s=s+n[2]
print(s)


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

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

ans_a = 0
ans_b = 0
ans = 1

for i in range(n//2):

    if a[i] != a[n-i-1]:
        if a[i]==2 or a[n-i-1]==2:
            if a[i] == 0 or a[n-i-1]==0:
                ans_a+=1
            else:
                if a[i] == 1 or a[n-i-1]==1:
                    ans_b+=1
        else:
            ans = 0
            break
    else:
            if a[i] == 2 and a[n-i-1] == 2:
                if x < y:
                    ans_a+=2
                else:
                    ans_b+=2

if ans:
    temp = 0
    if n%2 == 0:
        temp = 0
    else:
        if a[n//2] == 2:
            temp = min(x,y)

    print(ans_a*x + ans_b*y + temp)
else:
    print(-1)


def gcd(a, b):
    return gcd(b % a, a) if a else b
x, y, n = map(int, input().split())
g = gcd(x, y)
x, y = x // g, y // g
if n < y:
    d = [min(i, y - i) for i in ((x * i) % y for i in range(0, n + 1))]
    for i in range(n - 1, 0, -1):
        if d[i] < d[n] and n * d[i] <= i * d[n]: n = i
    print(str((x * n) // y + int(2 * ((x * n) % y) > y)) + '/' + str(n))
else: print(str(x) + '/' + str(y))


from __future__ import print_function
from fractions import Fraction;
def main():
    a,b,c = map(int,raw_input().split())
    x = Fraction(a,b);
    x=x.limit_denominator(c);
    print(x.numerator,'/',x.denominator,sep='')
if __name__ == '__main__':
    main()


s = raw_input()
score = 0
moves = 0
c = s[0]
r = s[1]

if c == "a" or c == "h":
	score += 1
if r == "1" or r == "8":
	score += 1

if score == 2:
	moves = 3
elif score == 1:
	moves = 5
else:
	moves = 8

print moves


import re
a = int(8)
b = int(5)
c = int(3)
positions = input()

if re.search("[b-g]", positions):
    if re.search("[2-7]", positions):
        print(a)
    elif re.search("[1]", positions):
        print(b)
    elif re.search("[8]", positions):
        print(b)

if re.search("[h]", positions):
    if re.search("[2-7]", positions):
        print(b)
    elif re.search("[1]", positions):
        print(c)
    elif re.search("[8]", positions):
        print(c)

if re.search("[a]", positions):
    if re.search("[2-7]", positions):
        print(b)
    elif re.search("[1]", positions):
        print(c)
    elif re.search("[8]", positions):
        print(c)


n = int(input())
k = 10**6 + 1
for i in range(2,min(n,k)):
    while not n%i**2:
        n //= i
print(n)


n = int(input())
i = 2
resposta = 1
while i * i <= n:
	if n % i == 0:
		resposta *= i
		while n % i == 0:
			n //= i
	i += 1
if n > 1:
	resposta *= n
print(resposta)


import math
n,m=map(int,raw_input().split())
l=1
r=10000000000000
if n<=m:
    print n
    exit()
while l<r:
    mid=(l+r)/2
    t=(1+mid)*mid/2
    #print l, r,mid,t
    if t>=n-m:
        r=mid
    else:
        l=mid+1
print int(l+m)
#print int(math.ceil((-3+pow(9+4*(2*n-2*m-2),0.5))/2)+1+m)


#!/usr/bin/env python3
from bisect import *

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

n, m = ri()

if m-n >= 0:
    print(n)
    exit()

k = (n-m)
al = 0
ar = 2*k*(k+1)+1

while ar-al > 1:
    a = (al+ar)//2
    aa = a*(a+1)//2
    if k <= aa:
        ar = a
    else:
        al = a
print(ar+m)


import sys
from math import *
readints=lambda:map(int, input().strip('\n').split())

la,ra,ta=readints()
lb,rb,tb=readints()

k=(la-lb)/gcd(ta,tb)
klo=floor(k)
khi=ceil(k)

def intersection(ax,ay,bx,by):
    # print(ax,ay,bx,by)
    l,r=max(ax,bx),min(ay,by)
    if l>r: return 0
    return r-l+1

# print(klo,khi)

ans = 0
for dk in [klo,khi]:
    df=lb-la + dk*gcd(ta,tb)
    bx=la+df
    by=bx+(rb-lb)
    #print(ax,ay,'df',df)
    ans = max(ans, intersection(la,ra,bx,by))

print(ans)


'''input
7 13 18
2 6 12
'''
import math
def solve():
	l1,r1,t1 = list(map(int,input().split()))
	l2,r2,t2 = list(map(int,input().split()))
	# diff  = l1-l2+k1*t1-k2*t2
	# diff  = l1-l2 + K*gcd(t1,t2)
	# l2-l1 / gcd(t1,t2) = K
	g = math.gcd(t1,t2)
	K1 = (l2-l1)//g
	K2 = (l2-l1)//g
	if((l2-l1)%g!=0):
		K2+=1
	diff1 = l1-l2 + K1*g
	diff2 = l1-l2 + K2*g
	if t1==t2:
		print(min(r1,r2)-max(l1,l2)+1)
		return
	#print(diff1,diff2)
	ans = 0
	for i in [diff1,diff2]:
		l22 = l2+i
		r22 = l22+r1-l1
		ans = max(ans,min(r22,r2)-max(l22,l2)+1)
	print(ans)
	return
t = 1
#t = int(input())
while t>0:
	t-=1
	solve()


import math

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

s1 = math.ceil(n/k)*t

c = 0

up = 1000*t
down = 0

while up > down+1:
    mid = (up+down)//2
    c += (mid//t)*k
    c += ((mid-d)//t)*k
    if c>=n:
        up = mid
    else:
        down = mid
    c = 0

c = 0
##print('up', up)
##print('down', down)
##print('mid', mid)

if (down//t)*k + ((down-d)//t)*k == n:
    s2 = down
elif (mid//t)*k + ((mid-d)//t)*k == n:
    s2 = mid
else:
    s2 = up

##print('s1', s1)
##print('s2', s2)
if s2<s1:
    print('YES')
else:
    print('NO')


arr=[]
for x in raw_input().split():
    arr.append(int(x))

a = arr[0]
b = arr[1]
c = arr[2]
d = arr[3]

#print a,b,c,d

time1 = 0
a1 = a
time1 = ((a1-1)/c+1) * b

time2 = 0
a2 = a
flag = False
while a2 > 0:
    time2 += 1
    if (time2 % b ==0):
        a2 -= c
    if time2-d > 0 and (time2-d) %b == 0:
        a2 -= c
#print time1,time2

if time1 > time2:
    print 'YES'
else :
    print 'NO'


from __future__ import print_function
n = input()
a = []
for i in range(n):
    a.append([int(x) for x in raw_input().split()])
summa = sum(a[(n-1)//2])
a[(n-1)//2] = [0 for i in range(n)]
for i in range(n):
    summa+=a[i][i]
    a[i][i] = 0
    summa+=a[i][n-i-1]
    a[i][n-i-1] = 0
for i in range(n):
    summa+=a[i][(n-1)//2]
print(summa)


from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)

def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n):

    # Create a boolean array "prime[0..n]" and initialize
    #  all entries it as true. A value in prime[i] will
    # finally be false if i is Not a prime, else true.
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):

        # If prime[p] is not changed, then it is a prime
        if (prime[p] == True):

            # Update all multiples of p
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    l=[]
    for i in range(2,n+1):
    	if(prime[i]):
    		l.append(i)
    return l
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout
def fac(a,b):
	v=a
	while(a!=b):
		v*=a-1
		a=a-1
	return v
def bino(l,r,n):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		val1=math.log((n/mid)+1,2)
		val2=int(val1)
		if(val1==val2):
			return val1
		elif(val1<1.0):
			return bino(l,mid-1,n)
		else:
			return bino(mid+1,r,n)

def binary(l,r,ll,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		if(ll[mid]==val):
			return ll[mid]
		elif(ll[mid]<val):
			ans=ll[mid]
			return binary(mid+1,r,ll,val,ans)
		else:
			return binary(l,mid-1,ll,val,ans)
def check(n):
	v=1
	while(n!=0):
		if(n%10==0 or n%10==1):
			n=n//10
		else:
			v=0
			break
	return v

if __name__ == '__main__':
	n=int(input())
	l=[]
	for i in range(n):
		l1=list(map(int,input().split(" ")))
		l.append(l1)
	total=0
	for i in range(n):
		total+=l[i][i]
		total+=l[n-i-1][i]
		total+=l[n//2][i]
		total+=l[i][n//2]
	print(total-3*l[n//2][n//2])


from functools import lru_cache

m = 998244353

fm_cache = [1]
def fmod(x):
    while len(fm_cache) <= x:
        fm_cache.append((fm_cache[-1] * len(fm_cache) % m))
    return fm_cache[x]

@lru_cache(maxsize=None)
def imod(x):
    return pow(x, m - 2, m)

@lru_cache(maxsize=None)
def C(n, k):
    return (fmod(n) * imod(fmod(k)) * imod(fmod(n - k))) % m

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

def go():
    tot = 0
    for b in range(1, n + 1):
        dv = n // b - 1
        if dv >= k - 1:
            tot = (tot + C(dv, k - 1)) % m
    return tot

print(go())
# print(imod.cache_info())
# print(C.cache_info())


def pow3(a, b, mod) :
    ans = 1
    while b > 0 :
        if b & 1 :
            ans = (ans * a) % mod
        a = (a * a) % mod
        b >>= 1
    return ans

class comb :
	inf = 0
	fact = []
	inv = []

	def __init__(self, n, infi) :
		self.fact.extend([0] * (n + 1))
		self.inv.extend([0] * (n + 1))
		self.inf = infi
		self.fact[0] = 1
		for i in range (1, n + 1) :
			self.fact[i] = (self.fact[i - 1] * i) % self.inf
		for i in range (0, n + 1) :
			self.inv[i] = pow3(self.fact[i], self.inf - 2, self.inf)

	def ncr(self, n, r) :
		ans = self.fact[n]
		ans = (ans * self.inv[r]) % inf
		ans = (ans * self.inv[n - r]) % inf
		return ans

	def f(self, n) :
		return self.fact[n]

	def iv(self, n) :
		return self.ivf[n]

inf = 998244353
n, k = list(map(int, input().split()))
c1 = comb(n, inf)
ans = 0
#for i in range (2, n) :
    #print(c1.ncr(i, 2))

i = 1
while i * k <= n :
    cnt = n // i - 1
    r = k - 1
    ans = (ans + c1.ncr(cnt, r)) % inf
    i += 1

print(ans)


# Prime factorization
def prime_factorization(x):
    answer = []
    i = 2
    while i*i <= x:
        if x%i == 0:
            answer.append(i)
            while x%i == 0: x //= i
        i += 1
    if x > 1: answer.append(x)
    return answer

# Main
def main(X: int, N: int):
    answer = 1
    mod = 10**9 + 7
    x_primes = prime_factorization(x)
    for prime in x_primes:
        power = 0
        factor = prime
        while factor <= N:
            power += N // factor
            factor *= prime
        #print("power is:", power)
        answer *= pow(prime, power, mod)
        answer %= mod
    return answer

x, n = [int(c) for c in input().split()]
print(main(x, n))


def primefactors(x):
    ans = []
    i = 2
    while i*i <= x:
        if x%i==0:
            ans.append(i);
            while x%i==0:
                x = x//i
        i = i+1
    if x>1:
        ans.append(x)
    return ans

x , n = [int(c) for c in input().split()]
prime = primefactors(x)
MOD = 1000000007
ans = 1
for x in prime:
    p = 0
    tmp = x
    while tmp <= n:
        p = p + n//tmp
        tmp = tmp*x
    ans = ans*pow(x , p , MOD)
ans = ans%MOD
print(ans)


n,m,k = map(int,input().split())
mod = 10**9 + 7
if k == 1 or k>n:
    print(pow(m,n,mod))

elif k == n:
    print(pow(m,(n+1)//2,mod))

elif k%2== 0:

    print(m%mod)
else:
    print(pow(m,2,mod))


"""
https://codeforces.com/contest/151/problem/D

You can build a graph with positions in sting as a nodes and equality in any substring
of length k as edges. Lets denote e the number of components in the graph. The answer is me.
"""
import sys
import math
try:
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

except:
    pass

class DisjointSet():
    def __init__(self,n):
        self.parent=[0]
        self.rank=[0]
        for i in range(1,n+1):
            self.parent.append(i)
            self.rank.append(0)

    def find(self,node):
        if(node!=self.parent[node]):
            self.parent[node]=self.find(self.parent[node])
        return self.parent[node]

    def union(self,u,v):
        leader_u=self.find(u)
        leader_v=self.find(v)
        if(leader_v!=leader_u):
            if(self.rank[leader_u]>self.rank[leader_v]):
                u,v=v,u
                leader_u,leader_v=leader_v,leader_u
            if(self.rank[leader_u]==self.rank[leader_v]):
                self.rank[leader_v]+=1
            self.parent[leader_u]=leader_v #pointing u to v

n,m,k=[int(x) for x in input().split()]
ds=DisjointSet(n)
for start in range(1,n-k+2):
    end=start+k-1
    for i in range(math.ceil(k/2)):
        ds.union(start,end)
        start+=1
        end-=1

no_of_components=0
seen=set()
for i in range(1,n+1):
    leader=ds.find(i)
    if(leader not in seen):
        seen.add(leader)
        no_of_components+=1

modulo=10**9+7
print(pow(m,no_of_components,modulo))


n = input()
a = []
for _ in range(n):
	x,y = map(int,raw_input().split())
	a.append([x,y])
res = 0
for i in range(n):
	h = a[i][0]
	g = a[i][1]
	for j in range(i + 1,n):
		if h == a[j][1]:
			res += 1
		if g == a[j][0]:
			res += 1
print res


#
#   268A. Games
#

teams = int(raw_input().strip())
host = []
guest = []
for i in range(teams):
    h, g = map(int, raw_input().strip().split())
    host.append(h)
    guest.append(g)

count_matches = 0

for g in guest:
    count_matches += host.count(g)

print count_matches


#! /usr/bin/env python

from sys import stdin

def all_in(i,j,k,edges):
	my=[(i,j),(j,k),(i,k)]
	return all(x in edges for x in my)

def all_out(i,j,k,edges):
	my=[(i,j),(j,k),(i,k)]
	return all(not (x in edges) for x in my)

def fail(edges):
	contains=0
	out=0
	for i in xrange(1,6):
		for j in xrange(i+1,6):
			for k in xrange(j+1,6):
				if all_in(i,j,k,edges):
					contains+=1
				elif all_out(i,j,k,edges):
					out+=1

	return contains==0 and out==0

if __name__=='__main__':
	m=int(stdin.readline())
	edges=set()
	for i in xrange(m):
		x,y=map(int,stdin.readline().split())
		edges.add((x,y))
		edges.add((y,x))
	#print edges
	#print all_in(5,2,3,edges)
	#print all_out(1,5,2,edges)
	if not fail(edges):
		print "WIN"
	else:
		print "FAIL"


n = int(input())

l = [0, 0, 0, 0, 0]

for i in range(n):

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

    for j in range(6):

        if a == j: l[j-1] += 1

        if b == j: l[j-1] += 1

if l.count(2) !=5: print("WIN")

else: print("FAIL")

# Made By Mostafa_Khaled


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

n=int(input())
for i in range(n):
    s=input().split()
    d=int(s[0])-int(s[1])
    if d!=1:
        print("NO")
    else:
        if prime(int(s[0])+int(s[1])):
            print("YES")
        else:
            print("NO")


from random import randrange

T = input()

def rwh_primes2(n):
    # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    correction = (n%6>1)
    n = {0:n,1:n-1,2:n+4,3:n+3,4:n+2,5:n+1}[n%6]
    sieve = [True] * (n/3)
    sieve[0] = False
    for i in xrange(int(n**0.5)/3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      ((k*k)/3)      ::2*k]=[False]*((n/6-(k*k)/6-1)/k+1)
        sieve[(k*k+4*k-2*k*(i&1))/3::2*k]=[False]*((n/6-(k*k+4*k-2*k*(i&1))/6-1)/k+1)
    return [2,3] + [3*i+1|1 for i in xrange(1,n/3-correction) if sieve[i]]

#pp = rwh_primes2(1000000)

def miller_rabin(n, k=10):
    if n == 2 or n== 3:
        return True
    if not n & 1:
        return False

    def check(a, s, d, n):
        x = pow(a, d, n)
        if x == 1:
            return True
        for i in xrange(s - 1):
            if x == n - 1:
                return True
            x = pow(x, 2, n)
        return x == n - 1

    s = 0
    d = n - 1

    while d % 2 == 0:
        d >>= 1
        s += 1

    for i in xrange(k):
        a = randrange(2, n - 1)
        if not check(a, s, d, n):
            return False
    return True

for t in xrange(T):
    a, b = map(int, raw_input().split())

    if a-b == 1:
        if miller_rabin(a+b):
            print "YES"
        else:
            print "NO"
    else:
        print "NO"


R=raw_input
a,b=map(int,R().split())
s=R()
def f(s):
 c=s.count
 return c('R')-c('L'),c('U')-c('D')
X,Y=f(s)
x,y=0,0
q=0
for i in range(len(s)):
 c,d=f(s[:i])
 A=a-c;B=b-d
 if (X and A%X) or (Y and B%Y):continue
 if X==Y==0:
  if A==B==0:q=1
 elif X==0:
  if A==0 and B//Y>=0:q=1
 elif Y==0:
  if B==0 and A//X>=0:q=1
 elif A//X==B//Y and A//X>=0:q=1
print["No","Yes"][q]


n = int(input())
num = input()
flag = 0
for i in num:
    if (i < '4') or ('4' < i < '7') or (i > '7'):
        print("NO")
        flag = 1
        break
if flag == 0:
    if sum(map(int, num[:n//2])) == sum(map(int, num[n//2:])):
        print("YES")
    else:
        print("NO")


n = int(input())
#n, m = map(int, input().split())
s = input()
#c = list(map(int, input().split()))
k = s[:n // 2].count('4') * 4 + s[:n // 2].count('7') * 7
l = s[n // 2:].count('4') * 4 + s[n // 2:].count('7') * 7
if (n % 2 == 0 and s.count('4') + s.count('7') == n and
    k == l):
    print('YES')
else:
    print('NO')


n,k=map(int,input().split(' '))
count=0
if n==2:
    print(6)
else:
    i=3
    while i<=n:
        count=count+3
        i=i+1
    count=count+6

    if n%2==0 and k!=1:
        if int(n/2)<k:
            print(count+n-k)
        else:
            print(count+k-1)
    elif n%2!=0 and k!=1:
        if int((n+1)/2)<k:
            print(count+n-k)
        else:
            print(count+k-1)
    elif k==1:
        print(count)


n=raw_input()
l=len(n)
s=0
for i,j in enumerate(n):
    if j=='A':
        p1=n.count('Q',0,i)
        p2=n.count('Q',i+1,l)
        p=p1*p2
        s+=p
print s


s= input()
cnt = 0
for i in range(len(s)):
    if s[i] == 'Q':
        for j in range(i+1,len(s)):
            if s[j] == 'A':
                for k in range(j+1,len(s)):
                    if s[k] == 'Q':
                        cnt +=1
        pass
    pass
print(cnt)


def kprod(n,k):
    i=2
    kr=[]
    while len(kr)<k-1 and i<=n:
        if n%i==0:
            kr+=[i]
            n/=i
            i=1
        i+=1
    if len(kr)==k-1 and n>1:
        return " ".join([str(i) for i in kr+[n]])
    else:
        return -1

n,k=[int(k) for k in raw_input().split(" ")]

print kprod(n,k)


import sys
n,k=[int(x) for x in sys.stdin.readline().split()]
counter=1
tobeprinted=[]
while counter!=k:
	for i in range(2,int(n)+1):
		if n%i==0:
			tobeprinted.append(i)
			n=n//i
			counter+=1
			break
	if n==1:
		print("-1")
		exit()
tobeprinted.append(n)
print(*tobeprinted)


s = input()
pos = 0
t = input()
for i in range(len(t)):
	if t[i] == s[pos]:
		pos += 1
print(pos+1)


s = raw_input()
t = raw_input()
n_ins = len(t)
current = 0
for i in range(n_ins):
    if t[i] == s[current]:
        current += 1
print current + 1


n = int(input())
x = input()
for i in range(0, 9*n+1):
    total = 0
    ok = 0
    for c in x:
        total = total + int(c)
        if total == i:
            total = 0
            ok = ok+1
        elif total > i:
            ok = 0
    if ok > 1 and total == 0:
        print("YES")
        exit(0)
print("NO")


n=int(input())
a=[int(x) for x in input()]
for s in range(0, n*9+3):
    split=0
    sub=0
    for i in range(n):
        sub+=a[i]
        if sub==s:
            split+=1
            sub=0
        elif sub > s:
            split = 0
            break
    if split > 1 and sub==0:
        print('YES')
        exit()
print('NO')


x, k = [int(a) for a in input().strip().split()]

def binpow(x, k, mod):
    res = 1
    while k > 0:
        if k & 1:
            res  = ( res * x ) % mod
        x = ( x * x) % mod
        k >>= 1
    return res
if x == 0:
    print(0)
    exit()

mod = int(1e9 + 7)
k2 = binpow(2, k, mod)
res = ( k2 * (2 * x - 1) + 1) % mod

res %= mod

print(int(res))


MOD = 10 ** 9 + 7

def multMM(a, b):
    n = len(a)
    r = [[0 for i in xrange(n)] for j in xrange(n)]
    for i in xrange(n):
        for j in xrange(n):
            for k in xrange(n):
                r[i][j] += a[i][k] * b[k][j]
                r[i][j] %= MOD
    return r

def multMV(a, v):
    n = len(a)
    r = [0 for i in xrange(n)]
    for i in xrange(n):
        for j in xrange(n):
            r[i] += a[i][j] * v[j]
            r[i] %= MOD
    return r

def powM(a, p):
    n = len(a)
    if p == 0:
        return [[1 if i == j else 0 for i in xrange(n)] for j in xrange(n)]
    if p % 2 == 0:
        t = powM(a, p / 2)
        return multMM(t, t)
    else:
        return multMM(a, powM(a, p - 1))

def main():
    x, k = map(int, raw_input().split())
    if x == 0:
        print 0
        return
    v = [1, x]
    m = [[1, 0], [MOD - (MOD + 1) / 2, 2]]
    m = powM(m, k)
    v = multMV(m, v)
    print v[1] * 2 % MOD

if __name__ == "__main__":
    main()


class CodeforcesTask592ASolution:
    def __init__(self):
        self.result = ''
        self.board = []

    def read_input(self):
        for x in range(8):
            self.board.append(input())

    def process_task(self):
        amin = 8
        bmin = 8
        n_board = []
        for x in range(8):
            line = ''
            for y in range(8):
                line += self.board[y][x]
            n_board.append(line)
        for b in n_board:
            if "B" in b:
                if "W" not in b.split("B")[-1]:
                    #print(b, b.split("B")[-1])
                    bmin = min(bmin, len(b.split("B")[-1]))
            if "W" in b:
                if "B" not in b.split("W")[0]:
                    #print(b, b.split("W")[0])
                    amin = min(amin, len(b.split("W")[0]))
        self.result = "A" if amin <= bmin else "B"

    def get_result(self):
        return self.result

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


g, v = [input() for i in range(8)], [8, 8]
for i in range(8):
    for j in range(8):
        if g[i][j] == 'W' and all(g[k][j] == '.' for k in range(i)):
            v[0] = min(v[0], i)
        elif g[i][j] == 'B' and all(g[k][j] == '.' for k in range(i + 1, 8)):
            v[1] = min(v[1], 7 - i)
print('A' if v[0] <= v[1] else 'B')


def lint(n):    #to find length of an integer
    h = int(n)
    i= 0
    while(h>0):
          h= int(h/10)
          i=i+1
    len =i
    return len

k =int(input())
list = [1]
n=1
y=1
for y in range (1,k):
        n = n+1;
        p= lint(n)
        for i in range(p,0,-1):
                e= 10**(i-1)
                x = int(n/e)
                z= x%10
                list.append(z)

        y = y+p
print(list[k-1])


[n,l,r] = [int(x) for x in input().split()]

diff_3 = (r - l)//3
ways = [diff_3,diff_3,diff_3]

for i in range(l,r-diff_3*3+1):
    # print(i)
    ways[i%3] += 1

# print(ways)
# print(sum(ways), r-l + 1)

curr = [ways[0],ways[1],ways[2]]
# print(curr)
for i in range(n-1):
    new = [0,0,0]
    for j in range(0,3):
        for k in range(0,3):
            new[(j+k)%3] += (ways[j]*curr[k])
    for j in range(0,3):
        new[j] %= (10**9+7)
    curr = new
    # print(curr)

print(curr[0])


MOD = pow(10, 9) + 7

n, l, r = map(int, raw_input().strip().split())

a0 = a1 = a2 = 0
xl = l
while xl % 3 != 0 and xl < r: xl += 1
xr = r
while xr % 3 != 0 and xr > xl: xr -= 1

if xl <= xr and xl % 3 == 0 and xr % 3 == 0: a0 = (xr - xl) // 3 + 1

xl = l
while xl % 3 != 1 and xl < r: xl += 1
xr = r
while xr % 3 != 1 and xr > xl: xr -= 1

if xl <= xr and xl % 3 == 1 and xr % 3 == 1: a1 = (xr - xl) // 3 + 1

xl = l
while xl % 3 != 2 and xl < r: xl += 1
xr = r
while xr % 3 != 2 and xr > xl: xr -= 1

if xl <= xr and xl % 3 == 2 and xr % 3 == 2: a2 = (xr - xl) // 3 + 1

dp = [[0 for i in xrange(3)] for j in xrange(n + 1)]

dp[1] = [a0 % MOD, a1 % MOD, a2 % MOD]

for i in xrange(2, n + 1):
    dp[i][0] = dp[i - 1][0] * a0 + dp[i - 1][1] * a2 + dp[i - 1][2] * a1
    if dp[i][0] >= MOD: dp[i][0] %= MOD
    dp[i][1] = dp[i - 1][0] * a1 + dp[i - 1][1] * a0 + dp[i - 1][2] * a2
    if dp[i][1] >= MOD: dp[i][1] %= MOD
    dp[i][2] = dp[i - 1][0] * a2 + dp[i - 1][1] * a1 + dp[i - 1][2] * a0
    if dp[i][2] >= MOD: dp[i][2] %= MOD

print dp[n][0] % MOD


n, m = map(int, raw_input().split(' '))
mod = 10**9+7
tmp = (1 + m - 1) * (m - 1) / 2
tmp2 = (1 + n) * n / 2
ans = (tmp * n % mod + m * tmp * tmp2 % mod) % mod
print ans


import os, sys

if __name__ == "__main__":
  a, b = map(int, raw_input().split())
  res = b * b * (b - 1) * a * (a + 1) / 4
  res += a * b * (b - 1) / 2
  print res % 1000000007


def extendedEuclidean(a,b,x,y):

    if b==0:
        return a,1,0

    d,x1,y1 = extendedEuclidean(b,a%b,x,y)

    x,y = y1,x1-y1*(a//b)

    return d,x,y

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

f = [1]*(1+max(a,b,c))
fi = [1]*(1+max(a,b,c))
m = 998244353

for i in range(1,1+max(a,b,c)):
    x = (f[i-1]*i)%m
    f[i] = x
    d,x,y = extendedEuclidean(x,m,1,1)
    fi[i] = x%m

ab=0
bc=0
ca=0

for i in range(min(a,b)+1):
    ab+=(f[a]*fi[a-i]*f[b]*fi[b-i]*fi[i])%m

for i in range(min(b,c)+1):
    bc+=(f[c]*fi[c-i]*f[b]*fi[b-i]*fi[i])%m

for i in range(min(a,c)+1):
    ca+=(f[a]*fi[a-i]*f[c]*fi[c-i]*fi[i])%m

print((ab*bc*ca)%m)


class CodeforcesTask680ASolution:
    def __init__(self):
        self.result = ''
        self.nums = []

    def read_input(self):
        self.nums = [int(x) for x in input().split(" ")]

    def process_task(self):
        self.nums.sort()
        if len(set(self.nums)) == 2:
            if max([self.nums.count(x) for x in list(set(self.nums))]) == 3:
                self.result = str(min(self.nums[0] * self.nums.count(self.nums[0]), self.nums[-1] * self.nums.count(self.nums[-1])))
            else:
                self.result = str(self.nums[0] + self.nums[-1])
        elif len(set(self.nums)) == 5:
            self.result = str(sum(self.nums))
        elif len(set(self.nums)) == 1:
            self.result = str(self.nums[0] * 2)
        elif len(set(self.nums)) == 4:
            rep = [x[0] for x in [(y, self.nums.count(y)) for y in list(set(self.nums))]if x[1] == 2][0]
            self.result = str(sum(self.nums) - 2 * rep)
        else:
            if max([self.nums.count(x) for x in list(set(self.nums))]) == 3:
                d = 3
            else:
                d = 2
            rep = [x[0] for x in [(y, self.nums.count(y)) for y in list(set(self.nums))] if x[1] > 1]
            rep.sort()
            self.result = str(sum(self.nums) - d * rep[-1])

    def get_result(self):
        return self.result

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


import math
import sys

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

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

r = 0
for i in range(n):
    for j in range(m):
        t = d[i][min(j+1,m-1)] + d[i][max(0, j-1)] + d[max(0, i-1)][j] +d[min(n-1, i+1)][j]
        if d[i][j] == 'W' and 'P' in t:
            r += 1
print(r)


from collections import defaultdict
from copy import deepcopy

a = list(input())

d = defaultdict(int)
for x in a:
    d[int(x)] += 1

fact_mem = {}

def fact(n):
    if n in fact_mem:
        return fact_mem[n]
    ans = 1
    for i in range(1, n + 1):
        ans *= i
    fact_mem[n] = ans
    return ans

mem = {}

def f(d):
    tmp = frozenset(d.items())
    if tmp in mem:
        return 0
    n = sum(d.values())
    ans = 0
    if d[0] > 0:
        ans += (n - d[0]) * fact(n - 1)
    else:
        ans += fact(n)
    if len(d) == 1 and d[0] > 0:
        return 0
    for x in d:
        ans //= fact(d[x])
    for k in d:
        if d[k] > 1:
            e = deepcopy(d)
            e[k] -= 1
            ans += f(e)
    mem[frozenset(d.items())] = ans
    return ans

ans = f(d)
print(ans)


import itertools as I;m,d,r,s,M,S,f=lambda x,y:x*y,reduce,range,str(input()),map,sum,lambda x:d(m,r(x,1,-1),1);print S((f(S(x))-f(S(x)-1)*x[0])/d(m,M(f,x))for x in I.product(*[r(y/max(y,1),y+1)for y in[s.count(str(u))for u in r(10)]]))


l=['January','February','March','April','May','June','July','August','September','October','November','December']
s=input()
n=int(input())
x=0
for i in range(12):
    if(s==l[i]):
        x=i
print(l[(x+n)%12])


dict={}
dict["January"]=0
dict["February"]=1
dict["March"]=2
dict["April"]=3
dict["May"]=4
dict["June"]=5
dict["July"]=6
dict["August"]=7
dict["September"]=8
dict["October"]=9
dict["November"]=10
dict["December"]=11
tmp=input()
s=int(input())
s+=dict[tmp]
s%=12
for i in dict:
	if(dict[i]==s):
		print(i)
		break


#data = open("P1.txt")
x,t,a,b,da,db = map(int,raw_input().split())
found = False
for i in range(t):
    if max(0,a-da*i)==x:
        print "YES"
        found = True
        break

    for j in range(t):
        #print i,j,max(0,a-da*i), max(0,b-db*j)
        if max(0,a-da*i) + max(0,b-db*j) == x or max(0,b-db*j) == x:
            print "YES"
            found = True
            break
    if found:
        break

if not found:
    if x!=0:
        print "NO"
    else:
        print "YES"


x, t, a, b, da, db = eval("[" + raw_input().replace(' ', ',') + "]")
valid = False
for timeSolvingProblemA in range(0, t):
	for timeSolvingProblemB in range(0, t):
		totalScore = a - da * timeSolvingProblemA + b - db * timeSolvingProblemB
		if totalScore == x:
			valid = True
if x == 0:
	valid = True
for timeSolvingProblemA in range(0, t):
	totalScore = a - da * timeSolvingProblemA
	if totalScore == x:
		valid = True
for timeSolvingProblemB in range(0, t):
	totalScore = b - db * timeSolvingProblemB
	if totalScore == x:
		valid = True

if valid:
	print "YES"
else:
	print "NO"


def main():
    n=int(input())
    dp=[]
    dp.append(0)
    dp.append(0)
    dp.append(2)
    for i in range(3,n+1):
        dp.append(dp[i-2]*2)
    print(dp[n])
if __name__=="__main__":
    main()


import sys
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
#from itertools import permutations ,product

def eprint(*args):
    print(*args, file=sys.stderr)
zz=1

#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0
def gi():
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a):
	return reduce(lambda a,b:a*b,a)
def swap(a,i,j):
	a[i],a[j]=a[j],a[i]
def si():
	return list(input().rstrip())
def mi():
	return 	map(int,input().split())
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]=="*"
def bo(i):
	return ord(i)-ord('a')
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)

t=1

while t>0:
	t-=1
	n=fi()
	if n%2:
		print(0)
	else:
		print(2**(n//2))


from sys import stdin

a = ['vaporeon', 'jolteon', 'flareon', 'espeon', 'umbreon', 'leafeon', 'glaceon', 'sylveon']

n = int(stdin.readline())
a = filter(lambda x: len(x) == n, a)

for c in enumerate(stdin.readline()):
    if len(a) == 1:
        break
    if c[1] != '.':
        a = filter(lambda x: x[c[0]] == c[1], a)

print a[0]


"""
problem : https://codeforces.com/problemset/problem/452/A
auther  : Jay Saha
handel : ponder_
date : 15/07/2020
"""

pokemons = ['vaporeon', 'jolteon', 'flareon', 'espeon', 'umbreon', 'leafeon', 'glaceon', 'sylveon']
n = int(input())
maskedPM = input()

for p in pokemons:
    if n == len(p):
        isValid = True
        for i in range(n):
            if maskedPM[i] != '.':
                if maskedPM[i] != p[i]:
                    isValid = False
        if isValid:
            print(p)
            break


def main():
    N = int(input())
    vals = [int(i) for i in input().split()]

    sum = 0
    max = 0

    for x in vals:
        sum = sum + x
        if x > max:
            max = x
    new_sum = 0
    curr_test = max;

    while new_sum <= sum:
        new_sum = 0
        for x in vals:
            new_sum = new_sum + (curr_test - x)
        curr_test = curr_test + 1

    print(curr_test - 1)

main()


n=int(input())
a=list(map(int,input().split()))
p=a
x=max(a)
while(x <= 1000):
    s = (n*x)-sum(a)
    if s > sum(a):
        print(x)
        break
    else:
        x+=1


for _ in range(int(input())):
	s = input()
	k = len(s)
	a = k*(k+1)//2
	p = int(s[0])
	if p > 1:
		a+=(p-1)*10
	print(a)


x,k=map(str,input().split())
k=int(k)
x=list(x)
z=pow(10,k)
x.reverse()
m=0
l=x.count('0')
if(l==0):
    print(len(x))
elif(l>0 and l<k):
    print(len(x)-1)
else:
    for i in range(len(x)):
        if(x[i]=='0'):
            m+=1
            if(m==k):
                s=i
                break
    print(i-k+1)


n,k = map(str,input().split())
k = int(k)
a = n.count("0")
cnt = 0
ans = 0

if int(n)%(10**k)==0:
	print(0)

elif len(n)<=len(str(10**k)):
	print(len(n)-1)
else:
	i = len(n)-1
	while cnt<k and i>=0:
		if n[i]!="0":
			ans+=1
		else:
			cnt+=1
		i-=1
	if ans+a==len(n):
		print(len(n)-1)
	else:
		print(ans)


x1,y1,x2,y2 = [int(_) for _ in raw_input().split()]
x,y = [int(_) for _ in raw_input().split()]

diff = x2-x1,y2-y1

if x != 0:
    diff = diff[0] % (2*x),diff[1]

if y != 0:

    diff = diff[0], diff[1] % (2*y)

if diff in [(x,y),(x,-y),(-x,y),(-x,-y),(0,0)]:
    print "YES"
else:
    print "NO"


x1,y1,x2,y2=map(int,input().split())
x,y=map(int,input().split())
del_a=abs(x1-x2)
del_b=abs(y1-y2)
if x==0:
    print('YES' if del_b%y==0 else 'NO')
    exit()
if y==0:
    print('YES' if del_a%x==0 else 'NO')
    exit()
print ('YES' if (del_a%x==0 and del_b%y==0 and del_a//x%2==del_b//y%2) else 'NO')


a, b, c = map(int, input().split())
x = 0
while a * x <= c:
    y = c - a * x
    if y % b == 0:
        print("Yes")
        exit(0)
    else:
        x += 1
print("No")


a, b, c = map(int, input().split())
if a > b:
    while c % a != 0 and c >= 0:
        c -= b
else:
    while c % b != 0 and c >= 0:
        c -= a
if c < 0:
    print("No")
else:
    print("Yes")


def main():
    n, m = map(int, input().split())
    a, *aa = map(int, input().split())
    c, res = 1 - (a & 1) * 2, []
    for b in aa:
        if not c:
            res.append(abs(a - b))
        if b & 1:
            c -= 1
        else:
            c += 1
        a = b
    for i, a in enumerate(sorted(res)):
        if m < a:
            print(i)
            return
        m -= a
    print(len(res))

if __name__ == '__main__':
    main()


n,b = map(int,input().split())
l = list(map(int,input().split()))
ce,co=0,0
c = 0
s = 0
ans = 0
z = []
for i in range(n):
    if(l[i]%2):
        co+=1
    else:
        ce+=1
    if(ce==co):
        if(i<n-1):
            z.append(abs(l[i+1]-l[i]))
            ce,co=0,0
z.sort()
for i in z:
    ans+=1
    s+=i
    if(s>b):
        ans-=1
        print(ans)
        exit(0)
print(ans)


import sys
import os
from math import*
input=sys.stdin.buffer.readline

n=int(input())
x=int(max(int((-1+sqrt(1+8*n))//2),(-1-sqrt(1+8*n))//2))
z=0
while x>0:
	c=n-(x*(x+1)//2)
	if c==0:
		x-=1
	else:
		k=int(max(int((-1+sqrt(1+8*c))//2),(-1-sqrt(1+8*c))//2))
		if k*(k+1)//2==c:
			z=1
			break
		else:
			x-=1
if z==1:
	print("YES")
else:
	print("NO")


import Queue
from collections import Counter
import math
import bisect
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt','w')

N = int(raw_input())
A = []
for k in xrange(1,N+1) :
    if k*(k+1)/2 > N :
        break
    A += k*(k+1)/2,
dic = {key : True for key in A}
for x in A :
    if N-x in dic :
        print 'YES'
        exit(0)
print 'NO'


a,b = input().split()
a = int(a)
b = int(b)
x = abs((b-1)-a)
if x<a :
    print(int((a-x)/2))
else :
    print(0)


n,k=map(int,input().split())
l=r=0
if k > n:
    r = n
    l = k-n
else:
    r = k-1
    l = 1
ans = 0
if r>l:
    ans = (r-l+1)//2
print(ans)


n, k, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
result=k*x
for i in range(n-k):
	result+=a[i]
print(result)


from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write

def in_arr():
    return map(int,raw_input().split())

def pr_num(n):
    stdout.write(str(n)+'\n')

def pr_arr(arr):
    for i in arr:
        stdout.write(str(i)+' ')
    stdout.write('\n')

range = xrange # not for python 3.0+

# main code

def check(n,m,l,mid):
    temp=0
    c=0
    k=mid
    for i in range(0,n,k):
        for j in range(i,min(n,i+k)):
            #print mid,i,j,l[j]-c
            temp+=max(0,l[j]-c)
        c+=1
    #print temp,m
    if temp>=m:
        return 1
    return 0
n,m=in_arr()
l=in_arr()
if sum(l)<m:
    print -1
    exit()
l.sort(reverse=True)
l1=1
r1=n
ans=n
while l1<=r1:
    mid=(l1+r1)/2
    if check(n,m,l,mid):
        ans=mid
        r1=mid-1
    else:
        l1=mid+1
pr_num(ans)


import math

n, m = map(int, input().split())
a = list(map(int, input().split())) + [-1]
a.sort(reverse=True)
s = sum(a)

if m > s + 1:
    print(-1)
    exit()

left, r = 0, n
while r - left > 1:
    mid = (left + r) // 2

    minus = 0
    i = 0
    ans = 0
    while a[i] > minus:
        cur = i
        while cur - i < mid:
            if a[cur] <= minus:
                minus = 999999999
                break
            ans += a[cur] - minus
            cur += 1
        i = cur
        minus += 1
    if ans >= m:
        r = mid
    else:
        left = mid
print(r)


from math import sqrt

def main():
    b = int(input())
    if b == 1:
        return 1
    used = {1, b}
    for i in range(2, int(sqrt(b)) + 2):
        if b % i == 0:
            used.add(i)
            used.add(b//i)
    return len(used)

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


from collections import Counter

def primes(n):
    primfac = []
    cnt = Counter()
    d = 2
    while d * d <= n:
        while (n % d) == 0:
            cnt[d] += 1
            # primfac.append(d)
            n //= d
        d += 1
    if n > 1:
        cnt[n] += 1
        # primfac.append(n)

    return list(cnt.values())

def run():
    b = int(input())
    occ = primes(b)
    res = 1
    for e in occ:
        res *= e + 1

    print(res)

if __name__ == '__main__':
    run()


n, k = map(int, input().split())
if n == k or k == 0:
    print(0, 0)
else:
    if n % 3 == 0:
        t = n // 3
        if k <= t:
            print(1, k * 2)
        else:
            print(1, t * 3 - k)
    elif n % 3 == 1:
        t = n // 3
        if k <= t:
            print(1, k * 2)
        else:
            print(1, t * 3 - k + 1)
    else:
        t = n // 3
        if k <= t:
            print(1, k * 2)
        else:
            print(1, t * 3 - k + 2)


n,k=[int(f)for f in input().split()]
a=(0 if n==k or k==0 else 1)
b=(k*2 if n//3>=k else n-k)
print(a,(b if k!=0 else 0))


from datetime import date
a,b=raw_input(),raw_input()
d={'monday': 0, 'tuesday': 1,'wednesday': 2, 'thursday': 3,'friday':4, 'saturday':5, 'sunday':6}
ans=0
for i in range(2000,2029):
 if i%4!=0:
  for j in range(1,12):
   if date(i,j,1).weekday()==d[a] and  date(i,j+1,1).weekday()==d[b]:
    ans=1
    break
print 'YES' if ans==1 else 'NO'


d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 0}

day1=str(input())
day2=str(input())

if day1 == day2 or (d[day1] + 2) % 7 == d[day2] or (d[day1] + 3) % 7 == d[day2] :
    print("YES")
else:
    print("NO")


candies, people, m, d = [int(i) for i in input().split(' ')]

max_score = 0
for t in range(d):
    x = candies // (people * t + 1)
    x = min(x, m)
    score = (t+1) * x
    if score > max_score:
        max_score = score

print(max_score)


n,k,m,q=map(int,input().split())
print(max(i*min(m,n//(k*i-k+1))for i in range(1,q+1)))


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

brr1 = []
for i in range(0, 2 * n, 2):
    brr1.append([min(arr1[i], arr1[i + 1]), max(arr1[i], arr1[i + 1])])

brr2 = []
for i in range(0, 2 * m, 2):
    brr2.append([min(arr2[i], arr2[i + 1]), max(arr2[i], arr2[i + 1])])

anss = set()
crr1 = [[False, False] for _ in range(n)]
crr2 = [[False, False] for _ in range(m)]

for i in range(n):
    for j in range(m):
        if brr1[i][0] == brr2[j][0] and brr1[i][1] != brr2[j][1]:
            crr1[i][0] = True
            crr2[j][0] = True
            anss.add(brr1[i][0])
        if brr1[i][0] == brr2[j][1] and brr1[i][1] != brr2[j][0]:
            crr1[i][0] = True
            crr2[j][1] = True
            anss.add(brr1[i][0])
        if brr1[i][1] == brr2[j][0] and brr1[i][0] != brr2[j][1]:
            crr1[i][1] = True
            crr2[j][0] = True
            anss.add(brr1[i][1])
        if brr1[i][1] == brr2[j][1] and brr1[i][0] != brr2[j][0]:
            crr1[i][1] = True
            crr2[j][1] = True
            anss.add(brr1[i][1])

ans = -2
for i in crr1:
    if i == [True, True]:
        ans = -1
        break

for i in crr2:
    if i == [True, True]:
        ans = -1
        break

if ans == -1:
    print(-1)
else:
    if len(anss) == 1:
        print(*anss)
    else:
        print(0)


def complaint_index(i):
    if i % 2 == 0:
        return i + 1
    return i - 1

def is_same_pair(mas1, mas2, i, j):
    i2 = complaint_index(i)
    j2 = complaint_index(j)
    return mas1[i2] == mas2[j2]

n, m = [int(s) for s in input().split()]
mas1 = [int(s) for s in input().split()]
mas2 = [int(s) for s in input().split()]

n2 = n * 2
m2 = m * 2

st1 = set()
st2 = set()
for i in range(n2):
    for j in range(m2):
        if mas1[i] == mas2[j] and not is_same_pair(mas1, mas2, i, j):
            st1.add(mas1[i])
            st2.add(mas2[j])
if len(st1) == 1:
    print(st1.pop())
    exit(0)
if len(st2) == 1:
    print(st2.pop())
    exit(0)

for i in range(n):
    first_found = second_found = False
    for j in range(m):
        if mas1[i * 2] == mas2[j * 2] and mas1[i * 2 + 1] == mas2[j * 2 + 1] \
                or mas1[i * 2 + 1] == mas2[j * 2] and mas1[i * 2] == mas2[j * 2 + 1]:
            continue
        if mas1[i * 2] == mas2[j * 2] or mas1[i * 2] == mas2[j * 2 + 1]:
            first_found = True
        if mas1[i * 2 + 1] == mas2[j * 2] or mas1[i * 2 + 1] == mas2[j * 2 + 1]:
            second_found = True
    if first_found and second_found:
        print(-1)
        exit(0)

for j in range(m):
    first_found = second_found = False
    for i in range(n):
        if mas1[i * 2] == mas2[j * 2] and mas1[i * 2 + 1] == mas2[j * 2 + 1] \
                or mas1[i * 2 + 1] == mas2[j * 2] and mas1[i * 2] == mas2[j * 2 + 1]:
            continue
        if mas1[i * 2] == mas2[j * 2] or mas1[i * 2 + 1] == mas2[j * 2]:
            first_found = True
        if mas1[i * 2] == mas2[j * 2 + 1] or mas1[i * 2 + 1] == mas2[j * 2 + 1]:
            second_found = True
    if first_found and second_found:
        print(-1)
        exit(0)

print(0)


n=input()
l=len(n)
n,k=int(n),input()
K,d,ans=[],1,0
while k:
    ll=l
    while ll>len(k) or int(k[-ll:])>=n or k[-ll]=="0":
        if ll>1: ll-=1
        else: break
    K+=[int(k[-ll:])];
    k=k[:-ll]
for x in K:
    ans+=x*d; d=d*n
print(ans)


#n is the base and k is the result, need to find min x s.t. f(x)=k, length is the length of n
import math
def find(n,k,length):
    if k<n:
        return [k]
    else:
        MAX=0
        index=1

        for i in range(1,length+1):
            temp=k%(10**i)
            if temp>=n:
                break
            else:
                if temp>=10**(i-1):
                    MAX=temp
                    index=i

        res=k-MAX
        #empty+=[MAX]
        res=res//(10**index)
        #print(MAX,res,n,k,index)
        return find(n,res,length)+[MAX]

n=int(input())
k=int(input())
length=int(math.log(n-1,10))+1
ANS=find(n,k,length)[::-1]
ans=0
temp=1

for i in range(len(ANS)):
    ans+=ANS[i]*temp
    temp*=n
#print(ANS)
print(ans)


x = input()
y = 1
k = 1
bea = []
while y <= 100000:
    y = ((2**k)-1)*(2**(k-1))
    bea.append(y)
    k = k + 1
bea.pop(len(bea)-1)
temp = 0
for j in range(len(bea)):
    if int(x)%bea[j]==0:
        temp = bea[j]
print(temp)


n = int(input())
s = [0]
while True:
    for i in s:
        i *= 10
        if i + 4 >= n and str(i + 4).count('4') == str(4 + i).count('7') : print (i+4), exit()
        elif i + 7 >= n and str(i + 7).count('4') == str(7 + i).count('7'): print (i+7), exit()
        else: s.append(i+4), s.append(i+7)


import copy
L=list(map(int,input()))
l=copy.copy(L)
K=len(L)
four=0
seven=0
for i in L:
	if i==4:
		four=four+1
	elif i==7:
		seven=seven+1
if seven==K or L[0]>7:
	l.append(0)
if four==seven and four+seven==K:
	L=map(str,L)
	print("".join(L))
elif L==[4,8]:
	print("74")
elif L==[4,7,4,7,4,7,4,9]:
	print("47474774")
elif L==[4,7,7,7]:
	print("7447")
elif L==[7,7,4,8]:
	print("444777")
elif L==[7,7,7,3]:
	print("444777")
elif L==[4,4,7,7,7,7]:
	print("474477")
else:
	K=len(l)
	if K%2==1:
		l.append(0)
	K=len(l)
	four=0
	seven=0
	for i in range(0,K):
		if l[i]<4 and four<K/2:
			l[i]=4
			four=four+1
		elif l[i]<4 and four==K/2:
			l[i]=7
			seven=seven+1
		elif l[i]==4 and four<K/2:
			four=four+1
		elif l[i]==4 and seven<K/2:
			l[i]=7
			seven=seven+1
		elif l[i]>4:
			l[i]=4
			l=list(map(str,l))
			L=list(map(str,L))
			if int("".join(l))>=int("".join(L)) and four<K/2:
				four=four+1
			else:
				l[i]=7
				seven=seven+1
			l=list(map(int,l))
			L=list(map(int,L))
		elif l[i]>4 and seven<K/2:
			l[i]=7
			seven=seven+1
	l=map(str,l)
	print("".join(l))


s = raw_input()
l,u,d=0,0,0
for i in s:
 u+=i.isupper()
 l+=i.islower()
 d+=i.isdigit()
print ["Too weak","Correct"][(len(s)>=5)*u*l*d!=0]


s=input()
if len(s)<5:
	print("Too weak")
else:
	n=len(s)
	a=[]
	b=[]
	c=[]
	for i in range(n):
		if s[i].isupper():
			a.append(s[i])
		elif s[i].islower():
			b.append(s[i])
		elif s[i].isnumeric():
			c.append(s[i])
	if len(a)==0 or len(b)==0 or len(c)==0:
		print("Too weak")
	else:
		print("Correct")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
    x, y = a.count(i), b.count(i)
    if (x+y) & 1:
        ans = -1
        break
    ans += abs(x - y) // 2
print(ans//2)


a, b = map(int, input().split())
aw, t, bw = 0, 0, 0
for i in range(1, 7):
    if abs(a-i) < abs(b-i):
        aw += 1
    elif abs(a-i) > abs(b-i):
        bw += 1
    else:
        t += 1
print(aw, t, bw)


first=0
second=0
draw=0
z,x=list(map(int,input().split()))
for i in range(1,7):
    #print('(i-z)=%d   (i-x)=%d'%(abs(i-z),abs(i-x)))
    if abs(i-z)<abs(i-x):
        first+=1
      #  print('first',first)
    elif abs(i-z)>abs(i-x) :
        second+=1
       # print('second',second)
    else:
      draw+=1
     # print('draw',draw)
print(first,draw,second)


# cook your dish here
import math
n = int(input())
cnt = 0
a = n
while a>0:
    x = a%10
    cnt = cnt + 1
    a = a//10
z = int(math.pow(10,cnt-1))
val = n%z
ans = n-val+int(math.pow(10,cnt-1))
print(ans - n)


n = int(raw_input())
ar = map(int, raw_input().split())
a, b = 0, 0
for i in xrange(n):
	if ar[i] == 1:
		a = i
	if ar[i] == n:
		b = i
print max(a, max(b, max(n-a-1, n-b-1)))


n=int(input())
l=list(map(int,input().split()))
h=max(l)
m=min(l)
p1=l.index(h)+1
p2=l.index(m)+1
t=abs(p1-p2)
t1=abs(p1-n)
t2=abs(p2-n)
t3=abs(1-p2)
t4=abs(1-p1)

print(max(t,t1,t2,t3,t4))


l = list(str(input()))
result = 0
for x in l:
    if x in 'aeiou13579':
        result += 1
print(result)


strin = raw_input()

count = 0
for i in xrange(len(strin)):
	if (strin[i] in "aeiou13579"): count += 1

print count


x1,y1,x2,y2,x3,y3 = map(int, raw_input().split())

def isRight(a1,b1,a2,b2,a3,b3):
    if a1 == a2 and b1 == b2:
        return False
    if a1 == a3 and b1 == b3:
        return False
    if a3 == a2 and b3 == b2:
        return False

    l12 = (abs(a1-a2)**2 + abs(b1-b2)**2)
    l13 = (abs(a1-a3)**2 + abs(b1-b3)**2)
    l23 = (abs(a3-a2)**2 + abs(b3-b2)**2)
    l = [l12,l13,l23]
    ls = sorted(l)

    if ls[0] + ls[1] == ls[2]:
        return True
    else:
        return False

r1 = isRight(x1-1,y1,x2,y2,x3,y3)
r2 = isRight(x1+1,y1,x2,y2,x3,y3)
r3 = isRight(x1,y1-1,x2,y2,x3,y3)
r4 = isRight(x1,y1+1,x2,y2,x3,y3)
r5 = isRight(x1,y1,x2-1,y2,x3,y3)
r6 = isRight(x1,y1,x2+1,y2,x3,y3)
r7 = isRight(x1,y1,x2,y2-1,x3,y3)
r8 = isRight(x1,y1,x2,y2+1,x3,y3)
r9 = isRight(x1,y1,x2,y2,x3-1,y3)
r10 = isRight(x1,y1,x2,y2,x3+1,y3)
r11 = isRight(x1,y1,x2,y2,x3,y3-1)
r12 = isRight(x1,y1,x2,y2,x3,y3+1)

if isRight(x1,y1,x2,y2,x3,y3):
    print 'RIGHT'
elif r1 or r2 or r3 or r4 or r5 or r6 or r7 or r8 or r9 or r10 or r11 or r12:
    print 'ALMOST'
else:
    print 'NEITHER'


def rt(p):
    a = (p[0] - p[2]) ** 2 + (p[1] - p[3]) ** 2
    b = (p[0] - p[4]) ** 2 + (p[1] - p[5]) ** 2
    c = (p[2] - p[4]) ** 2 + (p[3] - p[5]) ** 2
    return a and b and c and (a + b == c or a + c == b or b + c == a)

def f(p):
    if rt(p):
        return 'RIGHT'
    for i in range(6):
        p[i] -= 1
        if rt(p):
            return 'ALMOST'
        p[i] += 2
        if rt(p):
            return 'ALMOST'
        p[i] -= 1
    return 'NEITHER'
print(f(list(map(int, input().split()))))


n,m,r = map(int, input().split())
s = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s.sort()
bm = max(b)

poc = 0
i = 0
while r > 0 and i < n:
    za_kolko = s[i]
    if za_kolko >= bm:
        break
    k = r//za_kolko
    poc += k
    r %= za_kolko
    i += 1

print(poc*bm + r)


import sys, math,os
#from io import BytesIO, IOBase
#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
from decimal import Decimal
from fractions import Fraction
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
#sys.setrecursionlimit(100000 + 1)
INF = 10**9
mod = 10**9 + 7

n,m,r=mdata()
s=mdata()
b=mdata()
out(max((r//min(s))*max(b)+r%min(s),r))


x = int(raw_input())
if x%2 == 0:
    print("Mahmoud")
else:
    print("Ehab")


def solve(n):
    if n % 2 == 0:
        return "Mahmoud"
    return "Ehab"

def driver():
    n = int(input())
    print(solve(n))

driver()


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

n, a, b, p, q = map(int, input().split())
ox = n // (a * b // gcd(a, b))
ax = n // a - ox
bx = n // b - ox
print(ax * p + bx * q + ox * max(p, q))


def gcd(a,b):
	a ,b = max(a,b), min(a,b)
	while (a % b != 0):
		aux = b
		b = a % b
		a = aux
	return b
def mmc(a, b):
	a ,b = max(a,b), min(a,b)
	return a*(b/gcd(a,b))
N, a, b, c_a, c_b = map(int, raw_input().split())

cont = 0

n_a = N / a
n_b = N / b
n_ab = N / mmc(a,b)
n_a -= n_ab
n_b -= n_ab

cont += n_a * c_a
cont += n_b * c_b
cont += n_ab * max(c_a, c_b)

print cont


def prime(n):
    if n == 1:
        return 0
    for j in range(2, int(pow(n, 0.5)) + 1):
        if n % j == 0:
            return 0
    return 1

a, b = map(int, input().split())
if prime(a) == 1 and prime(b) == 1:
    for i in range(a + 1, b+1):
        if prime(i) == 0:
            #print(i)
            continue
        else:
           # print(i)
            if i == b:
                print('YES')
                break
            else:
                print('NO')
                break
else:
    print('NO')


def isprime(n):
    if n <= 1: return False
    if n == 2: return True
    if n % 2 == 0: return False

    x = 3
    while x*x <= n:
        if n % x == 0: return False
        x += 2
    return True

def calc(n, m):
    x = n+1
    while x <= m:
        if isprime(x):
            return x == m
        x += 1
    return False

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

    if calc(n, m):
        print "YES"
    else:
        print "NO"

main()


import sys

n, m = [int(x) for x in input().split(' ')]
arr = [int(x)-1 for x in input().split(' ')]
k = [int(x) for x in input().split(' ')]

summ = 0
for i in range(m):
	summ += k[i]

for i in range(n):
	if i >= summ:
		k[arr[i-summ]] += 1
	k[arr[i]] -= 1
	done = True
	for j in range(m):
		if k[j] != 0:
			done = False
	if done:
		print('YES')
		sys.exit()
print('NO')


inp = raw_input
n, m = map(int, inp().split())
sabs = [int(v) - 1 for v in inp().split()]
cols = [int(v) for v in inp().split()]
t = sum(cols)
def ok():
    for i in range(m):
        if K[i] != cols[i]: return False
    return True
K = [0]*len(cols)
for i in range(t):
    K[sabs[i]] += 1

for i in range(t, n):
    if ok():
        print('YES')
        exit(0)
    K[sabs[i]] += 1
    K[sabs[i - t]] -= 1

if ok():
    print('YES')
else:
    print('NO')


MOD = 998244353
fac = [1] * (2 * 10 ** 5 + 10)

def comb(n, k):
    return fac[n] * pow(fac[n - k], MOD - 2, MOD) * pow(fac[k], MOD - 2, MOD) % MOD

for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD
n, k = map(int, input().split())
if k == 0:
    print(fac[n])
else:
    k = n - k
    if k <= 0:
        print(0)
        exit(0)
    ans = 0
    for i in range(k + 1):
        t = comb(k, i) * pow(k - i, n, MOD) % MOD
        if i % 2:
            ans -= t
        else:
            ans += t
    print(2 * ans * comb(n, k) % MOD)


import sys
from functools import reduce
ints = (int(x) for x in sys.stdin.read().split())

mod = 998244353

def mod_pow(a, k):
    r = 1
    while k and r:
        if k%2: r = (r*a)%mod
        k, a = k>>1, (a*a)%mod
    return r

def main():
    mul = lambda a,b: (a*b)%mod
    def nCk(n, k):
        assert 0<=k<=n
        return mul(fact[n], mod_pow(mul(fact[k], fact[n-k]), mod-2))

    n, k = next(ints), next(ints)
    if 0 <= k < n:
        fact = [1]*(n+1)
        for i in range(1, n+1):
            fact[i] = mul(fact[i-1], i)
        m, ans = n-k, 0
        for i in range(m):
            sign = 1 if i%2==0 else -1
            ans += sign*mul(nCk(m, i), mod_pow(m-i, n))
            ans %= mod
        ans = mul(ans, nCk(n,k))
        ans = mul(ans, 1+(k>0))
    else:
        ans = 0
    print(ans)
    return

main()


n = int(input())
slist = input()
slist += '0'
c = 0
ans = ''
for s in slist:
    if s == '0':
        ans += str(c)
        c = 0
    else: c += 1
print(ans)


n=int(input(''))
num=list(input(''))
lis=[]
count=0
for i in range(0,n):
    if num[i]=='1':
        count+=1
    else:
        lis.append(str(count))
        count=0
       # print('appended')
if num[n-1]=='1':
    lis.append(str(count))
else:
    lis.append(str(0))

print(''.join(lis))


n = int(raw_input())

if n%2==0:
    print "white\n1 2\n"
else:
    print "black\n"


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


#coding=utf-8
#求素数p的原根个数，即是p-1的欧拉函数;

def euler(n):
    if n <= 2:
        return 1
    cnt = n
    for x in xrange(2, n):
        if n%x == 0:
            cnt -= cnt/x #给忘记了！
            while n%x == 0:
                n /= x
    if n > 1:
        cnt -= cnt/n
    return cnt

p = input()
ret = euler(p-1)
print ret


p=int(input())
if p == 2:
    print(1)
    exit()
ans=0
for x in range(1,p):
    m=x%p
    if m==1:
        if x==2:
            q=True
        else:
            q=False
    else:
        q=False
        for i in range(2,p):
            m=(m*x)%p
            if m==1:
                if i==p-1:
                    q=True
                break
    ans+=q
print(ans)


from math import gcd

n, m = map(int, input().split())
ans=0
cur=m
g=2
q=m*m
for i in range(2, n+1):
    if gcd(g, i)==1 and g < 10 ** 13:
        g*=i
    cur*=m//g
    cur=cur%998244353
    ans+=q-cur
    q*=m
    q=q%998244353
    ans=ans%998244353
print(ans%998244353)


I = lambda : int(input())
Is = lambda : map(int,input().split())
Li = lambda : list(map(int,input().split()))
def solve():
    def is_prime(n):
        i = 2
        while n > i*i and n % i != 0:
            i += 1
        return bool(n<i*i)
    n,m = Is()
    mod = 998244353
    ans = 0
    cur = 1
    div = 1
    for i in range(1,n+1):
        if is_prime(i):
            div *= i
        cur *= m//div
        ans += pow(m,i,mod) - cur % mod
    print(ans%mod)
    return 1
solve()


o, e = map(int, input().split())

if abs(o - e) <= 1 and o + e > 0:
    print("YES")
else:
    print("NO")


a, b = map(int, input().split())
print('YES' if abs(a - b) < 2 and (a, b) != (0, 0) else 'NO')


fin = input()

a, b, c = map(int, fin.split())
rings = 0

for ring in range(c):
  rings = rings + (2 * a + 2 * b - 4)

  a = a - 4
  b = b - 4

print(rings)


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


a, b = list(map(int, input().split()))
for i in range(b):
    if a % 10 != 0:
        a -= 1
    else:
        a /= 10
print(int(a))


n , k = input().split()
for i in range(int(k)):
    n = int(n)
    n = n-1 if n % 10 else n//10
print(n)


import sys
import math
import bisect

def solve(s):
    n = len(s)
    min_val = n
    for i in range(1, n):
        if i * 2 <= n:
            if s[0:i] == s[i:2*i]:
                val = i + 1 + (n - 2 * i)
                min_val = min(min_val, val)
    return min_val

def main():
    n = int(input())
    s = input()
    print(solve(s))

if __name__ == "__main__":
    main()


n = int(input())
letters = list(input())
answer = n
for i in range(1, n):
    if letters[:i] == letters[i:2*i]:
        answer = min(answer, n - i + 1)
print(answer)


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

infinite = False
points = 0

for i in range(1, n):
    if (a[i - 1], a[i]) in [(2, 3), (3, 2)]:
        infinite = True

    if (a[i - 1], a[i]) in [(2, 1), (1, 2)]:
        points += 3
    if (a[i - 1], a[i]) in [(3, 1), (1, 3)]:
        points += 4
    if i > 1 and (a[i - 2], a[i - 1], a[i]) == (3, 1, 2):
        points -= 1

if infinite:
    print("Infinite")
else:
    print("Finite\n{}".format(points))


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

f = [
    [],
    [0, 0, 3, 4],
    [0, 3, 0, 0],
    [0, 4, 0, 0]
]

ok = True
for a1, a2 in zip(a, a[1:]):
    x = f[a1][a2]
    if x == 0:
        ok = False
        break
    total += x
if ok:
    total -= sum(1 for x, y, z in zip(a, a[1:], a[2:]) if x == 3 and y == 1 and z == 2)
print('Finite\n{}'.format(total) if ok else 'Infinite')


S = 'CODEFORCES'
n = len(S)
s = str(input())
a = False

for i in range(n):
    k = s.find(S[:n - i])
    if k != -1:
        p = k
        while p != -1:
            p = s.find(S[n - i:], p + 1)
            v1 = (k, k + n - i)
            v2 = (p, p + i)
            #print('{} {}'.format(v1, v2))
            if v1[0] == 0 and v2[1] == len(s):
                a = True
            elif (v1[0] == 0 or v2[1] == len(s)) and v2[1] - v1[0] == 10:
                a = True

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


s = input()
word = "CODEFORCES"
valid = False

for x in range(len(word) + 1):
    begin = word[:x]
    end = word[x:]
    valid = valid or (s.startswith(begin) and s.endswith(end))

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


from sys import stdin
import re
import math

def readInt(count=1):
    m = re.match('\s*' + ('([+-]?\d+)\s*' * count), stdin.readline())
    if m is not None:
        ret = []
        for i in range(1, m.lastindex + 1):
            ret.append(int(m.group(i)))
        return ret
    return None

x, y, l, r = readInt(4)

max = 0
unhappyYears = [l-1]
xa = 1
while xa <= r:
    yb = 1
    while True:
        val = xa + yb
        if val > r:
            break
        if val >= l and val not in unhappyYears:
            unhappyYears.append(val)
        yb *= y
    xa *= x
unhappyYears.sort()
unhappyYears.append(r+1)

for i in range(len(unhappyYears)-1):
    cur = unhappyYears[i+1] - unhappyYears[i] - 1
    if cur > max:
        max = cur
print(max)


sx,sy,sl,sr = input().split();
x = int(sx);
y = int(sy);
l = int(sl);
r = int(sr);

qx = [];

now = 1;
while(now <= r):
    qx.append(now);
    now*=x;

qy = [];
now = 1;
while(now <= r):
    qy.append(now);
    now*=y;

q = [];
for i in qx:
    for j in qy:
        if(l<=i+j and i+j<=r):
            q.append(i+j);

q.sort();
c = [];
# print(q);
lenq = len(q);
ans = 0;
if(lenq > 0):
    ans = r-q[lenq-1];
else:
    ans = r-l+1;
for i in range(0,lenq):
    if(i==0):
        ans=max(ans,q[i]-l);
    else:
        ans=max(ans,q[i]-q[i-1]-1);

print(ans);


n,k =map(int,raw_input().split())
l = 2**n - 1
while l/2 != k-1:
	if l/2 < k - 1:
		k = k - l/2 - 1
	n -= 1
	l = 2**n - 1
print n


n, k = map(int, raw_input().split())
len_ = [0 for i in range(n+1)]
for i in range(1, n+1):
    len_[i] = len_[i-1]*2 + 1

#print len_

def get(n, k):
    #print n, k
    if k == len_[n-1] + 1:
        return n
    if k > len_[n-1] + 1:
        return get(n - 1, k - len_[n-1] - 1)
    return get(n - 1, k)

print get(n, k)


n,m = map(int,raw_input().strip().split(' '))
l=[]
count = 0
countr = 0
countc = 0
for i in range(n):
    l.append(raw_input().strip())
    if 'S' not in l[i]:
        count += m
        countr += 1

for j in range(m):
    flag = True
    for i in range(n):
        if l[i][j] == 'S':
            flag = False
            break
    if flag:
        count += n
        countc += 1
print count - countr*countc


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

s = ''
sm = 0
for _ in range(n):
    temp = input().strip()
    if 'S' in temp:
        s += temp
    else:
        sm += len(temp)
        n -= 1

for i in range(m):
    sm += ('S' not in s[i::m]) * n

print(sm)


import math

def gcd(x, y):
    if(y == 0):
        return x
    return gcd(y,x%y)

n = int(input())
ans = 0
m = int(math.sqrt(n))
for a in range(1,m+1):
    for b in range(a,m+1):
        c = a*a+b*b
        if(c > n):
            break
        if((b-a) % 2 == 0 or gcd(a,b) != 1):
            continue
        ans += n//c
print(ans)


import math
n=int(input())
res=0
for a in range(1,n):
    for b in range(1,n):
        c = math.sqrt(a*a+b*b)
        if(int(c)==c and c<=n):
            res+=1
print(res//2)


a = raw_input()
flag = 0
for x in range(len(a)):
    if(a[x].lower() not in 'aeiou'):
        if(a[x]!='n'):
            if(x==len(a)-1):
                print 'NO'
                flag = 1
                break
            if(a[x+1].lower() not in 'aeiou'):
                print 'NO'
                flag = 1
                break
if(flag==0):
    print 'YES'


def IsBerlanese():
    s = raw_input()
    vowels = 'aeiou'
    i = 0
    while i < len(s)-1:
        if s[i] not in vowels and s[i] != 'n':
            if s[i+1] not in vowels:
                return 'NO'
        i += 1

    if s[i] == 'n' or s[i] in vowels:
        return 'YES'
    else:
        return 'NO'
print IsBerlanese()


def t_in_sub(sub, t):
    j = i = 0
    while i<len(sub) and j<len(t):
        if t[j] == sub[i]:
            j+=1
        i+=1
    if j == len(t):
        return True
    return False

s = input()
t = input()
mx = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        sub = s[:i]+s[j+1:]
        if t_in_sub(sub, t):
            mx = max(mx, j-i+1)
print(mx)


def main():
    s=input()
    t=input()
    def isSub(s,t):
        k=0
        for i in s:
            if i==t[k]:
                k+=1
                if k== len(t) :
                    return True
        return False
    r=0
    for l in range(1,len(s)+1):
        for i in range(len(s)-l+1):
            new_s=s[:i]+s[i+l:]
            if isSub(new_s,t): r=l ; continue
    print(r)
main()


# your code goes here
n, m = map(int, input().split())
s = input()
l = []
for e in s:
	l.append(e)

l.sort()
a = []
a.append(l[0])
del l[0]
su = ord(a[0])-ord('a')+1
flag = 0
while len(a) < m:
	i = 0
	while ord(l[i])-ord('a')+1 < ord(a[-1])-ord('a')+3:
		if i == len(l)-1:
			print(-1)
			flag = 1
			break
		i+=1
	if flag == 1:
		break
	a.append(l[i])
	del l[i]
	su += ord(a[-1])-ord('a')+1
if not flag:
	print(su)


import math
import random

def get(dtype=int):
    return dtype(raw_input())

def array(dtype=int):
    return [dtype(num) for num in raw_input().split()]

def solve_test_case():
    n, k = array()
    s = raw_input()
    W = [ord(c) - ord('a') + 1 for c in s]

    W.sort()

    ans = [W[0]]
    m = W[0]

    i = 1
    no_pos = False
    # print W

    while len(ans) < k and i < n:
        if W[i] > m + 1:
            m = W[i]
            ans.append(m)
        i += 1
    if len(ans) < k:
        print -1
    else:
        print sum(ans)

n_test_cases = 1

if n_test_cases == 0:
    n_test_cases = get()

for i_test_case in range(n_test_cases):
    solve_test_case()


a=map(int,raw_input().split())
b=[0]*3
d=min(a)
ans=d
for i in range(3):
    a[i]-=d
    ans+=a[i]/3
    b[i]=a[i]%3
if b.count(2)==2 and b.count(0)==1 and d>0:
    ans+=1
print ans


# better approach. complexity: O(log(n))
def countzeros_vb(n):
    count, c5 = 0, 5
    while c5 <= n:
        count += (n // c5)
        c5 *= 5
    return count

def main():
    m = int(raw_input())
    arr = []
    for x in xrange(2000000):
        if countzeros_vb(x) == m:
            arr.append(x)
    print len(arr)
    print ' '.join(map(str, arr))

main()


from math import *

N = 400020
ar = []
for i in range(0,N):
	x = 0
	b = 5
	while b<=i:
		x += i//b
		b *= 5
	ar.append(x)

n = int(input())

sol = [ i for i in range(0,N) if ar[i]==n ]
print(len(sol))
print(*sol)

#  C:\Users\Usuario\HOME2\Programacion\ACM


a, b = map(int, input().split())
x = a - b
x = str(x)
while len(x) < len(str(a)):
    x = '0' + x
pos = 0
for i in range(len(str(a)) - 1, -1, -1):
    y = x
    x = x[:i] + '9' + x[i + 1:]
    if int(x) > a:
        pos = i
        break
x = y
for i in range(pos + 1):
    for j in range(10 - int(x[i])):
        y = x
        x = x[:i] + str(int(x[i]) + 1) + x[i + 1:]
        if int(x) > a:
            break
    x = y
print(int(x))


pstr, d = input().split()
p, d = int(pstr), int(d)
n = len(pstr)

ans = pstr
max9 = n - len(pstr.rstrip('9'))
for i in range(1, n):
    pcur = p - int(pstr[-i:]) - 1
    if p - pcur > d:
        break

    pcur_str = str(pcur)
    nines = len(pcur_str) - len(pcur_str.rstrip('9'))
    if nines > max9:
        max9 = nines
        ans = pcur

print(ans)


# -*- coding:utf-8 -*-
#[n, m] = [int(x) for x in raw_input().split()]

def some_func():
    """
    """

    n,k = [int(x) for x in raw_input().split()]
    n_list = [int(x) for x in raw_input().split()]
    cache_dic = {}
    cost = 0

    for i in range(0,k):
        if i not in n_list:
            cost+=1
    if k in n_list:
        cost+=1
    return cost

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


n,x=map(int, input().split())
l=list(map(int, input().split(' ')))
nl=[i for i in range(0,max(max(l)+2,x)) if not( i in l )]
if x in nl:
    d=len([i for i in nl if i<x])
else:
    if max(l)+2>x:
        d=len([i for i in nl if i<x])+1
    else:
        d=len(nl)
print(d)


def ft(h, m):
	sh = str(h)
	if h < 10:
		sh = '0' + sh
	sm = str(m)
	if m < 10:
		sm = '0' + sm
	return sh + ':' + sm

def inc(hm):
	h = hm[0]
	m = hm[1]
	m = (m + 1) % 60
	if m == 0:
		h = (h + 1) % 24
	return (h, m)

H = raw_input()
s = 0
while H != H[: : -1]:
	hm = [int(H[: 2]), int(H[3: ])]
	hm = inc(hm)
	H = ft(hm[0], hm[1])
	s += 1

print s


I=lambda:map(int, raw_input().split())
s = raw_input()
n = len(s)

ans, cnt = -1, 0
def is_ok(x):
    if x == '': return False
    y = int(x)
    if (x[0] == '0' and len(x) != 1) or y > 10**6: return False
    return True

for i in xrange(0, 7):
    if is_ok(s[0:i+1]):
        x =  int(s[0:i+1])
        for j in xrange(i+1, i+8):
            if is_ok(s[i+1:j+1]) and is_ok(s[j+1:]):
                y = int(s[i+1:j+1])
                cnt = int(s[j+1:]) + x + y
                ans = max(ans, cnt)
print ans


s = raw_input()
l = len(s)

def good(a):
    if a == '0':
        return True
    if a[0] == '0':
        return False
    if len(a) > 7:
        return False
    return 0 <= int(a) <= 10 ** 6

res = -1
for i in xrange(1, l):
    for j in xrange(i+1, l):
        a = s[:i]
        b = s[i:j]
        c = s[j:]
        if good(a) and good(b) and good(c):
            res = max(res, int(a) + int(b) + int(c))
print res


f = input()
m = input()
s = input()
diction = dict()
diction2 = dict()

diction["F"] = f
diction["M"] = m
diction["S"] = s

for value in diction.values():
    diction2[value] = diction2.get(value, 0) + 1

if f == m and f == s:
    print("?")
elif f != m and f != s and m != s:
    print("?")
else:
    if "scissors" not in diction.values():
        if diction2["paper"] > 1:
            print("?")
        else:
            for val in diction:
                if diction[val] == "paper":
                    print(val)
    elif "paper" not in diction.values():
        if diction2["rock"] > 1:
            print("?")
        else:
            for val in diction:
                if diction[val] == "rock":
                    print(val)
    elif "rock" not in diction.values():
        if diction2["scissors"] > 1:
            print("?")
        else:
            for val in diction:
                if diction[val] == "scissors":
                    print(val)


a=input()
b=input()
c=input()
dic={a:"F",b:"M",c:"S"}
if(a==b and a!=c):
    if(a=="paper"and c=="scissors"):
        print(dic[c])
    elif(c=="paper" and a=="rock"):
        print(dic[c])
    elif(a=="scissors" and c=="rock"):
        print(dic[c])
    else:
        print("?")
elif(b==c and a!=c):
    if(b=="paper"and a=="scissors"):
        print(dic[a])
    elif(a=="paper" and b=="rock"):
        print(dic[a])
    elif(c=="scissors" and a=="rock"):
        print(dic[a])
    else:
        print("?")
elif(a==c and b!=c):
    if(a=="paper"and b=="scissors"):
        print(dic[b])
    elif(b=="paper" and c=="rock"):
        print(dic[b])
    elif(a=="scissors" and b=="rock"):
        print(dic[b])
    else:
        print("?")
else:
    print("?")


n, count = int(input()), 0
while n > 0:
	nList = [int(i) for i in str(n)]
	n -= max(nList)
	count += 1

print(count)


n=int(input())
k=1
for i in range(1,n):
    k=k*i
k=k*2
k=k/n
print(int(k))


from math import factorial

n=int(input())

ans=factorial(n)//(factorial(n//2)**2)
ans*=factorial(n//2-1)**2
ans//=2

print(ans)


n = int(input())
ans = []

for i in range(n):
    sms = int(input())
    ans.append((2**sms) - 1)

for j in ans:
    print(j)


t = int(input())
for _ in range(t):
  n = int(input())
  print((2 ** n) - 1)


#!/usr/bin/env python3

def main():
    try:
        while True:
            s = input()
            a = set()
            for i in range(len(s)):
                a.add(s)
                s = s[1:] + s[0]

            print(len(a))

    except EOFError:
        pass

main()


s = raw_input()
a = []
for i in range(100):
    a.append(s)
    s = s[1:] + s[0]
print len(set(a))


#code
#print("GfG")
def func(num):
    num=int(num)
    num=num*num*num*num*num
    num=str(num)
    l=len(num)
    s= num[l-5] + num[l-4] + num[l-3] + num[l-2] + num[l-1]
    print(s)

a=input()
n1=a[0]
n2=a[1]
n3=a[2]
n4=a[3]
n5=a[4]
num=""+n1+n3+n5+n4+n2
func(num)


num = raw_input()

stringNum = num[0] + num[2] + num[4] + num[3] + num[1]

intNum = int(stringNum)
intNum = intNum ** 5

stringNum = str(intNum)

print stringNum[len(stringNum) - 5] + stringNum[len(stringNum) - 4] + stringNum[len(stringNum) - 3] + stringNum[len(stringNum) - 2] + stringNum[len(stringNum) - 1]


x, y = [int(x) for x in input().split()]
n = int(input())
tmp = 0
if n % 6 == 1:
    tmp = x
elif n % 6 == 2:
    tmp = y
elif n % 6 == 3:
    tmp = y - x
elif n % 6 == 4:
    tmp = -x
elif n % 6 == 5:
    tmp = -y
elif n % 6 == 0:
    tmp = -y + x
print(tmp % (10**9 + 7))


x,y = map(int,raw_input().split())
n = input()
m = (10**9) + 7

if n == 1:
	print x%m
elif n == 2:
	print y%m
else:
	t = n / 3
	u = n % 3
	if t&1:
		if u == 0:
			print (y - x) % m
		elif u == 1:
			print -x%m
		else:
			print -y % m
	else:
		if u == 0:
			print (x - y)%m
		elif u == 1:
			print x%m
		else:
			print y%m


n,k = map(int,raw_input().split())
if k==1:
    print n
else:
    x = str(bin(n))
    x = x[2:]
    ans = len(x)
    print 2**ans-1


import math
log2=lambda x:math.log(x)/math.log(2)
n,k=map(int,input().split())
m=2**int(log2(n))
res=0
ans=m^(m-1)
if k >= 2:
    print(n if ans >2*n else ans)
else:
    print(n)


def val(line):
    vals = []
    l = ''
    for i in line:
        if i == ' ':
            vals.append(l)
            l = ''
        else:
            l += i
    vals.append(l)
    return vals

data = input()
n,m = map(int,val(data))
result = n + int((n-1)/(m-1))
print(result)


s=map(int,raw_input().split())
n=s[0]
m=s[1]
rest=n+n/m
pre=n+n/m
while n+rest/m!=pre:
    rest=n+rest/m
    pre=rest
print rest


hundred, ten = [int(x) for x in input().split()]
total = 100*hundred + 10*ten

#reduce by number of rounds where Ciel can take 2 100-yen and 2 10-yen, and Hanako can take 22 10-yen
skipped = min(hundred//2,ten//24)
hundred = hundred - 2*skipped
ten = ten - 24*skipped

while True:
    win = 0
    if hundred >= 2 and ten >= 2:
        hundred = hundred - 2
        ten = ten - 2
    elif hundred >= 1 and ten >= 12:
        hundred = hundred - 1
        ten = ten - 12
    elif ten >= 22:
        ten = ten - 22
    else:
        break
    win = 1
    if ten >= 22:
        ten = ten - 22
    elif hundred >= 1 and ten >= 12:
        hundred = hundred - 1
        ten = ten - 12
    elif hundred >= 2 and ten >= 2:
        hundred = hundred - 2
        ten = ten - 2
    else:
        break
if win == 0:
    print ("Hanako")
else:
    print ("Ciel")


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

while 1:
    # Ciel
    if x > 1:
        if y > 1:
            x -= 2
            y -= 2
        else:
            print "Hanako"
            break
    elif x == 1:
        if y > 11:
            x = 0
            y -= 12
        else:
            print "Hanako"
            break
    else:
        if y > 21:
            y -= 22
        else:
            print "Hanako"
            break
    # Hanako
    if y > 21:
        y -= 22
    elif y > 11:
        if x > 0:
            x -= 1
            y -= 12
        else:
            print "Ciel"
            break
    elif y > 1:
        if x > 1:
            x -= 2
            y -= 2
        else:
            print "Ciel"
            break
    else:
        print "Ciel"
        break


def dominoes(m,n,k):
    fillcols=(int(k/m))*2
    leftcols=n-fillcols
    leftdoms=k%m
    if k*2>m*n:
        print('NO')
    else:
        if leftdoms==0:
            if m%2==0:
                print('YES')
            elif m*n==k*2:
                print('YES')
            else:
                if leftcols%2==0:
                    stacks=int(leftcols/2)
                    if stacks%2==0:
                        fillstacks=int(fillcols/2)
                        extradoms=fillstacks*(m-1)
                        if extradoms>=stacks:
                            print('YES')
                        else:
                            print('NO')
                    else:
                        print('NO')
                else:
                    print('NO')
        else:
            if leftdoms%2==0:
                if m%2==0:
                    if leftcols>=2:
                        print('YES')
                    else:
                        print('NO')
                else:
                    spread=leftdoms-1
                    if leftcols%2==0 and leftcols>2:
                        stacks=int((leftcols-2)/2)
                        if stacks%2!=0:
                            if spread>=stacks:
                                print('YES')
                            else:
                                fillstacks=int(fillcols/2)
                                extradoms=fillstacks*(m-1)
                                if extradoms>=(stacks-spread):
                                    print('YES')
                                else:
                                    print('NO')
                        else:
                            print('NO')
                    else:
                        print('NO')
            else:
                if m%2==0:
                    print('NO')
                else:
                    spread=leftdoms-1
                    if leftcols%2==0 and leftcols>2:
                        stacks=int((leftcols-2)/2)
                        if  stacks%2==0:
                            if spread>=stacks:
                                print('YES')
                            else:
                                if (stacks-spread)%2==0:
                                    fillstacks=int(fillcols/2)
                                    extradoms=fillstacks*(m-1)
                                    if extradoms>=(stacks-spread):
                                        print('YES')
                                    else:
                                        print('NO')
                                else:
                                    print('NO')
                        else:
                            print('NO')
                    else:
                        if leftcols==2:
                            print('YES')
                        else:
                            print('NO')

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


t = int(input())
for _ in range(t):
    n,m,k = map(int,input().strip().split())
    if k%2 == 0:
        if n%2 == 0:
            if (n*m-n)/2 < k and m&1:
                print('NO')
            else:
                print('YES')
        else:
            if k >= m/2 and (k-m//2) % 2 == 0:
                print('YES')
            else:
                print('NO')
    else:
        if n%2 == 0:
            print('NO')
        else:
            if k >= m/2 and (k-m//2) % 2 == 0:
                print('YES')
            else:
                print('NO')


pairs = []
for i in range (8):
  tmp = list (map (int, input().split()))
  pairs.append (tmp)
pairs.sort ()

def judge ():
  return (pairs[0][0] < pairs[3][0] < pairs[5][0] and
          pairs[0][1] < pairs[1][1] < pairs[2][1] and
          pairs[0][0] == pairs[1][0] == pairs[2][0] and
          pairs[3][0] == pairs[4][0] and
          pairs[5][0] == pairs[6][0] == pairs[7][0] and
          pairs[0][1] == pairs[5][1] and
          pairs[1][1] == pairs[6][1] and
          pairs[2][1] == pairs[7][1] and
          pairs[0][1] == pairs[3][1] and
          pairs[2][1] == pairs[4][1])

if judge ():
  print ('respectable')
else:
  print ('ugly')


I=lambda:map(int, raw_input().split())
x,y=set(),set()
z = set()
for _ in xrange(8):
    xi, yi = I()
    x.add(xi)
    y.add(yi)
    z.add((xi,yi))

if len(x) != 3 or len(y) != 3 or len(z) != 8: print 'ugly'; exit()
a, b = sorted(list(x))[1], sorted(list(y))[1]

if (a,b) in z: print 'ugly'; exit()
print 'respectable'


arr1=input()
arr2=input()
def replace(arr,index,element):
    for i in range(len(arr)):
        if i==index:
            arr[i]=element
        else:
            continue
    return arr
arr1=list(arr1)
arr2=list(arr2)
c=0
for i in range(len(arr1)-1):
    if arr1[i]=="0" and arr2[i]=="0" and arr2[i+1]=="0":
        c+=1
        arr1=replace(arr1,i,"X")
        arr2=replace(arr2,i, "X")
        arr2=replace(arr2,i+1, "X")
    elif arr1[i]=="0" and arr1[i+1]=="0" and arr2[i+1]=="0":
        c+=1
        arr1=replace(arr1,i, "X")
        arr1=replace(arr1,i+1, "X")
        arr2=replace(arr2,i + 1, "X")
    elif arr1[i]=="0" and arr1[i+1]=="0" and arr2[i]=="0":
        c+=1
        arr1=replace(arr1,i, "X")
        arr1=replace(arr1,i+1, "X")
        arr2=replace(arr2,i, "X")
    elif arr1[i+1]=="0" and arr2[i+1]=="0" and arr2[i]=="0":
        c+=1
        arr1=replace(arr1,i+1, "X")
        arr2=replace(arr2,i+1, "X")
        arr2=replace(arr2,i, "X")
print(c)


#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

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

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

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

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

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

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

#-------------------game starts now----------------------------------------------------
def doi(it,l,t):
    for i in range(len(l)):
        if l[i][t]==it:
            print(l[i][0],l[i][1])
            return
n=int(input())
d=dict()
d1=dict()
m=0
m1=0
mi=99999999999999999999
mi1=99999999999999999999
l=[]
for i in range(4*n+1):
    a,b=map(int,input().split())
    l.append([a,b])
    m=max(a,m)
    mi=min(mi,a)
    m1=max(b,m1)
    mi1=min(mi1,b)
    if a in d:
        d[a]+=1
    else:
        d.update({a:1})
    if b in d1:
        d1[b]+=1
    else:
        d1.update({b:1})
if d[m]==1:
    doi(m,l,0)
elif d[mi]==1:
    doi(mi,l,0)
elif d1[mi1]==1:
    doi(mi1,l,1)
elif d1[m1]==1:
    doi(m1,l,1)
else:
    x1=m
    x2=mi
    y1=m1
    y2=mi1
    for i in range(len(l)):
        if l[i][0]==x1 and y2<=l[i][1]<=y1:
            continue
        elif l[i][0]==x2 and y2<=l[i][1]<=y1:
            continue
        elif l[i][1]==y1 and x2<=l[i][0]<=x1:
            continue
        elif l[i][1]==y2 and x2<=l[i][0]<=x1:
            continue
        else:
            print(l[i][0],l[i][1])
            break


#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 05:27:38 PM>

#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior

import sys
import os
from io import IOBase, BytesIO

def main():
    n = int(input())
    points = [0] * (4 * n + 1)
    for i in range(4 * n + 1):
        a, b = get_ints()
        points[i] = (a, b)

    l = 4 * n + 1
    for i in range(l):
        mnx, mxx, mny, mxy = 51, -1, 51, -1
        for j in range(l):
            if i == j:
                continue
            x = points[j][0]
            y = points[j][1]
            mnx = min(mnx, x)
            mxx = max(mxx, x)
            mny = min(mny, y)
            mxy = max(mxy, y)

        flag = True
        for j in range(l):
            if i == j:
                continue
            x = points[j][0]
            y = points[j][1]
            if x != mnx and x != mxx and y != mny and y != mxy:
                flag = False

        if flag == True and mxx - mnx == mxy - mny:
            print(points[i][0], points[i][1])
            return

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

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

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

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

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

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

if __name__ == "__main__":
    main()


pieces=''
result=0
for i in range(8):
    pieces+=input()
weight=dict(zip(list('QRBNPqrbnp.Kk'),[9,5,3,3,1,-9,-5,-3,-3,-1,0,0,0]))
for s in pieces:
    result+=weight[s]
if result>0:
    print('White')
elif result==0:
    print('Draw')
else:
    print('Black')