The first line contains a single integer n (1 ≤ n ≤ 50) — the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the same and are between 1 to 20 inclusive.

NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible:   you guess the string in one question. The event's probability is ;  you guess the string in two questions. The event's probability is  ·  =  (as in this case the first question should ask about the position that is other than the third one);  you guess the string in three questions. The event's probability is  ·  ·  = ; Thus, the expected value is equal to In the second sample we need at most two questions as any pair of questions uniquely identifies the string. So the expected number of questions is .In the third sample whatever position we ask about in the first question, we immediately identify the string.

Print the single number — the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.

You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to guess which string was chosen by your friend. In order to guess what string your friend has chosen, you are allowed to ask him questions. Each question has the following form: «What character stands on position pos in the string you have chosen?» A string is considered guessed when the answers to the given questions uniquely identify the string. After the string is guessed, you stop asking questions. You do not have a particular strategy, so as each question you equiprobably ask about a position that hasn't been yet mentioned. Your task is to determine the expected number of questions needed to guess the string chosen by your friend.

Input:
2
aab
aac

Output: 2.000000000000

Output: 2.00000000000000000

Input:
3
aaA
aBa
Caa

Output: 1.666666666667

Output: 1.66666666666666652

Input:
3
aca
vac
wqq

Output: 1.00000000000000000

Output: 1.000000000000

Input:
10
aababbbaabaababababa
ababaababbabaaababbb
ababbababaaaaaabbbab
ababbbbabaabaaababaa
abbabbbaabbbbbbbaaba
baaabbabababbabbaaaa
bababbbbbbaaaabbaaba
babbaabaaabaaaabbaab
babbbaababaabbbbbaab
bbbbabaaababaabbabab

Output: 4.898647621739

Output: 4.89864762172811652

Output: 4.898647621728

Input:
10
aaabaabbbaaabbaabaab
aabaaaababbaaabbbbaa
aababaabbbbbabbbabbb
aababbbbababbabaaaab
abbbbbabbbbaababbbba
baaaaabbababaabaaaba
baaaababaabaabbbabbb
babbaaaaababbbbbbabb
babbbbbaaabbbabaabba
bbabbaaaabaabaabbaaa

Output: 4.297908015617

Output: 4.29790801561699354

Output: 4.297908015620

Input:
10
aaababaabaaaabbbaaba
aabbabbbabbbabbbbaab
abbabbbbabaaabbabbba
baabaabaababbababbaa
baabbaaabaaabaaababa
babaaabababbaabbaaba
babbabbbabbaababbbab
babbbabbababbababbaa
bbaaaaabaaaaaabababa
bbbaaabaaaaaaaaaabba

Output: 4.981978735918

Output: 4.98197873591836426

Output: 4.981978735935

Input:
10
adacdbbbcabadbcbbcbc
baaaadabaacbbdbddbcc
baabbdcacadcccddbdbc
babdaacddaabcbbbbdad
bcacaddcdaaaacaddabd
caddcadcbdbbdbcbbcdc
cbbddccdbdbaacdcadda
ccbcaacbcbdccbdadbda
dbccddcbddacdbacabac
dbdaabaacdddacdccccb

Output: 2.40745127808208315

Output: 2.407451278082

Input:
10
aabbbcbacaccbadabdcc
abdbbdacbdbdabdbacac
acacabbcbdaacccddbcb
bdbaaccbbdbddaadadda
bdcbdbdccddddcdbcaad
caacbcaabbbdadcbcada
ccbcdacdccdbadaaccad
cdaaddacbabddababbbd
cdadbabbcabccddcddab
dbacadbdbdabacdadbcc

Output: 2.47042569659442712

Output: 2.470425696594

Input:
10
abbabbbbbddddaabbacd
accacddbabbaddbaacaa
bcabaddadccbcabbbcca
cadadbbbcdaaddbdbccd
cbdccdbdbcbbdddbcccc
cdcbbcdaaacadcdacdcd
daacacadcdcbcbbcbcdb
dbcbbadaacaddadbcdca
dbccacbcbddbaaddbdac
dcbdadcacbdacabdcacb

Output: 2.60904759069619763

Output: 2.609047590696

Input:
50
aaaddddddcadbcdaacbb
aabddaacbdcccacbbcba
abaaacdbdccaacabaaad
abadbaabccababbabdaa
abbcbabccbdcbbbdddcc
abbddaaacbbdbbdacdbc
acabcdccadbdccccbbbc
acbabbabbaaabccbdcac
acbcdbbbdabbadcbbaab
accdbbcbaabcacbbbbca
adbaddddabdbcbaacadc
adbcccdaabcabbdddcbd
adcaaacaccdadaabdacc
addbadaabdddbacbadbd
baaadabbbcaacaadaddb
babcabbaaacbdbbdcadc
babdbccbabdadcadddda
bacdabdadcbdacaabbcc
bbbdabcdacbbbbbbbacd
bbcacdcddbadccccaccd
bccbdacabacaccdbdcba
bdadaadcbdcbbbcbccca
bdadacaccaccbdacddba
b...

Output: 3.67876224678314445

Output: 3.678762246783

Input:
50
aaaaabaaaababbbabbbb
aaaabaabaaababbaabab
aaaabbabbaabaaabaaaa
aaabbaabaaababbabbba
aaabbabbabaabbaaabbb
aabaaaaabbaaabbabaaa
aabaabababababbaabab
aababbaabababbbbbbbb
aababbbbbaabaababbaa
aabbaaaaabaaaaaaaaba
aabbaabbaabbbbbaaaab
aabbabaabbaaabaabaaa
aabbbbaaaaaabbaaabbb
aabbbbabbaaababaabaa
abaaaaabbabaabaababb
abaaabbaabaaaabbaaaa
ababaabababbaaabaaaa
abababaababaaabbbaab
abababbababbaaaabbab
ababbbbabbabbbababaa
abbaaabaaabaaaaabaab
abbaabbaaabbaaababba
abbaabbbaaabaaabbaaa
a...

Output: 7.003419663431

Output: 7.003419663411

Output: 7.00341966341192279

Input:
50
aaaabaaabbaababaaaaa
aaaababaabaabbaabbba
aaababaabbbabbbaaabb
aaabbbabbbababbaabba
aabaaaaabbbbbabbbaaa
aabaababbabaaabaabaa
aabaababbbaaabaaaaaa
aabaabbbbbaaabbbbaaa
aababbbbbbbaaaaaaaba
aabbababbbbbaaaaaaaa
aabbbabababaaaaabbab
abaaaabbaabaaabaabaa
abaabaaaabbbaaaaabbb
abaabbabbbabaabbbbbb
abaabbbaababbabababb
ababaabbbababbaabbbb
abababbababaabaabaaa
ababbabaaabbbaababaa
ababbbaaaababbaaaaaa
ababbbabbbbaabbbaaab
abbabbaabbaabbaabaaa
abbabbbbbbbabbbaaabb
abbbaabbbabbabbababb
a...

Output: 7.00571500068558883

Output: 7.005715000685

Output: 7.005715000708

Input:
50
baaaaaaaaaaaaaaaaaaa
caaaaaaaaaaaaaaaaaaa
daaaaaaaaaaaaaaaaaaa
abaaaaaaaaaaaaaaaaaa
acaaaaaaaaaaaaaaaaaa
adaaaaaaaaaaaaaaaaaa
aabaaaaaaaaaaaaaaaaa
aacaaaaaaaaaaaaaaaaa
aadaaaaaaaaaaaaaaaaa
aaabaaaaaaaaaaaaaaaa
aaacaaaaaaaaaaaaaaaa
aaadaaaaaaaaaaaaaaaa
aaaabaaaaaaaaaaaaaaa
aaaacaaaaaaaaaaaaaaa
aaaadaaaaaaaaaaaaaaa
aaaaabaaaaaaaaaaaaaa
aaaaacaaaaaaaaaaaaaa
aaaaadaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaacaaaaaaaaaaaaa
aaaaaadaaaaaaaaaaaaa
aaaaaaabaaaaaaaaaaaa
aaaaaaacaaaaaaaaaaaa
a...

Output: 10.500000000025

Output: 10.50000000000000000

Output: 10.500000000028

Input:
20
baaaaaaaaaaaaaaaaaaa
caaaaaaaaaaaaaaaaaaa
daaaaaaaaaaaaaaaaaaa
abaaaaaaaaaaaaaaaaaa
acaaaaaaaaaaaaaaaaaa
adaaaaaaaaaaaaaaaaaa
aabaaaaaaaaaaaaaaaaa
aacaaaaaaaaaaaaaaaaa
aadaaaaaaaaaaaaaaaaa
aaabaaaaaaaaaaaaaaaa
aaacaaaaaaaaaaaaaaaa
aaadaaaaaaaaaaaaaaaa
aaaabaaaaaaaaaaaaaaa
aaaacaaaaaaaaaaaaaaa
aaaadaaaaaaaaaaaaaaa
aaaaabaaaaaaaaaaaaaa
aaaaacaaaaaaaaaaaaaa
aaaaadaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaacaaaaaaaaaaaaa

Output: 10.500000000015

Output: 10.500000000034

Output: 10.50000000000000000

Input:
24
aaaabaabaa
aaaababbab
aaabbbbbbb
aababaabbb
aabbaaabbb
aabbababbb
aabbabbbab
aabbbabaaa
abaaaaaaab
abaaaaaabb
abaaababab
abaababbab
ababbababb
abbbbbabba
abbbbbabbb
baabaabbab
baabbabaaa
bababbaaab
babbabaaab
bbaaaaabba
bbaabaabab
bbaabbbbaa
bbabbabbba
bbbaabbbaa

Output: 5.844824735450

Output: 5.84482473544973491

Input:
3
babaa
babba
babbb

Output: 3.333333333333

Output: 3.33333333333333348

Input:
11
cwmqza
hdygxj
hrtbbf
hxwtbt
jehxcw
nvjnkw
ojdpns
pqrfrl
qaysyw
qjjley
sfalwu

Output: 1.28484848484848491

Output: 1.284848484848

Input:
15
cqnszqpotieb
epbaecjkieyq
fudzofjixmjq
gwuqheadamxd
hwshpkpwyduk
ispirvwmmusn
kkfdholfmsfj
obrknjnyakxl
plfsaiifzdmp
pmndkrpwrwuc
ppcfovxexyjf
qfsmqjuynwae
somjhldcpknl
uaqeohijawmv
ymhdnexcqdgd

Output: 1.48707070707070699

Output: 1.487070707071

Input:
10
asvcvlpnxdw
cxjpappgstb
fiusefywzcb
gbdgmhtbvnl
giocpvuwpwo
itriveehryt
jhaeiiwnmph
kspqzypxdrw
qeazxiswcsx
tbavepzdpqq

Output: 1.337575757576

Output: 1.33757575757575764

Input:
7
bszsfte
cvocmlk
kbyunlt
msdhlai
nwpqaki
sqxgvcy
zyqxaof

Output: 1.16326530612244894

Output: 1.163265306122

Input:
4
jow
qtu
wdy
wrf

Output: 1.16666666666666674

Output: 1.166666666667

Input:
1
asdsada

Output: 0.00000000000000000

Output: 0.000000000000

Output: 0

Input:
33
S
A
e
h
o
H
j
k
E
B
D
I
q
l
s
G
u
a
L
c
R
r
O
n
i
U
t
V
v
M
J
T
Y

Output: 1.00000000000000000

Output: 1.000000000000

Input:
50
mmXPthBaMZ
EDnLGnaERS
xWtbCjbjNS
NeXZeHRtWf
FeTyUerlIf
RCvxBVvUAU
QsfFLrWOcS
GGnlmDrMrT
VuKVuoLidq
gAciPlnyjF
RGCPHgdUWy
vXyGGCbGmd
DhVWxaaoPC
qUeNDbxogu
iQTqMeRBaQ
RXairTBXSf
wMBYikZuGN
nnEVeUArYv
DgEVZdFKlo
RGtjCRTCkF
RNyZyKDWKo
LbrXOgZypn
pFZXJmwNVX
BgUoNJloia
enUYYeXbKA
OAoPbPIwBu
KTCXPWmVhH
mLVXJiZKfj
RDajCBbrVo
CXcoFPJfPM
umZucYZard
ebAuqwywZi
hIAydFfqFi
gaiaAaQZGQ
uqTLBfQRop
LuIqqYGADn
iXftKtbldC
PjwUMNBTpT
QsFNAXntAY
NuWbepdlXe
qSDmoYiPON
qYFAnsCsdB
apO...

Output: 1.658777777778

Output: 1.65877777777777768

Input:
50
UzCwStMSNQYOuG
bvjLMusWQYkAYs
BXsipPQyobfffI
cowtgWghDbqRhW
LYfVeWMwKnXvGP
sGhKcRVtApeFTw
pthvmtSsvnRbfd
kdolOTSANpSuNq
MwBRVmpCGBYmjq
DjZrodPipDeGFS
QNVzpYTZeAShrI
XdaYMtqUwtJKgt
cyruNKvOPNhGep
oBClUcOGIgjifH
ewHVrgNUrVbIIn
AJrJnQAevUFbPB
iigxAfZPLNJQDV
gmLwyrrvDzvqve
rzppfMsOKXxryK
YWdwMAqBRPIoLn
lkXzLxaCkjwfUc
mzNFizRODluMUl
yGLTQoLjyOubGq
cHaaMBhMSMoJmv
uhkWxQKcnpyWGp
glPXvySGoYFGDm
qHxqCpxTnIrAVl
VpWcTsTaoCBOVG
NoKzzgVKjKJIft
IyHLGjQUXZysLV
HFDuQqPXMFuoOg
wMEIoGvKNcG...

Output: 1.597582417582

Output: 1.59758241758241759

Input:
45
vThY
dSut
WrpF
dtNn
tRfp
hBmf
QejB
RGKF
dsTW
OEVx
SJnO
QUBP
kjcM
MMTI
FUJN
EUbh
pJNS
SZGU
lStk
ruoX
hOpy
tnSQ
lLQr
wnPD
bPxG
qFDP
oatP
QLbF
zEIp
brjY
ubLI
LJfi
nGKb
XVbh
auGf
wtnD
BLED
yuzy
xlfj
kcNh
emVj
EDQB
oaua
EDuZ
yjqB

Output: 1.67037037037037028

Output: 1.670370370370

Input:
19
qcOgodgjYg
JxbYnOTons
mabvtsEjWM
LLIMsxeiRe
TzTegTNCjJ
ubWAXpiVpP
TqUhRNSmIW
HrrNXmGQhp
NDRGXYuZzz
nhGntpHcQt
fwyycsUtAH
UwDnsneZJJ
viBDNuozuo
wdaaoqCYFG
jeBQYtQOoI
QYuSQmQzsT
jDaNyKGjNo
AJNsSjyuKG
KmzPaRVkno

Output: 1.294152046784

Output: 1.29415204678362583

Input:
39
jreqpOJVqNHIoiDiywRS
YvZxlTiuRaSVXsubEXjo
JNIRZFvBrPttOYIlFqZK
ZbqvVVtsxmpucdALRQGV
qbgCDzGJoZMWLEFWBuQd
rhnOWdhdWKHfUdaazqbZ
zvrDxPPLMFQOsIfiILOb
ncYwYOpjeCjMrRoRIgFp
FkHvyCedPKXqkimrbYxA
gHxrxlnOKKRIjAfiLzIs
umRoEjLzJzFJpoNXfTxI
BGTpybDuzpPnNoBRkuys
tIEZgVJKbogDjlnlnELN
CoeWZzxJlbGHOnoikBYs
FDgkcCtTwISdIZsofKlJ
HNkdtGKlikBBJSGPOmCG
msmgCLAFPsZrWTnCNqDL
fOgoRRctCVIhngoQTwSH
gtRQYMcADfVbLrUStxpu
gQduJCZyYjwEIHhNuAcY
ZsOjbQdUOKdWGrwsjyWN
HmtgCZIadQtLoOpLPqyi
bKxjbxAlXwaYvshVyxrk
H...

Output: 1.55681511470985168

Output: 1.556815114710

Input:
49
iXrjIYlecexwsL
HOZgRAOtQDsuGX
dbodLbxqbdzbwh
VjHxueMvyrEvoF
PtKJlGJnlrVeDk
zeWpSoGgBfXtss
LmljDMuIpzlEBD
cmXkBCohRbKSUR
OvrvVDwfqXieiE
LbDpNvXnFbYKpp
YvsrUiUYwRhatn
xDwAfZVEThBeeP
mmPOezLZXGhewW
klZheOLDkDYCwG
rcVCctujROwWMQ
KRmqJAJCSmMBbp
MMTCtHCoNosCte
ZrvDsMjlqIBMTP
rPVjyFePXwpxYL
PJOhUDlDWigHpB
xKXMbHFChiLNeD
LlBvXazeGftQUL
xjeZiLwsSNmUcE
hbvuUtQdyHjiQU
sjmeOzCnxmyqMv
VOegVCmbUJrZbG
fmlHIyTkmMvBDt
GDKBgiBVungoQk
wLleHWQVOYwPqW
XSZByoBPOeVoGk
HyMHjmcyDbkbmv
dzPZHCTQjns...

Output: 1.65579318640543116

Output: 1.655793186405

Input:
48
nBSMnPAaUrzTCk
MbAMbmWvcbrUwi
GlfYDNlQMrCnuW
esHHXUVKJAdrrj
GAiZWooicbZwjG
qURonnGwNrZbFj
VQOWcUbIhAlcBy
kkSaHMUKXEqSSR
AmCBlBTNFxEBuZ
DPqVniUVPOJraB
WWCseqMGOyMoFM
OKBIQwooyiYOSP
xCGyTKQnEoLmZo
IjGuwnwsVLrYRD
EEUsVAxsPvpvWZ
jouNTvmHMcQzzb
hRgQLSNTbMlaMK
KJhibRMkMJprej
OWZaZaGRGvrYBe
RxoGrrZLvWgFCO
tQOiaYqjjbpmHu
DqSlmEOFfkiSNI
VZtHkYJGDLbMUa
DCdlCVSelLYiIz
euXZHwxWPIDbhz
OeHUathpdIFyBW
FODLoMbNNVEODW
HtDWTCsTYYwmFa
mniraJBhsHAADG
UIasoMaVhuHPkx
SpZiXtLeEFSgXl
hlcVcwZDBwL...

Output: 1.61801739926739918

Output: 1.618017399267

Input:
50
bXWtcBmBVIRw
uWdyiHhtcvmy
aVlSLdqfYXAW
DOjWAOHcxmgK
QLDoFFbsdSOY
wXVBHidEtKXF
csidwLILiEdj
emDLEnNQcDSq
uxCsButpcXgo
FbkrrPCAdogD
RQiMRbFIrpaB
dbXROCwnbsbk
nHBKZugJEwVr
ynfyzpqXntZq
vqYWHGljbxpu
fJtSjobjbEjh
msBIlIdAXeMr
pyYUlmXfCqmy
NUBJhmngNfTD
RGkXdirasrjH
fFkpLaBXNSJY
TNsoGusiPDMi
WERYyWVrNYEa
ycIrhUpcliAG
vnlLwOVLQaiV
aTvndZLbQfhK
AqFGjpaWyYuA
vCqwgGeZhrDh
SzLNdnmRZpPx
LAlQRaabUlKK
LlqkHTxkxucI
HPsmjrQHciwG
rYwWERfKPWnf
tBOMPGUIIyUh
iSnXHpDFZFKQ
fhKTdggytUCV
cmG...

Output: 1.63627272727272732

Output: 1.636272727273

Input:
50
moUKlQqxbU
yFyJgcCqYq
pyMQeHcQsM
aYzJNbSuPB
LhugLmGPdU
iHJNtPqWjL
rdlmkUemaO
luEiCnWreo
rGKMTcjDAq
RCImnlBCoW
nczwfTNJmO
dWMgcRwqHK
JDxfUfTyIR
QdfsRshQsB
hxHVKqXoVY
VyrHoOHLfD
LAuPcInRvG
QoLbBywrsv
beCCWEhrhk
jjFYSmEwok
HDHNUIxrtK
uvvEKxQEeF
vqwWlTtHff
hjsGDYQtQx
tuNhSUQgPs
dNWYNWRmJB
ZEeKYAWBCY
ZYljdsDkRi
MxOVAWKpoy
XJAnCWSvNv
mGQQAdimvU
JKGiGonvUy
PLEiXFknsg
UVeOByFrrq
sEOSAirKDa
pRbrMRWROW
JSfbPwGNmY
UhgerQKVOp
PqmOugeiuk
aJOnnQGKAQ
LWIGDoIVxI
jrmWTtQVAA
LPK...

Output: 1.675888888889

Output: 1.67588888888888898

Input:
50
ePVtBDx
RkVpqWq
AtGEEsp
CVZZKFN
HrMQEyg
PdOBnbg
RxFhCKy
ZTLVfSE
GvJJWKz
bSVOktq
WSAMBHZ
jxFjWxA
rzuVYvw
xEtEypB
QezKLlC
nNuzIfv
SURyQSG
MqEIRcd
SQXZLLU
hwGorru
QbfLDTG
xVJGFUJ
mYNpGhM
zsLrAkh
OOSMkqt
xmolSyn
qpeOMrT
AOCIKeP
zmlffah
bQPvphE
RqNRLjP
vKyDARc
HfoqOoK
RVlbbJj
YsFkKUI
KNuErHe
uIXhLvA
qyMKzRy
uNITbtP
XYNoVks
qrVmCEv
wWyZupe
AHUyEOi
hqeEKVj
vFglghw
syrkHwj
UwhhueN
JKuWsjD
ImfIYet
rvmiZRX

Output: 1.64952380952380939

Output: 1.649523809524

Input:
50
aNmZCJpoWmqrSezv
KzukGKxmsDcdtCuP
OgrLhWBnOKQETDPi
lsQgCPAnBbganIxy
amevTYiuBKhlhoGL
oMGyPtRzhQMUiMPn
jjASCWVNIkGmaXEI
QBVTlmQtqLihtRtT
FvCJbmLYIImdeHGw
ZejJMUbPPFdwklUo
AjlZXcKzGamtMLsy
JpTfiRftzgKhFxDc
qIfPZeifhqGvMUYO
TYLeyyKLxnsytzbD
zEQhfnXRILMoDtQn
jCRTfsPSLRXOgsFW
mYDkCrcKdUviEyuI
tDnWGVSPvDQHiIwO
WLbKRZfcaFDCCkrV
OURJcCKLZqgNpuCh
sDCOpzcLHHYnzJiJ
VqakzWtwTkZycEit
zJwZQhiRnxEdlAJO
tJmRsOVYDmpoNahK
GUzUyoKuIiRQIDDq
ODDiZcwqwJtKLyEC
ueQnPKzRnUWDibRX
VqakzyELRyJxKdBy
ONf...

Output: 1.63644047619047628

Output: 1.636440476190

Input:
49
jqoQlGavDXxxbd
HSIuNWNIsWezij
nuUlxHXnaYXKqB
ckPkGxWzOdOKvl
dGdLNEqDYtKTrZ
hPkjtbJinogLXi
jadfxoOWQrDePe
qwIvydnFRRUsdO
eVLHBsejpAmUwr
eYJYKuKVgtkVdh
RkvjjQeyCCHozQ
xknbHCotSKIzbW
rtvIcvcejhQqQN
FaEnYJJOLWHVfJ
gveZxFvNWoSQkC
iNDBwmLjRrdPMq
KoVGTAAxQTzAMm
VlXjOQhUBIGYEh
kMNiMZTqQvAcYN
sUudWAaqXRwyVS
idMalJIWhkUhuL
upfchoEHQfBveM
JEkTOtatJJAseZ
KiUfOSraDisTnG
kgulozKydHxXvf
DwTroUQnzpDbDl
bRNICbiQErTaId
kiFvQUuQtyFOhh
foPZBJzplHWLOK
nrEKZNHXHCVRrD
nbWAPwiwzoijWc
hOoqmLgFRwL...

Output: 1.590379008746

Output: 1.59037900874635563

Input:
2
heDCXMiiMXCUqNqqNwo
DgafURJPWkVNIACWBKu

Output: 1.00000000000000000

Output: 1.000000000000

Input:
1
lFPbAVjsMpPDTLkfwNY

Output: 0.00000000000000000

Output: 0.000000000000

Output: 0

Input:
2
BPpZFsncqYzmUWRCvTx
SciucXUsSkcJHaANwHq

Output: 1.00000000000000000

Output: 1.000000000000

Input:
2
wyPr
CeaC

Output: 1.00000000000000000

Output: 1.000000000000

Input:
2
MHpkDtWm
ZKCjIhTv

Output: 1.00000000000000000

Output: 1.000000000000

Input:
2
JgABqAJKnGHl
cZXaIRaZHGeW

Output: 1.083333333333

Output: 1.08333333333333326

Input:
5
bDvNF
ksFCQ
taBzv
RqUEY
qJUFa

Output: 1.08000000000000007

Output: 1.080000000000

Input:
4
C
g
Z
N

Output: 1.00000000000000000

Output: 1.000000000000

Input:
32
I
r
z
J
p
i
T
d
Z
n
R
h
V
s
P
q
A
O
e
G
K
C
w
S
U
b
B
F
f
y
g
c

Output: 1.000000000000

Output: 1.00000000000000000

Input:
30
x
D
g
S
R
U
A
H
M
k
t
Z
T
c
X
f
j
J
d
L
o
Q
K
Y
N
P
y
G
v
r

Output: 1.00000000000000000

Output: 1.000000000000

Input:
1
G

Output: 0.00000000000000000

Output: 0.000000000000

Output: 0

Input:
1
uZ

Output: 0.00000000000000000

Output: 0.000000000000

Output: 0

Input:
50
A
B
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

Output: 1.00000000000000000

Output: 1.000000000000

Input:
12
HPC
AMd
tNt
RDf
nMi
djh
zeJ
MkF
Jjx
quN
Wex
gkB

Output: 1.27777777777777768

Output: 1.277777777778

Input:
50
MObH
JXJU
YHGx
xuUZ
basA
ZuiR
zbpa
cOzg
UKal
iehD
ZNbN
lmLM
vwmc
Blbu
hhVp
evAO
dBVf
hFvw
ZdQJ
KWxo
vFVZ
NizE
kbGF
IIzJ
Zcmk
GfUi
HGVG
Ecdt
Sywt
hJyE
ppeu
ereu
jBva
mUqf
qTGX
mQbe
xOTg
PDpo
SLGg
UBLZ
TBXU
qdnR
jmNX
vUOg
HcUq
KwkD
Khtg
MfdA
bWOt
iSVS

Output: 1.67333333333333334

Output: 1.673333333333

Input:
1
x

Output: 0.00000000000000000

Output: 0.000000000000

Output: 0

Input:
50
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaac
aaaaaaaaaaaaaaaaaaad
aaaaaaaaaaaaaaaaaaae
aaaaaaaaaaaaaaaaaaaf
aaaaaaaaaaaaaaaaaaag
aaaaaaaaaaaaaaaaaaah
aaaaaaaaaaaaaaaaaaai
aaaaaaaaaaaaaaaaaaaj
aaaaaaaaaaaaaaaaaaak
aaaaaaaaaaaaaaaaaaal
aaaaaaaaaaaaaaaaaaam
aaaaaaaaaaaaaaaaaaan
aaaaaaaaaaaaaaaaaaao
aaaaaaaaaaaaaaaaaaap
aaaaaaaaaaaaaaaaaaaq
aaaaaaaaaaaaaaaaaaar
aaaaaaaaaaaaaaaaaaas
aaaaaaaaaaaaaaaaaaat
aaaaaaaaaaaaaaaaaaau
aaaaaaaaaaaaaaaaaaav
aaaaaaaaaaaaaaaaaaaw
a...

Output: 10.50000000000000000

Output: 10.500000000057

Output: 10.500000000010

Input:
2
saratovs
approach

Output: 1.00000000000000000

Output: 1.000000000000

Input:
4
hello
fromW
coppW
SGUWW

Output: 1.150000000000

Output: 1.14999999999999991

Input:
50
qwertyuiopasdfghjklq
qwertyuiopasdfghjklw
qwertyuiopasdfghjkle
qwertyuiopasdfghjklr
qwertyuiopasdfghjklt
qwertyuiopasdfghjkly
qwertyuiopasdfghjklu
qwertyuiopasdfghjkli
qwertyuiopasdfghjklo
qwertyuiopasdfghjklp
qwertyuiopasdfghjkla
qwertyuiopasdfghjkls
qwertyuiopasdfghjkld
qwertyuiopasdfghjklf
qwertyuiopasdfghjklg
qwertyuiopasdfghjklh
qwertyuiopasdfghjklj
qwertyuiopasdfghjklk
qwertyuiopasdfghjkll
qwertyuiopasdfghjklz
qwertyuiopasdfghjklx
qwertyuiopasdfghjklc
qwertyuiopasdfghjklv
q...

Output: 10.50000000000000000

Output: 10.500000000057

Output: 10.500000000010

Input:
50
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaac
aaaaaaaaaaaaaaaaaaad
aaaaaaaaaaaaaaaaaaae
aaaaaaaaaaaaaaaaaaaf
aaaaaaaaaaaaaaaaaaba
aaaaaaaaaaaaaaaaaaca
aaaaaaaaaaaaaaaaaada
aaaaaaaaaaaaaaaaaaea
aaaaaaaaaaaaaaaaaafa
aaaaaaaaaaaaaaaaabaa
aaaaaaaaaaaaaaaaacaa
aaaaaaaaaaaaaaaaadaa
aaaaaaaaaaaaaaaaaeaa
aaaaaaaaaaaaaaaaafaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaaacaaa
aaaaaaaaaaaaaaaadaaa
aaaaaaaaaaaaaaaaeaaa
aaaaaaaaaaaaaaaafaaa
aaaaaaaaaaaaaaabaaaa
aaaaaaaaaaaaaaacaaaa
a...

Output: 10.671818181838

Output: 10.671818181843

Output: 10.67181818181818187

Input:
50
phqghumeaylnlfdxfirc
vscxggbwkfnqduxwfnfo
zvsrtkjprepggxrpnrvy
stmwcysyycqpevikeffm
znimkkasvwsrenzkycxf
xtlsgypsfadpooefxzbc
oejuvpvaboygpoeylfpb
npljvrvipyamyehwqnqr
qpmxujjloovaowuxwhms
ncbxcoksfzkvatxdknly
jyhfixjswnkkufnuxxzr
zbmnmgqooketlyhnkoau
gzqrcddiuteiojwayyzp
vscmpsajlfvgubfaaovl
zylntrkdcpwsrtesjwhd
izcobzcnfwlqijtvdwvx
hrcbldvgylwgbusbmbor
xtlhcsmpxohgmgnkeufd
xotogbgxpeyanfetcuke
pzshkljugggekjdqzjen
pevqgxiepjsrdzjazujl
lchhbfqmkimwzobiwybx
duunfsksrsrtekmqdcyz
j...

Output: 1.943163054696

Output: 1.94316305469556250

Input:
50
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaac
aaaaaaaaaaaaaaaaaaad
aaaaaaaaaaaaaaaaaaae
aaaaaaaaaaaaaaaaaaaf
aaaaaaaaaaaaaaaaaaag
aaaaaaaaaaaaaaaaaaah
aaaaaaaaaaaaaaaaaaaj
aaaaaaaaaaaaaaaaaaak
aaaaaaaaaaaaaaaaaaal
aaaaaaaaaaaaaaaaaaam
aaaaaaaaaaaaaaaaaaan
aaaaaaaaaaaaaaaaaaao
aaaaaaaaaaaaaaaaaaap
aaaaaaaaaaaaaaaaaaaq
aaaaaaaaaaaaaaaaaaar
aaaaaaaaaaaaaaaaaaas
aaaaaaaaaaaaaaaaaaat
aaaaaaaaaaaaaaaaaaau
aaaaaaaaaaaaaaaaaaav
aaaaaaaaaaaaaaaaaaaw
aaaaaaaaaaaaaaaaaaax
a...

Output: 10.50000000000000000

Output: 10.500000000057

Output: 10.500000000010


The only line contains four positive integers cnt1, cnt2, x, y (1 ≤ cnt1, cnt2 < 109; cnt1 + cnt2 ≤ 109; 2 ≤ x < y ≤ 3·104) — the numbers that are described in the statement. It is guaranteed that numbers x, y are prime.

NoteIn the first sample you give the set of numbers {1, 3, 5} to the first friend and the set of numbers {2} to the second friend. Note that if you give set {1, 3, 5} to the first friend, then we cannot give any of the numbers 1, 3, 5 to the second friend. In the second sample you give the set of numbers {3} to the first friend, and the set of numbers {1, 2, 4} to the second friend. Thus, the answer to the problem is 4.

Print a single integer — the answer to the problem.

You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.In addition, the first friend does not like the numbers that are divisible without remainder by prime number x. The second one does not like the numbers that are divisible without remainder by prime number y. Of course, you're not going to present your friends numbers they don't like.Your task is to find such minimum number v, that you can form presents using numbers from a set 1, 2, ..., v. Of course you may choose not to present some numbers at all.A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.

Input: 3 1 2 3

Output: 5

Input: 1 3 2 3

Output: 4

Input: 916200 69682 2 3

Output: 1832399

Input: 808351 17767 433 509

Output: 826121

Input: 8851 901 20897 26183

Output: 9752

Input: 5099 2895 16273 29473

Output: 7994

Input: 5099 2895 16273 29473

Output: 7994

Input: 4969 694 293 2347

Output: 5663

Input: 683651932 161878530 2 5

Output: 1367303863

Input: 325832598 637961741 2 3

Output: 1156553206

Input: 999999999 1 2 3

Output: 1999999997

Input: 11006 976 6287 9007

Output: 11982

Input: 150064728 173287472 439 503

Output: 323353664

Input: 819712074 101394406 6173 7307

Output: 921106500

Input: 67462086 313228052 15131 29027

Output: 380690138

Input: 500000000 500000000 29983 29989

Output: 1000000001

Input: 500000000 500000000 2 3

Output: 1199999999

Input: 500000000 500000000 29959 29983

Output: 1000000001

Input: 999999999 1 29983 29989

Output: 1000033352

Input: 1 999999999 29983 29989

Output: 1000033345

Input: 1 999999999 2 3

Output: 1499999998

Input: 999999998 1 2 3

Output: 1999999995

Input: 999999998 2 2 3

Output: 1999999995

Input: 9999999 10000 29983 29989

Output: 10009999

Input: 1000 9999999 29983 29989

Output: 10000999

Input: 110 40 1567 7681

Output: 150

Input: 197 2 6361 18223

Output: 199

Input: 39 154 1033 18947

Output: 193

Input: 126 51 26249 29443

Output: 177

Input: 14 179 19699 29303

Output: 193

Input: 14797 3593 13147 13933

Output: 18390

Input: 782 5750 7079 23957

Output: 6532

Input: 10876 8828 12487 16607

Output: 19704

Input: 16860 2201 6427 23327

Output: 19061

Input: 4901 563 1997 15053

Output: 5464

Input: 1277613 596606 10427 29387

Output: 1874219

Input: 1513389 40825 5641 10009

Output: 1554214

Input: 1749165 72848 9743 20023

Output: 1822013

Input: 954386 580262 4993 15629

Output: 1534648

Input: 159606 875491 43 19121

Output: 1035098

Input: 139694297 21147406 8819 28499

Output: 160841703

Input: 26941620 135675892 4093 28979

Output: 162617513

Input: 9156260 174697920 8171 29863

Output: 183854180

Input: 191370899 1962652 3517 24023

Output: 193333553

Input: 78618222 88031575 28289 29023

Output: 166649797

Input: 1 1 2 3

Output: 2

Input: 1 2 2 3

Output: 3

Input: 1 2 29983 29989

Output: 3

Input: 1 1 29983 29989

Output: 2

Input: 2 1 2 3

Output: 3


The first line contains two integers a and m (1 ≤ a, m ≤ 105).

Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No".

One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce  (remainder after dividing x by m) more details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory. The board of directors are worried that the production by the given plan may eventually stop (that means that there will be а moment when the current number of details on the factory is divisible by m). Given the number of details a on the first day and number m check if the production stops at some moment.

Input: 1 5

Output: No

Input: 3 6

Output: Yes

Input: 1 8

Output: Yes

Input: 2 3

Output: No

Input: 3 24

Output: Yes

Input: 1 1

Output: Yes

Input: 100000 100000

Output: Yes

Input: 1 99989

Output: No

Input: 512 2

Output: Yes

Input: 100 24

Output: No

Input: 1 100000

Output: No

Input: 100000 1

Output: Yes

Input: 3 99929

Output: No

Input: 99961 99971

Output: No

Input: 1 65536

Output: Yes

Input: 4 65536

Output: Yes

Input: 3 65536

Output: Yes

Input: 32768 65536

Output: Yes

Input: 65535 65536

Output: Yes

Input: 1 65535

Output: No

Input: 98812 100000

Output: No

Input: 10 5

Output: Yes

Input: 6 8

Output: Yes


The single line contains the positive integer n (1 ≤ n ≤ 1015).

Notef(4) =  - 1 + 2 - 3 + 4 = 2f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3

For a positive integer n let's define a function f:f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n.


The only line of input contains an integer a ( - 109 ≤ a ≤ 109).

NoteFor the first sample, he has to arrive at the floor numbered 180.For the second sample, he will arrive at 8.Note that b should be positive, so the answer for the third sample is 10, not 0.

Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from  - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor  - 1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view. In Cyberland, it is believed that the number "8" is a lucky number (that's why Giga Tower has 8 888 888 888 floors above the ground), and, an integer is lucky, if and only if its decimal notation contains at least one digit "8". For example, 8,  - 180, 808 are all lucky while 42,  - 10 are not. In the Giga Tower, if you write code at a floor with lucky floor number, good luck will always be with you (Well, this round is #278, also lucky, huh?).Tourist Henry goes to the tower to seek good luck. Now he is at the floor numbered a. He wants to find the minimum positive integer b, such that, if he walks b floors higher, he will arrive at a floor with a lucky number.


The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the length and the sum of the digits of the required numbers.

In the output print the pair of the required non-negative integer numbers — first the minimum possible number, then — the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).

You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

Input: 2 15

Output: 69 96

Input: 3 0

Output: -1 -1

Input: 2 1

Output: 10 10

Input: 3 10

Output: 109 910

Input: 100 100

Input: 1 900

Output: -1 -1

Input: 1 9

Output: 9 9

Input: 1 0

Output: 0 0

Input: 1 1

Output: 1 1

Input: 1 2

Output: 2 2

Input: 1 8

Output: 8 8

Input: 1 10

Output: -1 -1

Input: 1 11

Output: -1 -1

Input: 2 0

Output: -1 -1

Input: 2 2

Output: 11 20

Input: 2 8

Output: 17 80

Input: 2 10

Output: 19 91

Input: 2 11

Output: 29 92

Input: 2 16

Output: 79 97

Input: 2 17

Output: 89 98

Input: 2 18

Output: 99 99

Input: 2 19

Output: -1 -1

Input: 2 20

Output: -1 -1

Input: 2 900

Output: -1 -1

Input: 3 1

Output: 100 100

Input: 3 2

Output: 101 200

Input: 3 3

Output: 102 300

Input: 3 9

Output: 108 900

Input: 3 20

Output: 299 992

Input: 3 21

Output: 399 993

Input: 3 26

Output: 899 998

Input: 3 27

Output: 999 999

Input: 3 28

Output: -1 -1

Input: 3 100

Output: -1 -1

Input: 100 0

Output: -1 -1

Input: 100 1

Input: 100 2

Input: 100 9

Input: 100 10

Input: 100 11

Input: 100 296

Input: 100 297

Input: 100 298

Input: 100 299

Input: 100 300

Input: 100 301

Input: 100 895

Input: 100 896

Input: 100 897

Input: 100 898

Input: 100 899

Input: 100 900

Input: 99 900

Output: -1 -1

Input: 99 891

Output: 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

Input: 99 892

Output: -1 -1

Input: 96 364

Output: 100000000000000000000000000000000000000000000000000000039999999999999999999999999999999999999999 999999999999999999999999999999999999999940000000000000000000000000000000000000000000000000000000

Input: 97 206

Output: 1000000000000000000000000000000000000000000000000000000000000000000000000079999999999999999999999 9999999999999999999999800000000000000000000000000000000000000000000000000000000000000000000000000

Input: 98 250

Output: 10000000000000000000000000000000000000000000000000000000000000000000006999999999999999999999999999 99999999999999999999999999970000000000000000000000000000000000000000000000000000000000000000000000

Input: 99 96

Output: 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000059999999999 999999999960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Input: 100 215

Input: 5 18

Output: 10089 99000


The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Print the maximum possible height of the pyramid in the single line.

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.


The only line of input contains exactly two digits representing number n (0 ≤ n ≤ 99). Note that n may have a leading zero.

NoteIn the first sample the counter may be supposed to show 88 or 89.In the second sample the good integers are 00, 08, 80 and 88.In the third sample the good integers are 03, 08, 09, 33, 38, 39, 73, 78, 79, 83, 88, 89, 93, 98, 99.

In the only line of the output print the number of good integers.

Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks by turning them on or off. The picture below shows how the elevator shows each digit.One day when Malek wanted to go from floor 88 to floor 0 using the elevator he noticed that the counter shows number 89 instead of 88. Then when the elevator started moving the number on the counter changed to 87. After a little thinking Malek came to the conclusion that there is only one explanation for this: One of the sticks of the counter was broken. Later that day Malek was thinking about the broken stick and suddenly he came up with the following problem.Suppose the digital counter is showing number n. Malek calls an integer x (0 ≤ x ≤ 99) good if it's possible that the digital counter was supposed to show x but because of some(possibly none) broken sticks it's showing n instead. Malek wants to know number of good integers for a specific n. So you must write a program that calculates this number. Please note that the counter always shows two digits.


In the only line of the input two space-separated integers a and b (0 ≤ a, b ≤ 109) are given.

NoteIn the first sample the answers of the Modular Equation are 8 and 16 since

If there is an infinite number of answers to our equation, print "infinity" (without the quotes). Otherwise print the number of solutions of the Modular Equation .

Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by . A Modular Equation, as Hamed's teacher described, is an equation of the form  in which a and b are two non-negative integers and x is a variable. We call a positive integer x for which  a solution of our equation.Hamed didn't pay much attention to the class since he was watching a movie. He only managed to understand the definitions of these equations.Now he wants to write his math exercises but since he has no idea how to do that, he asked you for help. He has told you all he knows about Modular Equations and asked you to write a program which given two numbers a and b determines how many answers the Modular Equation  has.

Input: 21 5

Output: 2

Input: 9435152 272

Output: 282

Input: 10 10

Output: infinity

Input: 0 1000000000

Output: 0

Input: 11 2

Output: 2

Input: 1 0

Output: 1

Input: 0 0

Output: infinity

Input: 121 0

Output: 3

Input: 772930485 686893955

Output: 0

Input: 257424 24

Output: 127

Input: 295138437 589952171

Output: 0

Input: 223093836 966

Output: 399

Input: 233758336 10665466

Output: 13

Input: 223092887 17

Output: 500

Input: 223094728 1858

Output: 371

Input: 223092899 29

Output: 495

Input: 997920 0

Output: 240

Input: 887043 3

Output: 213

Input: 124 24

Output: 3

Input: 982901 101

Output: 193

Input: 357987 35

Output: 45

Input: 954374 1030

Output: 32

Input: 49106 46

Output: 15

Input: 325508499 119510657

Output: 1

Input: 89768760 885778845

Output: 0

Input: 944387968 700818251

Output: 0

Input: 12 3

Output: 1

Input: 1000000000 1

Output: 19

Input: 923456789 3

Output: 14

Input: 1000000000 6

Output: 6

Input: 1000000000 333333300

Output: 2

Input: 5 2

Output: 1

Input: 1 10

Output: 0

Input: 15 3

Output: 3

Input: 2 0

Output: 2

Input: 77 75

Output: 0

Input: 1000000000 1000000000

Output: infinity


The first line contains a single integer n (3 ≤ n ≤ 100) — the number of holds. The next line contains n space-separated integers ai (1 ≤ ai ≤ 1000), where ai is the height where the hold number i hangs. The sequence ai is increasing (i.e. each element except for the first one is strictly larger than the previous one).

NoteIn the first sample you can remove only the second hold, then the sequence looks like (1, 6), the maximum difference of the neighboring elements equals 5.In the second test after removing every hold the difficulty equals 2.In the third test you can obtain sequences (1, 3, 7, 8), (1, 2, 7, 8), (1, 2, 3, 8), for which the difficulty is 4, 5 and 5, respectively. Thus, after removing the second element we obtain the optimal answer — 4.

Print a single number — the minimum difficulty of the track after removing a single hold.

Mike is trying rock climbing but he is awful at it. There are n holds on the wall, i-th hold is at height ai off the ground. Besides, let the sequence ai increase, that is, ai < ai + 1 for all i from 1 to n - 1; we will call such sequence a track. Mike thinks that the track a1, ..., an has difficulty . In other words, difficulty equals the maximum distance between two holds that are adjacent in height.Today Mike decided to cover the track with holds hanging on heights a1, ..., an. To make the problem harder, Mike decided to remove one hold, that is, remove one element of the sequence (for example, if we take the sequence (1, 2, 3, 4, 5) and remove the third element from it, we obtain the sequence (1, 2, 4, 5)). However, as Mike is awful at climbing, he wants the final difficulty (i.e. the maximum difference of heights between adjacent holds after removing the hold) to be as small as possible among all possible options of removing a hold. The first and last holds must stay at their positions.Help Mike determine the minimum difficulty of the track after removing one hold.

Input:
3
1 4 6

Output: 5

Input:
5
1 2 3 4 5

Output: 2

Input:
5
1 2 3 7 8

Output: 4

Input:
3
1 500 1000

Output: 999

Input:
10
1 2 3 4 5 6 7 8 9 10

Output: 2

Input:
10
1 4 9 16 25 36 49 64 81 100

Output: 19

Input:
10
300 315 325 338 350 365 379 391 404 416

Output: 23

Input:
15
87 89 91 92 93 95 97 99 101 103 105 107 109 111 112

Output: 2

Input:
60
3 5 7 8 15 16 18 21 24 26 40 41 43 47 48 49 50 51 52 54 55 60 62 71 74 84 85 89 91 96 406 407 409 412 417 420 423 424 428 431 432 433 436 441 445 446 447 455 458 467 469 471 472 475 480 485 492 493 497 500

Output: 310

Input:
3
159 282 405

Output: 246

Input:
81
6 7 22 23 27 38 40 56 59 71 72 78 80 83 86 92 95 96 101 122 125 127 130 134 154 169 170 171 172 174 177 182 184 187 195 197 210 211 217 223 241 249 252 253 256 261 265 269 274 277 291 292 297 298 299 300 302 318 338 348 351 353 381 386 387 397 409 410 419 420 428 430 453 460 461 473 478 493 494 500 741

Output: 241

Input:
10
218 300 388 448 535 629 680 740 836 925

Output: 111

Input:
100
6 16 26 36 46 56 66 76 86 96 106 116 126 136 146 156 166 176 186 196 206 216 226 236 246 256 266 276 286 296 306 316 326 336 346 356 366 376 386 396 406 416 426 436 446 456 466 476 486 496 506 516 526 536 546 556 566 576 586 596 606 616 626 636 646 656 666 676 686 696 706 716 726 736 746 756 766 776 786 796 806 816 826 836 846 856 866 876 886 896 906 916 926 936 946 956 966 976 986 996

Output: 20

Input:
100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000

Output: 901

Input:
100
1 9 15 17 28 29 30 31 32 46 48 49 52 56 62 77 82 85 90 91 94 101 102 109 111 113 116 118 124 125 131 132 136 138 139 143 145 158 161 162 165 167 171 173 175 177 179 183 189 196 801 802 804 806 817 819 827 830 837 840 842 846 850 855 858 862 863 866 869 870 878 881 883 884 896 898 899 901 904 906 908 909 910 911 912 917 923 924 925 935 939 943 945 956 963 964 965 972 976 978

Output: 605

Input:
100
2 43 47 49 50 57 59 67 74 98 901 903 904 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 938 939 940 942 943 944 945 946 947 948 949 950 952 953 954 956 957 958 959 960 961 962 963 965 966 967 968 969 970 971 972 973 974 975 976 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 998 999

Output: 803

Input:
72
178 186 196 209 217 226 236 248 260 273 281 291 300 309 322 331 343 357 366 377 389 399 409 419 429 442 450 459 469 477 491 501 512 524 534 548 557 568 582 593 602 616 630 643 652 660 670 679 693 707 715 728 737 750 759 768 776 789 797 807 815 827 837 849 863 873 881 890 901 910 920 932

Output: 17

Input:
38
1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Output: 54

Input:
28
1 38 75 112 149 186 223 260 297 334 371 408 445 482 519 556 593 630 667 704 741 778 815 852 889 926 963 1000

Output: 74


The first line contains two space-separated numbers n and k (1 ≤ n ≤ 1018, 2 ≤ k ≤ 30).

NoteIn the first sample the sequence ai looks as follows: (0, 1, 1, 0). All the possible subsequences are: (), (0), (0, 0), (0, 1), (0, 1, 0), (0, 1, 1), (0, 1, 1, 0), (1), (1, 0), (1, 1), (1, 1, 0).In the second sample the sequence ai looks as follows: (0, 1, 2, 3, 4, 5, 6). The subsequences of this sequence are exactly all increasing sequences formed from numbers from 0 to 6. It is easy to see that there are 27 = 128 such sequences.

In a single line print the answer to the problem modulo 109 + 7.

Assume that sk(n) equals the sum of digits of number n in the k-based notation. For example, s2(5) = s2(1012) = 1 + 0 + 1 = 2, s3(14) = s3(1123) = 1 + 1 + 2 = 4.The sequence of integers a0, ..., an - 1 is defined as . Your task is to calculate the number of distinct subsequences of sequence a0, ..., an - 1. Calculate the answer modulo 109 + 7.Sequence a1, ..., ak is called to be a subsequence of sequence b1, ..., bl, if there is a sequence of indices 1 ≤ i1 < ... < ik ≤ l, such that a1 = bi1, ..., ak = bik. In particular, an empty sequence (i.e. the sequence consisting of zero elements) is a subsequence of any sequence.

Input: 4 2

Output: 11

Input: 7 7

Output: 128

Input: 1 2

Output: 2

Input: 2 2

Output: 4

Input: 3 2

Output: 6

Input: 5 2

Output: 18

Input: 3 3

Output: 8

Input: 10 2

Output: 178

Input: 27 3

Output: 7213896

Input: 55 5

Output: 353678202

Input: 1000 2

Output: 354368607

Input: 1000000 10

Output: 870888788

Input: 1000000 30

Output: 969396889

Input: 1 30

Output: 2

Input: 100 27

Output: 146489612

Input: 1000000 2

Output: 580124744

Input: 1234567890 12

Output: 535368437

Input: 1000000000 10

Output: 834966988

Input: 999999999 10

Output: 62943439

Input: 777777777777 7

Output: 408853443

Input: 1823472938742 17

Output: 823618501

Input: 21611482313284249 26

Output: 385020011

Input: 50 5

Output: 189322900

Input: 505447028499293770 11

Output: 505893288

Input: 576460752303423488 2

Output: 954484180

Input: 576460752303423487 2

Output: 297600586

Input: 450283905890997363 3

Output: 311856393

Input: 168856464709124011 3

Output: 403340604

Input: 81919999999999999 20

Output: 922355374

Input: 76992917493894778 20

Output: 944567471

Input: 224112541259281123 5

Output: 183123095

Input: 733999678202108832 2

Output: 449747717

Input: 901353876296257880 2

Output: 231496046

Input: 319486697463445936 2

Output: 170014895

Input: 158470980967917057 17

Output: 372115426

Input: 1000000000000000000 2

Output: 213674229

Input: 1000000000000000000 3

Output: 606383439

Input: 1000000000000000000 4

Output: 991266056

Input: 1000000000000000000 5

Output: 288325951

Input: 1000000000000000000 6

Output: 297804220

Input: 1000000000000000000 7

Output: 945392817

Input: 1000000000000000000 8

Output: 156886437

Input: 1000000000000000000 9

Output: 580039863

Input: 1000000000000000000 10

Output: 22698384

Input: 1000000000000000000 15

Output: 559742553

Input: 1000000000000000000 29

Output: 455255152

Input: 1000000000000000000 30

Output: 224751546

Input: 999999999999999999 2

Output: 966710693

Input: 999999999999999999 3

Output: 542452697

Input: 999999999999999999 7

Output: 503812379

Input: 999999999999999999 10

Output: 967830217

Input: 999999999999999999 11

Output: 917915049

Input: 999999999999999999 29

Output: 367056089

Input: 999999999999999999 30

Output: 811438490

Input: 796676863618749899 19

Output: 669099434

Input: 900099654762154107 16

Output: 187704723

Input: 353989972219678213 18

Output: 416045847

Input: 531440999999999999 30

Output: 623214318

Input: 948401775311276715 25

Output: 876813022

Input: 353814783205469040 29

Output: 258212958


The single line of the input contains 7 numbers w1, w2, ..., w7 (0 ≤ wi ≤ 105). It is guaranteed that at least one of the wi's isn't equal to zero.

NoteAll the possible ways of painting the third sample are given below:

In the single line of the output display a single number — the answer to the problem modulo 109 + 7.

You are given a figure on a grid representing stairs consisting of 7 steps. The width of the stair on height i is wi squares. Formally, the figure is created by consecutively joining rectangles of size wi × i so that the wi sides lie on one straight line. Thus, for example, if all wi = 1, the figure will look like that (different colors represent different rectangles):  And if w = {5, 1, 0, 3, 0, 0, 1}, then it looks like that:  Find the number of ways to color some borders of the figure's inner squares so that no square had all four borders colored. The borders of the squares lying on the border of the figure should be considered painted. The ways that differ with the figure's rotation should be considered distinct.

Input: 0 1 0 0 0 0 0

Output: 1

Input: 0 2 0 0 0 0 0

Output: 7

Input: 1 1 1 0 0 0 0

Output: 9

Input: 5 1 0 3 0 0 1

Output: 411199181

Input: 1 0 0 0 0 0 0

Output: 0

Input: 0 0 0 0 0 0 1

Output: 8

Input: 100000 0 0 0 0 0 0

Output: 56182730

Input: 0 1 0 0 1 0 1

Output: 22919

Input: 0 1 0 1 0 1 0

Output: 3577

Input: 0 0 1 1 0 1 1

Output: 24194747

Input: 0 0 1 1 1 0 1

Output: 6847385

Input: 0 1 1 0 1 1 0

Output: 274197

Input: 0 1 0 0 0 0 1

Output: 61

Input: 2 9 1 4 8 10 0

Output: 558116421

Input: 8 6 0 8 10 10 5

Output: 905199207

Input: 6 8 1 9 10 1 10

Output: 940638354

Input: 8 10 0 3 1 5 9

Output: 86667542

Input: 10 0 6 6 6 5 3

Output: 674053733

Input: 8 6 7 0 3 8 8

Output: 794608861

Input: 53 91 91 47 65 70 40

Output: 955570466

Input: 66 100 11 81 19 55 96

Output: 806282508

Input: 44 8 21 71 7 29 40

Output: 639986260

Input: 22 18 6 93 51 70 18

Output: 473275942

Input: 68 16 16 83 74 44 41

Output: 919840330

Input: 13 93 26 73 18 29 18

Output: 969841570

Input: 610 733 623 505 595 316 299

Output: 502335618

Input: 711 437 970 279 610 924 660

Output: 422250703

Input: 812 761 936 52 245 158 12

Output: 823236381

Input: 913 474 893 827 268 773 754

Output: 904500124

Input: 394 798 239 974 284 1000 727

Output: 868715722

Input: 876 884 197 747 308 615 87

Output: 550075104

Input: 4378 6891 3337 4735 7196 5076 4509

Output: 396740014

Input: 9442 1550 839 7549 7902 6377 591

Output: 459254146

Input: 8821 6211 6590 770 8202 3769 4516

Output: 75140867

Input: 8200 870 4499 1833 659 3318 192

Output: 655121181

Input: 5421 5530 2001 5055 1365 2461 4117

Output: 113648169

Input: 2642 190 7752 7870 3823 2011 9793

Output: 818612801

Input: 24855 82667 4601 56243 9444 90804 11324

Output: 718330126

Input: 59122 75888 25928 75089 48529 93085 17189

Output: 658273774

Input: 69042 53044 47256 53523 52372 11430 39120

Output: 794436758

Input: 3309 70612 8996 7609 56216 89365 20639

Output: 29063799

Input: 37576 12526 5976 86044 95300 91646 2157

Output: 603356528

Input: 71843 30095 92064 4890 23490 34339 48435

Output: 337725955

Input: 65535 65535 65535 65535 65535 65535 65535

Output: 265270793

Input: 100000 100000 100000 100000 100000 100000 100000

Output: 722575602

Input: 100000 99999 100000 100000 100000 99999 100000

Output: 258172454

Input: 100000 99997 100000 99996 99998 100000 99999

Output: 914495724

Input: 98303 98303 98303 98303 98303 98303 98303

Output: 306934455

Input: 1 98303 98303 98303 98303 98303 98303

Output: 851265807

Input: 98303 98303 1 98303 98303 98303 98303

Output: 555597981


The first line contains integer n (1 ≤ n ≤ 100) — the number of segments on the level. Next line contains the scheme of the level represented as a string of n characters '*' and '.'.

NoteIn the first sample test you may perform a sequence of jumps through platforms 2, 5, 8, 11, 14.

If the level is good, print the word "yes" (without the quotes), otherwise print the word "no" (without the quotes).

In this problem you will meet the simplified model of game King of Thieves.In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way.  An interesting feature of the game is that you can design your own levels that will be available to other players. Let's consider the following simple design of a level.A dungeon consists of n segments located at a same vertical level, each segment is either a platform that character can stand on, or a pit with a trap that makes player lose if he falls into it. All segments have the same length, platforms on the scheme of the level are represented as '*' and pits are represented as '.'. One of things that affects speedrun characteristics of the level is a possibility to perform a series of consecutive jumps of the same length. More formally, when the character is on the platform number i1, he can make a sequence of jumps through the platforms i1 < i2 < ... < ik, if i2 - i1 = i3 - i2 = ... = ik - ik - 1. Of course, all segments i1, i2, ... ik should be exactly the platforms, not pits. Let's call a level to be good if you can perform a sequence of four jumps of the same length or in the other words there must be a sequence i1, i2, ..., i5, consisting of five platforms so that the intervals between consecutive platforms are of the same length. Given the scheme of the level, check if it is good.

Input:
16
.**.*..*.***.**.

Output: yes

Input:
11
.*.*...*.*.

Output: no

Input:
53
*.*.****.*.*......**....**.***.*.*.**.*.*.***...*..*.

Output: yes

Input:
71
**.**..*****.*.*.*.********.....*****.****.*..***...*.*.*.**.****.**.**

Output: yes

Input:
56
**.*..*...***.*.**.**..**.*.*.*.**...*.**.**....*...**..

Output: yes

Input:
64
***.*...*...*.***.....*.....**.*****.*.*...*..*.*..***..*...***.

Output: yes

Input:
41
*******....*..*.**..***.*...****.***.*...

Output: yes

Input:
99
.*..**..*..*..**...***.****.*...*....*****.....**..****.*..*....****..**..*****..*....**.*.**..**..

Output: yes

Input:
64
*.***...**...*..*...*....*..***.*.*.*.***.*.**...**.*.*.*..*....

Output: yes

Input:
89
..**..**..*.********....*.*****.**.****...*......*******..*.**.*****..*..****....*...**..

Output: yes

Input:
42
.*.*...*..**.****...****..*.*.***....**...

Output: yes

Input:
99
..*.*..**.*.*.******.*.*.**.**.**.*..**.*.*****..*.*.****.*....**....*****.....***..**....***.*.*.*

Output: yes

Input:
5
*****

Output: yes

Input:
10
.*.*.*.*.*

Output: yes

Input:
6
......

Output: no

Input:
11
.*.*.*.*...

Output: no

Input:
51
....****....*........*.*..**........*....****....*.

Output: no

Input:
98
.**..**.*****..***...*.**..*..*....*******..**....*.****.**.*.....*.**..***.**..***.*******..****.

Output: yes

Input:
45
.***..******....***..**..*.*.*.**..**..*.**..

Output: yes

Input:
67
..**.*...*.....****.***.**.*....***..***.*..***.....*******.....*.*

Output: yes

Input:
31
.******.**.**....*.*********...

Output: yes

Input:
97
...*..*...*******.*.**..**..******.*.*..*****.*...***.*.**.**.**..**.******.****.*.***.**..*...**

Output: yes

Input:
87
*..*..***.**.*...****...*....***....***......*..*.*.*****.**..*.***...*.****..**.*..***

Output: yes

Input:
99
***....*.....****.*.**.*.*.**.*.*.*..*...*..*...***..*.*...*.*...***.*.*...**.**.*******....**....*

Output: yes

Input:
90
**....****.***..***.*.*****...*.*.***..***.******.**...***..*...*****..*.**.**...*..**...*

Output: yes

Input:
58
**.*.*.**..******.**.*..*.**.*.*******.**.*.**.*..*****.*.

Output: yes

Input:
75
..*.**..*.*****.......*....*.*.*..**.*.***.*.***....******.****.*.....****.

Output: yes

Input:
72
.***.**.*.*...*****.*.*.*.*.**....**.*.**..*.*...**..***.**.**..*.**..**

Output: yes

Input:
69
.***...*.***.**...*....*.***.*..*....**.*...**....*.*..**....**..*.**

Output: yes

Input:
42
..*...*.*..**..*.*.*..**...**.***.*.******

Output: yes

Input:
54
...***.*...****.*..****....*..**..**..***.*..**...**..

Output: yes

Input:
55
...*..*.*.**..*.*....*.****..****....*..***.*****..*..*

Output: yes

Input:
57
**...*....**.**.*.******.**..**.*.....**.***..***...**..*

Output: yes

Input:
97
****.***.***.*..**.**.*.*.***.*............*..*......*.***.**.*.***.*.***.*..*.**.*.***.**.*****.

Output: yes

Input:
42
***.*..*.*.***...**..*..**....**..*..*...*

Output: yes

Input:
99
**...*.*.*..*....**.***..*...***..***.**.*.....*.*....*...*.**.**.****..**..*.*..*.***....**...**.*

Output: yes

Input:
1
.

Output: no

Input:
1
*

Output: no

Input:
99
.*.......................*.......................*.......................*.......................*.

Output: yes

Input:
99
.*.......................*...............................................*.......................*.

Output: no

Input:
100
****************************************************************************************************

Output: yes

Input:
99
***************************************************************************************************

Output: yes

Input:
5
.****

Output: no

Input:
5
*.***

Output: no

Input:
5
**.**

Output: no

Input:
5
***.*

Output: no

Input:
5
****.

Output: no

Input:
100
*...............................................................................................****

Output: no

Input:
100
*****...............................................................................................

Output: yes

Input:
11
.**.*..*.**

Output: no

Input:
21
*.*...*.*...*.*...*.*

Output: no

Input:
6
***.**

Output: no

Input:
13
*..*..*..*..*

Output: yes

Input:
4
****

Output: no

Input:
100
*.....................*.....................*.....................*.....................*...........

Output: yes

Input:
100
*.......................*.......................*.......................*.......................*...

Output: yes

Input:
17
.*..*..*.....*..*

Output: no

Input:
7
***.***

Output: no

Input:
20
.*..*...*....*.....*

Output: no

Input:
11
*...**..*.*

Output: no

Input:
10
*****....*

Output: yes

Input:
16
*.**.**.**.*..*.

Output: yes

Input:
10
.*.*.*.*..

Output: no

Input:
17
*...*...*...*...*

Output: yes

Input:
15
..........*****

Output: yes


The single line contains five integers C, Hr, Hb, Wr, Wb (1 ≤ C, Hr, Hb, Wr, Wb ≤ 109).

NoteIn the sample test Om Nom can eat two candies of each type and thus get 16 joy units.

Print a single integer — the maximum number of joy units that Om Nom can get.

A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place?  One day, when he came to his friend Evan, Om Nom didn't find him at home but he found two bags with candies. The first was full of blue candies and the second bag was full of red candies. Om Nom knows that each red candy weighs Wr grams and each blue candy weighs Wb grams. Eating a single red candy gives Om Nom Hr joy units and eating a single blue candy gives Om Nom Hb joy units.Candies are the most important thing in the world, but on the other hand overeating is not good. Om Nom knows if he eats more than C grams of candies, he will get sick. Om Nom thinks that it isn't proper to leave candy leftovers, so he can only eat a whole candy. Om Nom is a great mathematician and he quickly determined how many candies of what type he should eat in order to get the maximum number of joy units. Can you repeat his achievement? You can assume that each bag contains more candies that Om Nom can eat.

Input: 10 3 5 2 3

Output: 16

Input: 5 3 1 6 7

Output: 0

Input: 982068341 55 57 106 109

Output: 513558662

Input: 930064129 32726326 25428197 83013449 64501049

Output: 363523396

Input: 927155987 21197 15994 54746 41309

Output: 358983713

Input: 902303498 609628987 152407246 8 2

Output: 68758795931537065

Input: 942733698 9180 9072 1020 1008

Output: 8484603228

Input: 951102310 39876134 24967176 70096104 43888451

Output: 539219654

Input: 910943911 107 105 60 59

Output: 1624516635

Input: 910943911 38162 31949 67084 56162

Output: 518210503

Input: 910943911 9063 9045 1007 1005

Output: 8198495199

Input: 903796108 270891702 270891702 1 1

Output: 244830865957095816

Input: 936111602 154673223 309346447 1 2

Output: 144791399037089047

Input: 947370735 115930744 347792233 1 3

Output: 109829394468167085

Input: 958629867 96557265 386229061 1 4

Output: 92562678344491221

Input: 969889000 84931386 424656931 1 5

Output: 82374017230131800

Input: 925819493 47350513 28377591 83230978 49881078

Output: 520855643

Input: 934395168 119 105 67 59

Output: 1662906651

Input: 934395168 29208 38362 51342 67432

Output: 531576348

Input: 934395168 9171 9045 1019 1005

Output: 8409556512

Input: 946401698 967136832 483568416 2 1

Output: 457649970001570368

Input: 962693577 967217455 967217455 2 2

Output: 465567015261784540

Input: 989976325 646076560 969114840 2 3

Output: 319800249268721000

Input: 901235456 485501645 971003291 2 4

Output: 218775648435471424

Input: 912494588 389153108 972882772 2 5

Output: 177550052841687584

Input: 995503930 29205027 18903616 51333090 33226507

Output: 565303099

Input: 983935533 115 108 65 61

Output: 1742049794

Input: 983935533 33986 27367 59737 48104

Output: 559787479

Input: 983935533 7105 7056 1015 1008

Output: 6887548731

Input: 994040035 740285170 246761723 3 1

Output: 245291032098926983

Input: 905299166 740361314 493574209 3 2

Output: 223416160034288041

Input: 911525551 740437472 740437472 3 3

Output: 224975891301803200

Input: 922784684 566833132 755777509 3 4

Output: 174354977531116762

Input: 955100178 462665160 771108601 3 5

Output: 147297192414486195

Input: 949164751 36679609 23634069 64467968 41539167

Output: 537909080

Input: 928443151 60 63 106 112

Output: 525533853

Input: 928443151 25031 33442 43995 58778

Output: 528241752

Input: 928443151 1006 1012 1006 1012

Output: 928443150

Input: 936645623 540336743 135084185 4 1

Output: 126526011319256470

Input: 947904756 540408420 270204210 4 2

Output: 128063927875111380

Input: 959163888 540480074 405360055 4 3

Output: 129602242291091928

Input: 970423020 540551739 540551739 4 4

Output: 131140962756657945

Input: 976649406 455467553 569334442 4 5

Output: 111208028918928288

Input: 923881933 18531902 53987967 32570076 94884602

Output: 524563246

Input: 977983517 57 63 101 112

Output: 551931291

Input: 977983517 29808 22786 52389 40047

Output: 556454318

Input: 977983517 9009 9108 1001 1012

Output: 8801851608

Input: 984283960 367291526 73458305 5 1

Output: 72303831537144592

Input: 990510345 367358723 146943489 5 2

Output: 72774523091497887

Input: 901769477 367425909 220455545 5 3

Output: 66266693959035917

Input: 907995862 367493085 293994468 5 4

Output: 66736440098722854

Input: 924287742 367560271 367560271 5 5

Output: 67946290439275508

Input: 1000000000 1000 999 100 1000000000

Output: 10000000000

Input: 999999999 10 499999995 2 99999999

Output: 4999999995

Input: 999999999 1 1000000000 2 1000000000

Output: 499999999

Input: 999999997 2 999999997 2 999999997

Output: 999999997

Input: 1000000000 1 1 11 11

Output: 90909090

Input: 999999999 999999998 5 999999999 5

Output: 999999998

Input: 100000001 3 100000000 3 100000001

Output: 100000000

Input: 999999999 2 3 1 2

Output: 1999999998

Input: 1000000000 2 1 3 4

Output: 666666666

Input: 999999999 10000 494999 2 99

Output: 4999999994999

Input: 1000000000 1 1 1 1

Output: 1000000000

Input: 998999 1000 999 1000 999

Output: 998999

Input: 3 100 101 2 3

Output: 101

Input: 345415838 13999 13997 13999 13997

Output: 345415838

Input: 5000005 3 2 5 1

Output: 10000010

Input: 1000000000 1 1 1 1000000000

Output: 1000000000

Input: 999999999 3 2 10 3

Output: 666666666

Input: 1000000000 1000 1000 1 1

Output: 1000000000000

Input: 200000001 100000002 1 100000001 1

Output: 200000002

Input: 100000000 1000000000 1 100000001 1

Output: 100000000

Input: 1000000000 99 100 1 2

Output: 99000000000

Input: 1000000000 5 5 1 1

Output: 5000000000

Input: 1000000000 1 1000000000 1 1000000000

Output: 1000000000


The first line of the input contains two integers a, b (1 ≤ b < a ≤ 1012) — the sizes of the original sheet of paper.

NotePictures to the first and second sample test.

Print a single integer — the number of ships that Vasya will make.

One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm  ×  b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting the excess part.  After making a paper ship from the square piece, Vasya looked on the remaining (a - b) mm  ×  b mm strip of paper. He got the idea to use this strip of paper in the same way to make an origami, and then use the remainder (if it exists) and so on. At the moment when he is left with a square piece of paper, he will make the last ship from it and stop.Can you determine how many ships Vasya will make during the lesson?

Input: 2 1

Output: 2

Input: 10 7

Output: 6

Input: 1000000000000 1

Output: 1000000000000

Input: 3 1

Output: 3

Input: 4 1

Output: 4

Input: 3 2

Output: 3

Input: 4 2

Output: 2

Input: 1000 700

Output: 6

Input: 959986566087 524054155168

Output: 90

Input: 4 3

Output: 4

Input: 7 6

Output: 7

Input: 1000 999

Output: 1000

Input: 1000 998

Output: 500

Input: 1000 997

Output: 336

Input: 42 1

Output: 42

Input: 1000 1

Output: 1000

Input: 8 5

Output: 5

Input: 13 8

Output: 6

Input: 987 610

Output: 15

Input: 442 42

Output: 22

Input: 754 466

Output: 13

Input: 1000000000000 999999999999

Output: 1000000000000

Input: 1000000000000 999999999998

Output: 500000000000

Input: 941 14

Output: 74

Input: 998 2

Output: 499

Input: 1000 42

Output: 32

Input: 1000 17

Output: 66

Input: 5 1

Output: 5

Input: 5 2

Output: 4

Input: 5 3

Output: 4

Input: 5 4

Output: 5

Input: 293 210

Output: 17

Input: 787878787878 424242424242

Output: 8

Input: 956722026041 591286729879

Output: 58

Input: 956722026041 365435296162

Output: 58

Input: 628625247282 464807889701

Output: 102

Input: 695928431619 424778620208

Output: 167

Input: 1000000000000 42

Output: 23809523821

Input: 987654345678 23

Output: 42941493300

Input: 10000000001 2

Output: 5000000002

Input: 1000000000000 2

Output: 500000000000

Input: 1000000000000 3

Output: 333333333336

Input: 100000000000 3

Output: 33333333336

Input: 100000000000 23

Output: 4347826109

Input: 999999999997 7

Output: 142857142861

Input: 8589934592 4294967296

Output: 2


The first line contains two integers v1 and v2 (1 ≤ v1, v2 ≤ 100) — the speeds in meters per second at the beginning of the segment and at the end of the segment, respectively. The second line contains two integers t (2 ≤ t ≤ 100) — the time when the car moves along the segment in seconds, d (0 ≤ d ≤ 10) — the maximum value of the speed change between adjacent seconds. It is guaranteed that there is a way to complete the segment so that:   the speed in the first second equals v1,  the speed in the last second equals v2,  the absolute value of difference of speeds between any two adjacent seconds doesn't exceed d.

NoteIn the first sample the sequence of speeds of Polycarpus' car can look as follows: 5, 7, 8, 6. Thus, the total path is 5 + 7 + 8 + 6 = 26 meters.In the second sample, as d = 0, the car covers the whole segment at constant speed v = 10. In t = 10 seconds it covers the distance of 100 meters.

Print the maximum possible length of the path segment in meters.

The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per second, and in the end it is v2 meters per second. We know that this section of the route took exactly t seconds to pass.Assuming that at each of the seconds the speed is constant, and between seconds the speed can change at most by d meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed d in absolute value), find the maximum possible length of the path section in meters.

Input:
5 6
4 2

Output: 26

Input:
10 10
10 0

Output: 100

Input:
87 87
2 10

Output: 174

Input:
1 11
6 2

Output: 36

Input:
100 10
10 10

Output: 550

Input:
1 1
100 10

Output: 24600

Input:
1 1
5 1

Output: 9

Input:
1 1
5 2

Output: 13

Input:
100 100
100 0

Output: 10000

Input:
100 100
100 10

Output: 34500

Input:
1 100
100 1

Output: 5050

Input:
1 100
100 10

Output: 29305

Input:
100 1
100 1

Output: 5050

Input:
100 1
100 10

Output: 29305

Input:
1 10
2 10

Output: 11

Input:
1 1
2 1

Output: 2

Input:
1 1
2 10

Output: 2

Input:
1 2
2 1

Output: 3

Input:
1 2
2 10

Output: 3

Input:
1 5
3 2

Output: 9

Input:
2 1
2 2

Output: 3

Input:
2 1
2 10

Output: 3

Input:
1 11
2 10

Output: 12

Input:
11 1
2 10

Output: 12

Input:
1 1
3 5

Output: 8

Input:
1 10
3 5

Output: 17

Input:
1 21
3 10

Output: 33

Input:
21 1
3 10

Output: 33

Input:
100 100
99 1

Output: 12301

Input:
100 100
100 1

Output: 12450

Input:
99 99
99 1

Output: 12202

Input:
99 99
99 10

Output: 33811

Input:
1 100
99 10

Output: 28764

Input:
13 31
7 5

Output: 182

Input:
88 78
8 5

Output: 719

Input:
34 48
47 4

Output: 4030

Input:
91 29
78 3

Output: 8806

Input:
90 81
21 6

Output: 2391

Input:
95 89
45 3

Output: 5589

Input:
48 54
84 2

Output: 7724

Input:
72 31
59 7

Output: 8865

Input:
51 13
47 3

Output: 2970

Input:
97 91
82 2

Output: 10984

Input:
71 71
9 5

Output: 719

Input:
16 49
40 3

Output: 2350

Input:
22 41
68 4

Output: 6608

Input:
13 71
72 6

Output: 10444

Input:
77 78
46 3

Output: 5083

Input:
36 60
54 2

Output: 3924

Input:
55 39
93 2

Output: 8571

Input:
34 7
48 6

Output: 4266

Input:
80 88
79 3

Output: 11193

Input:
34 62
15 4

Output: 866

Input:
81 40
73 2

Output: 6798

Input:
13 38
97 6

Output: 16271

Input:
84 87
45 2

Output: 4814

Input:
42 65
76 3

Output: 8240

Input:
55 6
24 4

Output: 1110

Input:
41 16
43 2

Output: 2029

Input:
99 93
78 1

Output: 8961

Input:
10 7
44 2

Output: 1297

Input:
72 54
91 3

Output: 11781

Input:
48 34
80 2

Output: 6376

Input:
92 85
70 1

Output: 7373


The first and only line of input contains a lucky number n (1 ≤ n ≤ 109).

Print the index of n among all lucky numbers.

Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."  The problem is: You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.If we sort all lucky numbers in increasing order, what's the 1-based index of n? Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.


The first and only line of input contains an integer s (0 ≤ s ≤ 99), Tavas's score.

NoteYou can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals .

In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.

Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.  He ate coffee mix without water again, so right now he's really messed up and can't think.Your task is to help him by telling him what to type.

Output: six

Output: ninety-nine

Output: twenty

Output: ten

Output: fifteen

Output: twenty-seven

Output: forty

Output: sixty-three

Output: zero

Output: one

Output: two

Output: eight

Output: nine

Output: eleven

Output: twelve

Output: thirteen

Output: fourteen

Output: sixteen

Output: seventeen

Output: eighteen

Output: nineteen

Output: twenty-one

Output: twenty-nine

Output: thirty

Output: thirty-two

Output: thirty-eight

Output: forty-three

Output: forty-seven

Output: fifty

Output: fifty-four

Output: fifty-six

Output: sixty

Output: sixty-six

Output: seventy

Output: seventy-six

Output: eighty

Output: eighty-two

Output: ninety

Output: ninety-one

Output: ninety-five

Output: seventy-one

Output: forty-six

Output: eighty-four

Output: twenty-two

Output: twenty-three

Output: twenty-four

Output: twenty-five

Output: twenty-six

Output: twenty-eight

Output: thirty-one

Output: thirty-three

Output: thirty-four

Output: thirty-five

Output: thirty-six

Output: thirty-seven

Output: thirty-nine

Output: sixty-five

Output: sixty-eight

Output: forty-one

Output: forty-two

Output: forty-four

Output: forty-five

Output: forty-eight

Output: forty-nine

Output: fifty-one

Output: fifty-two

Output: fifty-three

Output: fifty-five

Output: fifty-seven

Output: fifty-eight

Output: fifty-nine

Output: sixty-one

Output: sixty-two

Output: sixty-four

Output: sixty-seven

Output: sixty-nine

Output: seventy-two

Output: seventy-three

Output: seventy-four

Output: seventy-five

Output: seventy-seven

Output: seventy-eight

Output: seventy-nine

Output: eighty-one

Output: eighty-three

Output: eighty-five

Output: eighty-six

Output: eighty-seven

Output: eighty-eight

Output: eighty-nine

Output: ninety-two

Output: ninety-three

Output: ninety-four

Output: ninety-six

Output: seven

Output: ninety-seven

Output: ninety-eight

Output: three

Output: four

Output: five


CODEWAITFORITFORCES BOTTOMCODER DECODEFORCES DOGEFORCES

The single line of the input contains the word written on the banner. The word only consists of upper-case English letters. The word is non-empty and its length doesn't exceed 100 characters. It is guaranteed that the word isn't word CODEFORCES.

Print 'YES', if there exists a way to cut out the substring, and 'NO' otherwise (without the quotes).

A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.

Input: CODEWAITFORITFORCES

Output: YES

Input: BOTTOMCODER

Output: NO

Input: DECODEFORCES

Output: YES

Input: DOGEFORCES

Output: NO

Input: ABACABA

Output: NO

Input: CODEFORCE

Output: NO

Input: C

Output: NO

Input: NQTSMZEBLY

Output: NO

Input: CODEFZORCES

Output: YES

Input: EDYKHVZCNTLJUUOQGHPTIOETQNFLLWEKZOHIUAXELGECABVSBIBGQODQXVYFKBYJWTGBYHVSSNTINKWSINWSMALUSIWNJMTCOOVF

Output: NO

Input: OCECFDSRDE

Output: NO

Input: MDBUWCZFFZKFMJTTJFXRHTGRPREORKDVUXOEMFYSOMSQGHUKGYCRCVJTNDLFDEWFS

Output: NO

Input: CODEFYTORCHES

Output: NO

Input: BCODEFORCES

Output: YES

Input: CVODEFORCES

Output: YES

Input: COAKDEFORCES

Output: YES

Input: CODFMWEFORCES

Output: YES

Input: CODEVCSYRFORCES

Output: YES

Input: CODEFXHHPWCVQORCES

Output: YES

Input: CODEFORQWUFJLOFFXTXRCES

Output: YES

Input: CODEFORBWFURYIDURNRKRDLHCLXZCES

Output: YES

Input: CODEFORCQSYSLYKCDFFUPSAZCJIAENCKZUFJZEINQIES

Output: YES

Input: CODEFORCEVENMDBQLSVPQIIBGSHBVOPYZXNWVSTVWDRONUREYJJIJIPMEBPQDCPFS

Output: YES

Input: CODEFORCESCFNNPAHNHDIPPBAUSPKJYAQDBVZNLSTSDCREZACVLMRFGVKGVHHZLXOHCTJDBQKIDWBUXDUJARLWGFGFCTTXUCAZB

Output: YES

Input: CODJRDPDEFOROES

Output: NO

Input: CODEFOGSIUZMZCMWAVQHNYFEKIEZQMAZOVEMDRMOEDBHAXPLBLDYYXCVTOOSJZVSQAKFXTBTZFWAYRZEMDEMVDJTDRXXAQBURCES

Output: YES

Input: CODEMKUYHAZSGJBQLXTHUCZZRJJJXUSEBOCNZASOKDZHMSGWZSDFBGHXFLABVPDQBJYXSHHAZAKHSTRGOKJYHRVSSUGDCMFOGCES

Output: NO

Input: CODEFORCESCODEFORCESCODEFORCESCODEFORCESCODEFORCESCODEFORCESCODEFORCESCODEFORCESCODEFORCES

Output: YES

Input: CCODEFORCESODECODEFORCCODEFORCESODCODEFORCESEFCODEFORCESORCODEFORCESCESCESFORCODEFORCESCES

Output: NO

Input: CCODEFORCESC

Output: NO

Input: CODEAFORBCES

Output: NO

Input: CODERRRRRFORCRRRRES

Output: NO

Input: CODELFORCELS

Output: NO

Input: CPOPDPEPFPOPRPCPEPS

Output: NO

Input: COXDEXFORXCEXS

Output: NO

Input: CODAAAAAFORCES

Output: NO

Input: CAOADEFORCES

Output: NO

Input: FORCESXCODE

Output: NO

Input: FORCESACODE

Output: NO

Input: ACAOADAEFORCES

Output: NO

Input: CCODEFORCESS

Output: NO

Input: ZCODEFORCEZ

Output: NO

Input: CODXEFORXCES

Output: NO

Input: CODEFORCEZ

Output: NO

Input: CODEFORCEST

Output: YES

Input: AXODEFORCES

Output: NO

Input: RCODEFORCESR

Output: NO

Input: CODECODEFORCESFORCES

Output: YES

Input: TTTWWWCODEFORCES

Output: YES

Input: CODEFORRCEST

Output: NO

Input: UJYTYUCODEFORCES

Output: YES

Input: CODEXXXXXXXXXXXXXXXXXXCODEFORCESXXXXXXXXXXXXXXXXXXXXXFORCES

Output: YES

Input: COXEDYFORCES

Output: NO

Input: UJYTYCODEFORCES

Output: YES

Input: UJYTCODEFORCES

Output: YES


The first line contains three positive integers k, n, w (1  ≤  k, w  ≤  1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants.

Output one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.

A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). He has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?

Input: 3 17 4

Output: 13

Input: 1 2 1

Output: 0

Input: 1 1 1

Output: 0

Input: 1 5 6

Output: 16

Input: 1 1000000000 1

Output: 0

Input: 1000 0 1000

Output: 500500000

Input: 859 453892 543

Output: 126416972

Input: 1000 1000000000 1000

Output: 0

Input: 1000 500500000 1000

Output: 0

Input: 1000 500500001 1000

Output: 0

Input: 1000 500499999 1000

Output: 1

Input: 634 87973 214

Output: 14497197

Input: 432 10000 241

Output: 12587552

Input: 111 111111111 111

Output: 0

Input: 20 43 3

Output: 77


First line contains a single integer n (2 ≤ n ≤ 10), the number of cards. Second line contains integer k1 (1 ≤ k1 ≤ n - 1), the number of the first soldier's cards. Then follow k1 integers that are the values on the first soldier's cards, from top to bottom of his stack. Third line contains integer k2 (k1 + k2 = n), the number of the second soldier's cards. Then follow k2 integers that are the values on the second soldier's cards, from top to bottom of his stack. All card values are different.

If somebody wins in this game, print 2 integers where the first one stands for the number of fights before end of game and the second one is 1 or 2 showing which player has won. If the game won't end and will continue forever output  - 1.

Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a "war"-like card game. The rules are following. On each turn a fight happens. Each of them picks card from the top of his stack and puts on the table. The one whose card value is bigger wins this fight and takes both cards from the table to the bottom of his stack. More precisely, he first takes his opponent's card and puts to the bottom of his stack, and then he puts his card to the bottom of his stack. If after some turn one of the player's stack becomes empty, he loses and the other one wins. You have to calculate how many fights will happen and who will win the game, or state that game won't end.

Input:
4
2 1 3
2 4 2

Output: 6 2

Input:
3
1 2
2 1 3

Output: -1

Input:
5
4 5 3 2 4
1 1

Output: 1 1

Input:
6
2 6 5
4 1 2 3 4

Output: 6 1

Input:
7
6 6 5 2 7 4 1
1 3

Output: 1 1

Input:
8
7 2 3 1 5 6 4 8
1 7

Output: 15 1

Input:
9
2 3 6
7 9 7 8 5 2 1 4

Output: 2 2

Input:
10
3 7 10 8
7 4 6 9 2 5 1 3

Output: 25 1

Input:
3
2 2 1
1 3

Output: 2 2

Input:
3
2 3 2
1 1

Output: 1 1

Input:
3
1 3
2 2 1

Output: 2 1

Input:
3
1 1
2 3 2

Output: 1 2

Input:
3
1 2
2 3 1

Output: 1 2

Input:
3
2 3 1
1 2

Output: 1 1

Input:
3
1 3
2 1 2

Output: -1

Input:
3
2 1 3
1 2

Output: -1

Input:
3
2 1 2
1 3

Output: -1

Input:
2
1 1
1 2

Output: 1 2

Input:
4
2 2 1
2 4 3

Output: 2 2

Input:
4
1 2
3 3 4 1

Output: 1 2

Input:
4
3 3 2 1
1 4

Output: 3 2

Input:
4
3 2 3 1
1 4

Output: 7 2

Input:
4
3 1 4 2
1 3

Output: 7 1

Input:
4
3 1 3 2
1 4

Output: 5 2

Input:
5
2 2 1
3 4 5 3

Output: 2 2

Input:
5
1 4
4 5 2 3 1

Output: 1 2

Input:
5
1 2
4 5 1 4 3

Output: 1 2

Input:
5
2 2 4
3 3 1 5

Output: -1

Input:
5
4 2 4 3 1
1 5

Output: -1

Input:
5
4 1 3 4 2
1 5

Output: -1

Input:
5
4 3 2 5 1
1 4

Output: 7 1

Input:
5
1 4
4 3 2 5 1

Output: 7 2

Input:
5
4 4 1 3 2
1 5

Output: 6 2

Input:
5
4 1 4 3 2
1 5

Output: -1

Input:
5
4 1 5 3 2
1 4

Output: -1

Input:
6
3 2 4 1
3 3 6 5

Output: 3 2

Input:
6
1 4
5 2 5 6 3 1

Output: 3 2

Input:
6
5 1 5 4 6 2
1 3

Output: 3 1

Input:
6
2 4 6
4 1 3 2 5

Output: -1

Input:
6
4 2 1 6 4
2 5 3

Output: -1

Input:
6
1 6
5 1 3 2 5 4

Output: -1

Input:
6
5 4 6 3 2 1
1 5

Output: 19 1

Input:
6
1 5
5 4 6 3 2 1

Output: 19 2

Input:
6
5 1 5 4 3 2
1 6

Output: 17 2

Input:
6
5 1 4 3 5 2
1 6

Output: -1

Input:
6
5 1 4 2 5 3
1 6

Output: -1

Input:
6
5 1 3 4 5 2
1 6

Output: -1

Input:
7
1 1
6 5 6 3 2 7 4

Output: 1 2

Input:
7
6 5 1 2 6 4 3
1 7

Output: -1

Input:
7
6 3 5 2 1 6 4
1 7

Output: 14 2

Input:
7
1 6
6 1 2 5 4 7 3

Output: -1

Input:
8
1 4
7 3 8 6 1 5 7 2

Output: 3 2

Input:
8
7 3 1 5 4 7 6 2
1 8

Output: 41 2

Input:
9
8 3 1 4 5 2 6 9 8
1 7

Output: 11 1

Input:
9
7 6 5 9 2 1 3 8
2 7 4

Output: -1

Input:
9
8 7 4 3 1 6 5 9 2
1 8

Output: 25 1

Input:
9
8 4 8 5 6 3 2 7 1
1 9

Output: -1

Input:
10
2 9 3
8 10 4 1 8 6 2 7 5

Output: 2 2

Input:
10
2 7 1
8 8 2 4 3 5 6 10 9

Output: 2 2

Input:
10
1 5
9 3 2 8 7 1 9 10 6 4

Output: 7 2

Input:
10
9 6 2 1 4 8 7 3 10 5
1 9

Output: -1

Input:
10
1 10
9 9 4 7 8 5 2 6 3 1

Output: -1

Input:
10
5 1 2 7 9 6
5 3 4 10 8 5

Output: -1

Input:
10
9 8 7 6 2 3 5 4 9 1
1 10

Output: 105 2

Input:
10
1 10
9 5 7 6 1 2 3 9 8 4

Output: 105 1

Input:
10
9 8 7 6 2 3 5 4 10 1
1 9

Output: 103 1

Input:
10
9 4 6 5 3 1 8 9 7 2
1 10

Output: -1

Input:
10
9 4 6 5 3 1 8 10 7 2
1 9

Output: -1

Input:
10
9 4 9 6 5 8 3 2 7 1
1 10

Output: -1

Input:
10
3 8 4 10
7 1 2 6 7 3 9 5

Output: 37 1

Input:
10
4 6 2 7 1
6 3 8 10 9 5 4

Output: 10 2

Input:
10
2 7 8
8 3 5 2 10 4 9 1 6

Output: 12 2

Input:
10
2 7 5
8 9 3 2 4 6 8 1 10

Output: 10 2

Input:
10
3 4 9 2
7 5 1 6 8 3 7 10

Output: 7 2

Input:
10
5 4 9 1 8 7
5 6 10 3 5 2

Output: 21 2

Input:
10
3 4 5 1
7 9 10 3 2 6 7 8

Output: 3 2

Input:
10
3 5 9 8
7 2 3 7 10 1 6 4

Output: 19 2

Input:
10
1 5
9 4 9 1 7 2 6 10 3 8

Output: 7 2

Input:
10
4 3 10 8 7
6 4 2 5 6 1 9

Output: 8 1

Input:
10
8 1 6 5 3 8 7 10 4
2 9 2

Output: 40 1

Input:
2
1 2
1 1

Output: 1 1


The first line of input contains integer m (2 ≤ m ≤ 106). The second line of input contains integers h1 and a1 (0 ≤ h1, a1 < m). The third line of input contains integers x1 and y1 (0 ≤ x1, y1 < m). The fourth line of input contains integers h2 and a2 (0 ≤ h2, a2 < m). The fifth line of input contains integers x2 and y2 (0 ≤ x2, y2 < m). It is guaranteed that h1 ≠ a1 and h2 ≠ a2.

NoteIn the first sample, heights sequences are following:Xaniar: Abol:

Print the minimum number of seconds until Xaniar reaches height a1 and Abol reaches height a2 or print -1 otherwise.

Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h1 and height of Abol is h2. Each second, Mike waters Abol and Xaniar.  So, if height of Xaniar is h1 and height of Abol is h2, after one second height of Xaniar will become  and height of Abol will become  where x1, y1, x2 and y2 are some integer numbers and  denotes the remainder of a modulo b.Mike is a competitive programmer fan. He wants to know the minimum time it takes until height of Xania is a1 and height of Abol is a2.Mike has asked you for your help. Calculate the minimum time or say it will never happen.

Input:
5
4 2
1 1
0 1
2 3

Output: 3

Input:
1023
1 2
1 0
1 2
1 1

Output: -1

Input:
1023
1 2
1 2
1 2
1 2

Output: 512

Input:
2
0 1
1 0
1 0
0 1

Output: -1

Input:
17
15 12
15 12
12 14
1 11

Output: -1

Input:
29
4 0
1 1
25 20
16 0

Output: 170

Input:
91
9 64
75 32
60 81
35 46

Output: 5

Input:
91
38 74
66 10
40 76
17 13

Output: -1

Input:
100
11 20
99 31
60 44
45 64

Output: 3

Input:
9999
4879 6224
63 7313
4279 6583
438 1627

Output: 4

Input:
10000
8681 4319
9740 5980
24 137
462 7971

Output: -1

Input:
100000
76036 94415
34870 43365
56647 26095
88580 30995

Output: 5

Input:
100000
90861 77058
96282 30306
45940 25601
17117 48287

Output: -1

Input:
1000000
220036 846131
698020 485511
656298 242999
766802 905433

Output: 5297

Input:
1000000
536586 435396
748740 34356
135075 790803
547356 534911

Output: 9958

Input:
1000000
661647 690400
864868 326304
581148 452012
327910 197092

Output: 1021

Input:
1000000
233404 949288
893747 751429
692094 57207
674400 583468

Output: -1

Input:
1000000
358465 242431
977171 267570
170871 616951
711850 180241

Output: -1

Input:
1000000
707719 502871
60595 816414
649648 143990
525107 66615

Output: -1

Input:
999983
192005 690428
971158 641039
974183 1882
127579 312317

Output: 470479

Input:
999983
420528 808305
387096 497121
596163 353326
47177 758204

Output: 548500

Input:
999983
651224 992349
803017 393514
258455 402487
888310 244420

Output: 126531

Input:
999983
151890 906425
851007 9094
696594 968184
867017 157783

Output: -1

Input:
999983
380412 325756
266945 907644
318575 83081
786616 603671

Output: -1

Input:
999983
570797 704759
723177 763726
978676 238272
708387 89886

Output: -1

Input:
999983
408725 408721
1 1
378562 294895
984270 0

Output: 499981500166

Input:
999983
639420 639416
1 1
507684 954997
466316 0

Output: 499981500166

Input:
999983
867942 867939
1 1
963840 536667
899441 0

Output: 999964000320

Input:
999961
664221 931770
530542 936292
885122 515424
868560 472225

Output: -1

Input:
999961
744938 661980
845908 76370
237399 381935
418010 938769

Output: 203332

Input:
999961
89288 89284
1 1
764559 727291
999322 0

Output: 999920001595

Input:
1000000
661703 661699
1 1
425192 823944
854093 0

Output: -1

Input:
100019
98811 98807
1 1
91322 14787
72253 0

Output: 10003600319

Input:
524288
199980 199978
1 1
236260 325076
81773 0

Output: -1

Input:
524288
47283 489031
305624 183135
141146 335913
519614 150715

Output: 19

Input:
524288
83398 33987
158854 211502
36433 18758
218812 517001

Output: -1

Input:
912488
681639 518634
168348 212018
255428 4970
31726 664998

Output: 34838

Input:
129081
128454 36771
116353 2940
95311 22200
579 118683

Output: 68409

Input:
129081
45717 106320
121816 69841
5161 4872
102076 100020

Output: -1

Input:
4
1 2
1 1
0 1
2 0

Output: -1

Input:
3
1 0
1 1
1 2
2 0

Output: 5

Input:
3
0 2
1 0
2 0
2 1

Output: -1

Input:
2
0 1
0 1
0 1
0 1

Output: 1

Input:
2
0 1
1 0
0 1
1 0

Output: -1

Input:
2
0 1
1 1
0 1
1 1

Output: 1

Input:
2
0 1
1 1
0 1
1 0

Output: -1

Input:
2
0 1
1 0
0 1
1 1

Output: -1

Input:
1000000
1 0
1 1
1 0
1 1

Output: 999999

Input:
1000000
2 1
1 1
2 0
1 2

Output: 999999

Input:
6
1 2
3 5
0 2
4 2

Output: 1

Input:
545
26 40
477 97
454 394
15 264

Output: 90

Input:
3
1 0
0 1
0 2
1 0

Output: -1

Input:
1376
1227 1349
313 193
1113 361
1314 23

Output: 338

Input:
1376
1322 1320
1 1
776 495
38 0

Output: -1

Input:
1376
152 405
1083 1328
76 856
49 629

Output: -1

Input:
1392
1060 796
512 242
1386 1346
1310 1199

Output: -1

Input:
100000
5827 41281
41285 70821
99199 42807
65667 94952

Output: 13770

Input:
100000
51157 27741
40564 90740
45270 52367
31585 92150

Output: -1

Input:
100000
70525 70522
1 1
89465 30265
33279 0

Output: -1

Input:
10
1 6
7 9
1 4
4 0

Output: 1

Input:
10
9 6
0 8
3 0
2 7

Output: -1

Input:
10
4 2
1 1
7 3
9 0

Output: -1

Input:
6
5 1
1 1
3 1
3 0

Output: -1

Input:
999983
3 1
1 1
8 1
2 0

Output: 499981500168

Input:
18
3 9
3 0
1 3
3 0

Output: 1

Input:
18
1 3
3 0
3 9
3 0

Output: 1

Input:
16
1 0
2 0
1 2
2 0

Output: -1

Input:
16
8 0
2 0
1 4
2 0

Output: 2

Input:
999983
2 1
2 0
1 0
1 1

Output: 499982500152

Input:
324
2 54
3 0
27 108
2 0

Output: -1

Input:
999993
499997 1
2 3
1 4
1 1

Output: 39325724721

Input:
999983
1 37827
1 1
2 192083
3 0

Output: 404303164556

Input:
41222
30759 26408
31332 39118
5026 25812
1 9030

Output: 58900566

Input:
100007
2 1
2 0
3 1
1 1

Output: 434330399

Input:
8
0 4
4 4
1 4
2 0

Output: 2


The first line contains four integers n, l, r, x (1 ≤ n ≤ 15, 1 ≤ l ≤ r ≤ 109, 1 ≤ x ≤ 106) — the number of problems you have, the minimum and maximum value of total difficulty of the problemset and the minimum difference in difficulty between the hardest problem in the pack and the easiest one, respectively. The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 106) — the difficulty of each problem.

NoteIn the first example two sets are suitable, one consisting of the second and third problem, another one consisting of all three problems.In the second example, two sets of problems are suitable — the set of problems with difficulties 10 and 30 as well as the set of problems with difficulties 20 and 30.In the third example any set consisting of one problem of difficulty 10 and one problem of difficulty 20 is suitable.

Print the number of ways to choose a suitable problemset for the contest.

You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made.A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest must be at least l and at most r. Also, you think that the difference between difficulties of the easiest and the hardest of the chosen problems must be at least x.Find the number of ways to choose a problemset for the contest.

Input:
3 5 6 1
1 2 3

Output: 2

Input:
4 40 50 10
10 20 30 25

Output: 2

Input:
5 25 35 10
10 10 20 10 20

Output: 6

Input:
4 15 60 10
10 20 30 25

Output: 6

Input:
1 10 20 1
15

Output: 0

Input:
10 626451 11471247 246428
369649 684428 303821 287098 422756 301599 720377 177567 515216 750602

Output: 914

Input:
15 1415849 15540979 356865
8352 960238 276753 259695 712845 945369 60023 920446 181269 392011 318488 857649 30681 740872 115749

Output: 31485

Input:
7 1000 2000 1
10 20 30 40 50 60 70

Output: 0

Input:
4 10 20 1
4 6 4 6

Output: 9

Input:
4 10 20 1
5 15 13 7

Output: 4

Input:
2 10 20 5
5 10

Output: 1

Input:
5 1098816 3969849 167639
85627 615007 794045 530104 7091

Output: 15

Input:
13 700147 8713522 390093
996812 94040 954140 545670 369698 423872 365802 784830 700267 960664 949252 84637 257447

Output: 8026

Input:
15 4531977 20754263 137419
637830 85299 755530 64382 896833 879525 331501 148182 741013 192101 112217 52165 702790 988594 587499

Output: 6759

Input:
15 2572491 5084070 823435
570344 78552 775918 501843 844935 71141 331498 636557 435494 715447 992666 831188 28969 171046 989614

Output: 15078

Input:
15 4789415 23152928 233992
502422 273992 449428 947379 700461 681985 857134 243310 478052 77769 936151 642380 464695 281772 964693

Output: 10875

Input:
3 390224 390224 1
264237 125987 288891

Output: 1

Input:
7 1652707 1652707 1
492387 684636 235422 332532 924898 499872 192988

Output: 1

Input:
10 501107 501107 1
843967 30518 196518 619138 204862 690754 274071 550121 173607 359971

Output: 1

Input:
15 6627289 6627289 1
683844 183950 184972 764255 211665 842336 790234 815301 914823 513046 93547 713159 554415 200951 388028

Output: 1

Input:
15 5083470 5083470 1
978510 643688 591921 723137 573784 346171 920030 352119 528857 365128 627302 308557 716247 263519 654230

Output: 1

Input:
15 6558665 6558665 1
572491 435494 916457 775918 823435 78552 501843 331498 71141 844935 636557 992666 570344 831188 715447

Output: 1

Input:
10 159699 10967276 3542
998862 999751 995306 992648 992661 991407 997503 998809 999740 997669

Output: 942

Input:
5 2815840 8479687 4082
991137 992161 997887 998891 994990

Output: 14

Input:
15 2898377 6694755 721
992733 999159 990076 996808 990975 993338 993234 994757 997873 993303 994409 993801 998027 990495 999287

Output: 9819

Input:
6 20 70 1
10 10 20 20 30 30

Output: 35

Input:
6 20 70 1
10 10 10 10 10 10

Output: 0

Input:
15 1 1000000000 1
10 20 30 40 50 60 70 80 90 100 110 120 130 140 150

Output: 32752

Input:
6 30 40 1
19 20 21 14 15 16

Output: 13

Input:
4 5 234 2
10 9 12 11

Output: 8


The only line contains two integers n and k (1 ≤ n, k ≤ 109).

Print the smallest integer x > n, so it is divisible by the number k.

Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.

Input: 5 3

Output: 6

Input: 25 13

Output: 26

Input: 26 13

Output: 39

Input: 1 1

Output: 2

Input: 8 8

Output: 16

Input: 14 15

Output: 15

Input: 197 894

Output: 894

Input: 6058 8581

Output: 8581

Input: 97259 41764

Output: 125292

Input: 453145 333625

Output: 667250

Input: 2233224 4394826

Output: 4394826

Input: 76770926 13350712

Output: 80104272

Input: 687355301 142098087

Output: 710490435

Input: 1000000000 999999999

Output: 1999999998

Input: 1000000000 1000000000

Output: 2000000000

Input: 999999999 1000000000

Output: 1000000000

Input: 1000000000 1

Output: 1000000001

Input: 1000000000 2

Output: 1000000002

Input: 999999999 1

Output: 1000000000

Input: 100000000 1

Output: 100000001

Input: 999999999 500000000

Output: 1000000000

Input: 999999990 10

Output: 1000000000

Input: 1000000000 999999997

Output: 1999999994

Input: 999999999 2

Output: 1000000000

Input: 999999984 1

Output: 999999985

Input: 999999983 1

Output: 999999984

Input: 666666666 1

Output: 666666667

Input: 1000000000 990000000

Output: 1980000000

Input: 41 48

Output: 48

Input: 123456 2

Output: 123458

Input: 111 111

Output: 222

Input: 878787 1

Output: 878788

Input: 121 1

Output: 122

Input: 114514 114514

Output: 229028

Input: 500000001 1000000000

Output: 1000000000

Input: 999999997 1

Output: 999999998

Input: 100000000 10

Output: 100000010


The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.

NoteToday is Monday, the 13th of June, 2016.

Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.

The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (https://en.wikipedia.org/wiki/Leap_year).


The only line contains four integers A, B, n and x (1 ≤ A, B, x ≤ 109, 1 ≤ n ≤ 1018) — the parameters from the problem statement. Note that the given value n can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Print the only integer s — the value g(n)(x) modulo 109 + 7.

Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.

Input: 3 4 1 1

Output: 7

Input: 3 4 2 1

Output: 25

Input: 3 4 3 1

Output: 79

Input: 1 1 1 1

Output: 2

Input: 3 10 723 6

Output: 443623217

Input: 14 81 51 82

Output: 908370438

Input: 826504481 101791432 76 486624528

Output: 621999403

Input: 475965351 844435993 96338 972382431

Output: 83709654

Input: 528774798 650132512 6406119 36569714

Output: 505858307

Input: 632656975 851906850 1 310973933

Output: 230360736

Input: 1 1 352875518515340737 1

Output: 45212126

Input: 978837295 606974665 846646545585165081 745145208

Output: 154788991

Input: 277677243 142088706 8846851 253942280

Output: 221036825

Input: 1 192783664 1000000000000000000 596438713

Output: 42838179

Input: 1 1000000000 1000000000000000000 1

Output: 999999665

Input: 1 1000000000 1000000000000000000 1000000000

Output: 999999657

Input: 1 100000000 10000000000000 1000000000

Output: 48993

Input: 1 1171281 1000000000000000000 100

Output: 57392869

Input: 1 1000000000 100000000000000000 1000000000

Output: 899999965

Input: 1 100000000 100000000000000000 10000

Output: 490010000

Input: 1 100000456 10000000000000000 54165

Output: 129054389

Input: 1 1000000000 10000000000000 1

Output: 490001

Input: 1 100000000 10000000000000000 10000

Output: 49010000

Input: 1 1000000000 10000000000 12

Output: 502

Input: 1 999999999 999999999999999999 12345678

Output: 12345294

Input: 1 1000000 1000000000000000000 100000

Output: 49100000

Input: 1 1000000000 1000000000000 12

Output: 49012

Input: 1 10000 1000000000000000000 5

Output: 490005

Input: 1 10000 1000000000000000000 10000

Output: 500000

Input: 1 1000000000 10000000000000 12

Output: 490012

Input: 1 1000000000 1000000000000000 12

Output: 49000012

Input: 1 1000000000 1000000000000000000 12

Output: 999999676

Input: 1 10000000 100000000000000000 100000

Output: 49100000

Input: 114514 114514 114514 114514

Output: 623380685

Input: 2 1 1000000006 1

Output: 1

Input: 1 1234 10 9

Output: 12349