ScansionCapba is doing a poetry analysis. He has scanned the lines of a poem and determined which syllables are stressed and which are unstressed. There are nineteen different "feet", that is, patterns of stressed and unstressed syllables. 0 represents an unstressed syllable and 1 represents a stressed syllable:
00 pyrrhic 01 iamb 10 trochee 11 spondee 000 tribrach 001 anapest 010 amphibrach 011 bacchius 100 dactyl 101 amphimacer 110 antibacchius 111 molossos 0001 fourth paeon 0010 third paeon 0011 ionic a minore 0100 second paeon 0110 antispast 1000 first paeon 1001 choriamb
A line with the pattern 001001, for example could be
a pyrrhic, a trochee, and an iamb;
a pyrrhic and a choriamb; or
a third paeon and an iamb.
Capba is having some trouble determining which.
He decides to guess the breakdown of the line into feet, and, through extensive shovelling, justify his assertion whether or not it be right (this leads to excellent results if done properly.) He would like to know how many different ways each line can be broken down into the feet as listed above.
Line 1: A sequence of ones or zeroes, up to 10000 characters long, corresponding to a pattern of stressed and unstressed syllables. 0 represents an unstressed syllable, 1 represents a stressed syllable.
An integer, on a single line - the number of ways that the given line can be broken down into feet, modulo 10007.
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Jan 24, 2009
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3