{"problem":{"name":"Many Replacement","description":{"content":"You are given a string $S$ of length $N$ consisting of lowercase English letters. You will perform an operation $Q$ times on the string $S$. The $i$\\-th operation $(1\\leq i\\leq Q)$ is represented by a","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc342_c"},"statements":[{"statement_type":"Markdown","content":"You are given a string $S$ of length $N$ consisting of lowercase English letters.\nYou will perform an operation $Q$ times on the string $S$. The $i$\\-th operation $(1\\leq i\\leq Q)$ is represented by a pair of characters $(c _ i,d _ i)$, which corresponds to the following operation:\n\n*   Replace all occurrences of the character $c _ i$ in $S$ with the character $d _ i$.\n\nPrint the string $S$ after all operations are completed.\n\n## Constraints\n\n*   $1\\leq N\\leq2\\times10^5$\n*   $S$ is a string of length $N$ consisting of lowercase English letters.\n*   $1\\leq Q\\leq2\\times10^5$\n*   $c _ i$ and $d _ i$ are lowercase English letters $(1\\leq i\\leq Q)$.\n*   $N$ and $Q$ are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$S$\n$Q$\n$c _ 1$ $d _ 1$\n$c _ 2$ $d _ 2$\n$\\vdots$\n$c _ Q$ $d _ Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc342_c","tags":[],"sample_group":[["7\natcoder\n4\nr a\nt e\nd v\na r","recover\n\n$S$ changes as follows: `atcoder` → `atcodea` → `aecodea` → `aecovea` → `recover`. For example, in the fourth operation, all occurrences of `a` in $S={}$`aecovea` (the first and seventh characters) are replaced with `r`, resulting in $S={}$`recover`.\nAfter all operations are completed, $S={}$`recover`, so print `recover`."],["3\nabc\n4\na a\ns k\nn n\nz b","abc\n\nThere may be operations where $c _ i=d _ i$ or $S$ does not contain $c _ i$."],["34\nsupercalifragilisticexpialidocious\n20\ng c\nl g\ng m\nc m\nr o\ns e\na a\no f\nf s\ne t\nt l\nd v\np k\nv h\nx i\nh n\nn j\ni r\ns i\nu a","laklimamriiamrmrllrmlrkramrjimrial"]],"created_at":"2026-03-03 11:01:14"}}