English · Original
Chinese · Translation
Formal · Original
%epigraph%%epigraphtext%_Are you going to Scarborough Fair?Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
_%endepigraphtext%%endepigraph%Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length _n_.
Willem needs to do _m_ operations, each operation has four parameters _l_, _r_, _c_1, _c_2, which means that all symbols _c_1 in range \[_l_, _r_\] (from _l_\-th to _r_\-th, including _l_ and _r_) are changed into _c_2. String is 1-indexed.
Grick wants to know the final string after all the _m_ operations.
## Input
The first line contains two integers _n_ and _m_ (1 ≤ _n_, _m_ ≤ 100).
The second line contains a string _s_ of length _n_, consisting of lowercase English letters.
Each of the next _m_ lines contains four parameters _l_, _r_, _c_1, _c_2 (1 ≤ _l_ ≤ _r_ ≤ _n_, _c_1, _c_2 are lowercase English letters), separated by space.
## Output
Output string _s_ after performing _m_ operations described above.
[samples]
## Note
For the second example:
After the first operation, the string is _wxxak_.
After the second operation, the string is _waaak_.
After the third operation, the string is _gaaak_.
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem 正带着女孩前往第28号岛屿的最高建筑,但他们都不知道如何到达那里。
Willem 向他的朋友 Grick 寻求方向,Grick 帮助了他们,并给了他们一个任务。
尽管女孩想帮忙,Willem 却坚持要自己完成。
Grick 给了 Willem 一个长度为 $n$ 的字符串。
Willem 需要执行 $m$ 次操作,每次操作有四个参数 $l, r, c1, c2$,表示将范围 $[l, r]$(从第 $l$ 个到第 $r$ 个字符,包含 $l$ 和 $r$)中所有字符 $c1$ 替换为 $c2$。字符串采用 1-索引。
Grick 想知道在执行完所有 $m$ 次操作后,最终的字符串是什么。
第一行包含两个整数 $n$ 和 $m$ $ (1 ≤ n, m ≤ 100)$。
第二行包含一个长度为 $n$ 的字符串 $s$,由小写英文字母组成。
接下来的 $m$ 行,每行包含四个参数 $l, r, c1, c2$ ($1 ≤ l ≤ r ≤ n$,$c1, c2$ 为小写英文字母),以空格分隔。
请输出执行上述 $m$ 次操作后的字符串 $s$。
对于第二个示例:
第一次操作后,字符串为 _wxxak_。
第二次操作后,字符串为 _waaak_。
第三次操作后,字符串为 _gaaak_。
## Input
第一行包含两个整数 $n$ 和 $m$ $ (1 ≤ n, m ≤ 100)$。第二行包含一个长度为 $n$ 的字符串 $s$,由小写英文字母组成。接下来的 $m$ 行,每行包含四个参数 $l, r, c1, c2$ ($1 ≤ l ≤ r ≤ n$,$c1, c2$ 为小写英文字母),以空格分隔。
## Output
请输出执行上述 $m$ 次操作后的字符串 $s$。
[samples]
## Note
对于第二个示例:
第一次操作后,字符串为 _wxxak_。
第二次操作后,字符串为 _waaak_。
第三次操作后,字符串为 _gaaak_。
**Definitions**
Let $ n, m \in \mathbb{Z}^+ $ with $ 1 \leq n, m \leq 100 $.
Let $ s = s_1 s_2 \dots s_n $ be a string of length $ n $, where $ s_i \in \{a, b, \dots, z\} $ for all $ i \in \{1, \dots, n\} $.
Let $ O = \{(l_j, r_j, c_{1,j}, c_{2,j}) \mid j \in \{1, \dots, m\}\} $ be a sequence of $ m $ operations, where for each $ j $:
- $ 1 \leq l_j \leq r_j \leq n $,
- $ c_{1,j}, c_{2,j} \in \{a, b, \dots, z\} $,
- and $ c_{1,j} \neq c_{2,j} $ (implied by context).
**Constraints**
1. $ 1 \leq n, m \leq 100 $
2. For all $ j \in \{1, \dots, m\} $:
- $ 1 \leq l_j \leq r_j \leq n $
- $ c_{1,j}, c_{2,j} \in \Sigma $, where $ \Sigma $ is the set of lowercase English letters
**Objective**
Apply each operation $ j \in \{1, \dots, m\} $ sequentially to $ s $:
For each $ i \in \{l_j, \dots, r_j\} $, set $ s_i \leftarrow c_{2,j} $ if $ s_i = c_{1,j} $.
Output the final string $ s $ after all $ m $ operations.
API Response (JSON)
{
"problem": {
"name": "A. Scarborough Fair",
"description": {
"content": "%epigraph%%epigraphtext%_Are you going to Scarborough Fair?Parsley, sage, rosemary and thyme. Remember me to one who lives there. He once was the true love of mine. _%endepigraphtext%%endepigraph%W",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF897A"
},
"statements": [
{
"statement_type": "Markdown",
"content": "%epigraph%%epigraphtext%_Are you going to Scarborough Fair?Parsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\n_%endepigraphtext%%endepigraph%W...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "Parsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\nWillem 正带着女孩前往第28号岛屿的最高建筑,但他们都不知道如何到达那里。\n\nWillem 向他的朋友 Grick 寻求方向,Grick 帮助了他们,并给了他们一个任务。\n\n尽...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ n, m \\in \\mathbb{Z}^+ $ with $ 1 \\leq n, m \\leq 100 $. \nLet $ s = s_1 s_2 \\dots s_n $ be a string of length $ n $, where $ s_i \\in \\{a, b, \\dots, z\\} $ for all $ i \\in \\{1, \\d...",
"is_translate": false,
"language": "Formal"
}
]
}