We, the insomniacs, love strings of characters. One day, we were playing
around with one of the strings, when suddenly Adam asks us to count how
many times does the character 'i' occur before the character 'j' in the given
string(from left to right, see sample test case for clarity ). So, that is exactly
what you need to do now.
Note: 'i' and 'j' need not be distinct.
Each input file consists of a single test case starting with the given string. The
next line contains a number Q, representing the number of queries that you
would have to answer.The following Q lines contain queries, one on each line.
Each query would be of type : 'i' 'j' ,where 'i' and 'j' would only be from among
the lower-case English alphabets[a..z]. (quotes around 'i' and 'j' are only
shown for distinction here). A single space-character would separate the two
1 <= Length of string <= 10000
1<= Q <= 10000
You must output a single number for each query on a separate line giving the
required count. If any of the characters in the query are not present in the
string, just print 0 for that query.