CF897A.Scarborough Fair

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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 nn .

Willem needs to do mm operations, each operation has four parameters l,r,c1,c2l,r,c_{1},c_{2} , which means that all symbols c1c_{1} in range [l,r][l,r] (from ll -th to rr -th, including ll and rr ) are changed into c2c_{2} . String is 1-indexed.

Grick wants to know the final string after all the mm operations.

输入格式

The first line contains two integers nn and mm (1<=n,m<=100)(1<=n,m<=100) .

The second line contains a string ss of length nn , consisting of lowercase English letters.

Each of the next mm lines contains four parameters l,r,c1,c2l,r,c_{1},c_{2} ( 1<=l<=r<=n1<=l<=r<=n , c1,c2c_{1},c_{2} are lowercase English letters), separated by space.

输出格式

Output string ss after performing mm operations described above.

输入输出样例

  • 输入#1

    3 1
    ioi
    1 1 i n
    

    输出#1

    noi
  • 输入#2

    5 3
    wxhak
    3 3 h x
    1 5 x a
    1 3 w g
    

    输出#2

    gaaak

说明/提示

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.

首页