{"raw_statement":[{"iden":"statement","content":"Planet of Visions\n\nYou 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.\n\nYou 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.\n\nThe 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.\n\nOutput 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.\n\n"},{"iden":"input","content":"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."},{"iden":"output","content":"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."},{"iden":"examples","content":"InputDEFPOTEC\nPEFDOTED\n3\nD P\nC D\nA Z\nOutput5 3 0\nInputDEFPOTEC\nABCDEFGH\n7\nA H\nD H\nB Z\nZ Y\nY E\nF C\nC T\nOutput0 4 4\n"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ s, t \\in \\Sigma^* $ be two strings of equal length $ L $, where $ \\Sigma = \\{A, B, \\dots, Z\\} $.  \nLet $ G = (V, E) $ be an undirected graph where $ V = \\Sigma $, and $ E $ contains edges $ \\{u, v\\} $ for each given similar letter pair (symmetric and transitive closure applied).  \nLet $ \\sim $ denote the equivalence relation induced by the transitive closure of $ E $: $ u \\sim v $ iff $ u $ and $ v $ are in the same connected component of $ G $.\n\n**Constraints**  \n1. $ |s| = |t| = L $, $ L \\geq 1 $  \n2. $ n \\in \\mathbb{Z}^+ $, $ n \\leq \\binom{26}{2} $  \n3. Each similar pair consists of two distinct uppercase letters.  \n\n**Objective**  \nCompute:  \n- $ a = \\left| \\{ i \\in \\{1, \\dots, L\\} \\mid s_i = t_i \\} \\right| $  \n- $ b = \\left| \\{ i \\in \\{1, \\dots, L\\} \\mid s_i \\neq t_i \\text{ and } s_i \\sim t_i \\} \\right| $  \n- $ c = \\left| \\{ i \\in \\{1, \\dots, L\\} \\mid s_i \\neq t_i \\text{ and } \\neg (s_i \\sim t_i) \\} \\right| $  \n\nOutput: $ a, b, c $","simple_statement":"You are given two strings of equal length: the correct text and your guess.  \nSome letters are “similar” (including transitive similarity — if A~B and B~C, then A~C).  \nCount:  \n- how many letters match exactly,  \n- how many are different but similar,  \n- how many are different and not similar.  \n\nOutput three numbers: exact matches, similar mismatches, totally wrong.","has_page_source":false}