Encryption
题号:NC237289
时间限制:C/C++/Rust/Pascal 7秒,其他语言14秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

You are given a string s of lowercase letters and let be the number of occurrences of t in s, we define an encryption function f(t) as follows:

where '' means string concatenation, for example, .
For each query string t, please calculate f(t).

输入描述:

The first line contains a string of lowercase letters.
The second line contains an integer q indicating the number of queries.
For the next q lines, each line contains a nonempty lowercase query string t.
It is guaranteed that the sum of the length of all queries doesn't exceed .

输出描述:

For each query, output the encrypted result in a single line.
示例1

输入

复制
ababa
1
aba

输出

复制
aab