Secret Code

Given a secret code with all distinct characters, score each same-length guess by counting exact position matches and characters present in the code but at a wrong position.

Easy3Hash mapStringImplementationBrute forceInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Marty is stuck in the past and wants to get back to his own 1985. He has already made his parents fall in love with each other, and he has found plutonium. All that is left is to start the time machine and begin the trip. One problem remains. Starting the time machine requires a secret code, and only Doc knows that code. Marty knows just two things about it: it is made of several different characters, and he knows its length. While he waits for Doc, he guesses the code by entering different combinations of characters.

Doc has come back and entered the correct code. Marty wants to know how close his guesses were. For each of Marty's attempts, find the number of characters that belong to the code and stand in the correct position, and the number of characters that belong to the code but stand in a wrong position.

Input

The first line contains the correct secret code ss. The code is made of uppercase English letters and digits, and all characters in the code are different, so its length is between 1 and 36.

The second line contains an integer nn (1n1051 \le n \le 10^5), the number of Marty's attempts.

Each of the next nn lines contains one attempt. Every attempt has the same length as ss, is made of uppercase English letters and digits, and all characters within one attempt are different.

Output

For each attempt print two integers aa and bb on one line, separated by a space. aa is the number of characters that belong to the code and stand in the correct position, and bb is the number of characters that belong to the code but stand in a wrong position.