Problem: Tyrion, son of Tywin was released from the dungeons of vale after his champion Bronn defeated Ser Vardis in the trial by combat.

As a Lannister always pays his debts, he invited Bronn to play a game of mastermind with him.

The game is played as follows:

Tyrion has rocks of 7 colours. (As he is rich, he has infinitely many of each colour)
He makes a sequence of length 10 from these rocks.
The colours are: VIBGYOR (Each letter is associated to corresponding colour)

Now Bronn chooses the number of times he wants to play. (No. of test cases)
Then each time he has to guess a sequence of 10 rocks.
Based on each guess Tyrion rewards Bronn 1 gold coin for a rock which is correct in colour and position both and 1 silver coin for a rock which is correct in colour only.

Input:
The first line contains the secret sequence of Tyrion
The next line contains an integer t, no. of times bronn choses to play.
The next t lines each contain a sequence.

Output:
For each t lines you have to print the number of golds followed by number of silvers.

Eg:

Input:

ROYGBIVVOG

3

VIBGYORROY

RRRRRVVVVV

ROYGBIVVGO

Output:

2 6

3 0

8 2

Input:

IBVIGBVVRV

5

GGVRIOYGRO

YROGVBIOBG

ORYVYBYOOI

BBIRRVVIVV

VRRVOGGGGO

Output:

2 2

1 5

1 3

3 6

0 4

SAMPLE INPUT
ROYGBIVVOG
3
VIBGYORROY
RRRRRVVVVV
ROYGBIVVGO

SAMPLE OUTPUT
2 6
3 0
8 2

Solution (in PYTHON):

Solution:
from sys import stdin
a = stdin.readline().strip()
di = {}
for i in a:
	di[i] = di.get(i,0) + 1

t = int(stdin.readline())
for _ in xrange(t):
	b = stdin.readline().strip()
	fir = 0
	sec = 0
	for i in xrange(10):
		if a[i] == b[i]:
			fir+=1
	hi = {}
	for i in b:
		hi[i] = hi.get(i,0)+1
	for i in hi:
		x = hi.get(i,0)
		y = di.get(i,0)
		if x>=y:
			sec += y
		else:
			sec += x
	print fir,sec-fir