407134: GYM102697 105 Planet of Visions

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

105. Planet of Visionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Planet of Visions

You are trying to test your vision using an eye test chart, and you want to see if you have 20/20 vision or not. You attempt read the text on the chart, and you unfortunately get some of them wrong. Now, you're curious how close you were to correctly reading the text.

You consider some pairs of letters similar. For example, "D" and "P" look relatively similar from far away. Given the letter pairs that you consider to be similar to each other, your task is to figure out how many of the letters you got right, how many you were close on (the letters were similar), and how many you got completely wrong (the letters were not similar). Note that letters are also similar to letters that its similar letters are similar to. For example, if "D" and "P" are similar, and "D" and "G" are similar, "P" and "G" are by definition similar as well.

Input

The first line of input contains a single string $$$s$$$, consisting of only capital letters: the correct text on the eye chart. The next line of input contains a single string $$$t$$$, consisting of only capital letters: your incorrect interpretation of the text on the eye chart. $$$s$$$ and $$$t$$$ are guaranteed to be the same length. The second line of input contains a single positive integer $$$n$$$: the number of letter pairs that you consider to be similar. The next $$$n$$$ lines contain two space-separated capital letters: a letter pair where the first letter is similar to the second, and the second letter is similar to the first.

Output

Output three space separated integers $$$a$$$, $$$b$$$, and $$$c$$$: the number of characters you got right, the number of characters you were close on, and the number of characters you got completely wrong, respectively, according to the definitions above.

ExamplesInput
DEFPOTEC
PEFDOTED
3
D P
C D
A Z
Output
5 3 0
Input
DEFPOTEC
ABCDEFGH
7
A H
D H
B Z
Z Y
Y E
F C
C T
Output
0 4 4

加入题单

上一题 下一题 算法标签: