HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Kovrov IT > problem:


2010.J. 50258 - String manipulations

Guest
• Discussion of problem (1)

Volume problems

• 2010.B. 50281 - Primes
• 2010.C. 50255 - Bishops
• 2010.D. 50277 - Unusual Lottery
• 2010.E. 50664 - Polygons
• 2010.F. 50265 - Liars and Knights
• 2010.G. 50256 - Sequence
• 2010.H. 50282 - Coins
• 2010.I. 50257 - Galls village
• 2010.J. 50258 - String manipulat...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 3000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Кирилл Бутин, ПГУ.

You are given a string S, consisting of lowercase Latin letters. The length of string is L. There are N small strings. You should concatenate all of them in any order to get string T. Your task is to count the number of different strings T, which are subsequences of string S.

Input
The first line contains L lowercase Latin letters (1 ≤ L ≤ 10000). The second line contains integer N (1 ≤ N ≤ 9) - the number of small strings, which should be concatenated. The following N lines contain sequences of lowercase Latin letters. The total length of small strings does not exceed 1000 symbols.

Output
Output a single number - the answer for the problem.

Input 1 Output 1
abracadabra
2
aaa
a
1
Input 2 Output 2
abracadabra
2
ara
bra
2

Для отправки решений необходимо выполнить вход.

www.contester.ru