All Tracks Problem

Chandler Bing and his nubbins
Tag(s):

Easy

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
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:
Notifications
View All Notifications

?