All Tracks Problem

Chandler Bing and his nubbins
/
No tags
Problem
Editorial
Analytics

Chandler Bing and his nubbins

enter image description here

Chandler after finding the his nubbin is struck by a question of answering the queries asked by his nubbins. First he gets a string S consisting of alphanumeric characters and then Q queries. Each query is a non-empty string of alphanumeric characters P. For each such P, Chandler has to tell how many P's can be formed using the elements of S.

Note : The string has both Lower and Upper case characters.

Input:

The first line of input contain a string S,
Next line contains an integer Q - number of queries.
Each of the next Q lines contain a string P.

Output:

For each query output the required answer.

Constraints:

\( 1 \leq |S| \leq 10^{5} \)

\( 1 \leq \sum |P| \leq 10^{5} \)

\( 1 \leq Q \leq 10^{5} \)

Problem Setter - Saurabh

SAMPLE INPUT
TriHackerCup
2
THick
path
SAMPLE OUTPUT
1
0
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?