extractFrequency that takes a string w and returns the frequency of its lexicographically smallest character.extractFrequency to each word in words and store the results in a list.words.ans to store the results for each query.queries, calculate its frequency using extractFrequency.ans list.ans list.