HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Strings > problem:


50258 - String manipulations

Guest
• Discussion of problem (1)

Section problems

• 50908 - Buy 1 Get 1
• 50761 - Magic Words
• 50760 - Hexatridecimal Sum
• 50759 - Text Statistics
• 50246 - Making Potions
• 50258 - String manipulations
• 50264 - String Multiplication
• 50307 - Palindromes
• 50315 - Pig Latin
• 50484 - Number Of Letters
• 50323 - Filtering Contact List
• 50409 - Random Password Generator
• 50763 - Valid Password
• 50429 - Secret Message

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