303035: CF591B. Rebranding

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

Description

Rebranding

题意翻译

一个小而骄傲的公司的名字由N小写的英文字母组成。该公司已决定尝试重新品牌化:一个积极的营销策略,其中包括一系列措施来改变品牌(无论是对公司和其生产的产品)或其组成部分:名称,标志,口号。他们决定以这个名字开头。 为此,公司先后聘请了M设计人员。一旦一个公司雇佣了第i个设计师,他立即为创建一个新的公司名称做出贡献:他取名字的最新版本并替换所有的字母x【i】变为y【i】,y【i】变为x【i】 …在最后一个设计师的工作之后,名字的版本变成了公司的新名称。 Arkady经理最近在这家公司找到了一份工作,但是他已经沉浸在团队合作精神中,并且非常担心品牌重塑能不能成功。自然而然地,他迫不及待地想知道公司会收到什么新名称。 满足Arkady的好奇心,告诉他名字的最终版本。

题目描述

The name of one small but proud corporation consists of $ n $ lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slogan. They decided to start with the name. For this purpose the corporation has consecutively hired $ m $ designers. Once a company hires the $ i $ -th designer, he immediately contributes to the creation of a new corporation name as follows: he takes the newest version of the name and replaces all the letters $ x_{i} $ by $ y_{i} $ , and all the letters $ y_{i} $ by $ x_{i} $ . This results in the new version. It is possible that some of these letters do no occur in the string. It may also happen that $ x_{i} $ coincides with $ y_{i} $ . The version of the name received after the work of the last designer becomes the new name of the corporation. Manager Arkady has recently got a job in this company, but is already soaked in the spirit of teamwork and is very worried about the success of the rebranding. Naturally, he can't wait to find out what is the new name the Corporation will receive. Satisfy Arkady's curiosity and tell him the final version of the name.

输入输出格式

输入格式


The first line of the input contains two integers $ n $ and $ m $ ( $ 1<=n,m<=200000 $ ) — the length of the initial name and the number of designers hired, respectively. The second line consists of $ n $ lowercase English letters and represents the original name of the corporation. Next $ m $ lines contain the descriptions of the designers' actions: the $ i $ -th of them contains two space-separated lowercase English letters $ x_{i} $ and $ y_{i} $ .

输出格式


Print the new name of the corporation.

输入输出样例

输入样例 #1

6 1
police
p m

输出样例 #1

molice

输入样例 #2

11 6
abacabadaba
a b
b c
a d
e g
f a
b b

输出样例 #2

cdcbcdcfcdc

说明

In the second sample the name of the corporation consecutively changes as follows: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/b0c9599f7e4282de011e545b3b2138ce054cf709.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/b503b89dff83c09912a9706615e9f382f03f5909.png) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/e277cc6136141b35244d23f5857e2b4088822639.png) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/cfe2461ca78ee24244102008b38c52289020e201.png) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/c06bdcdcec7417c4f543399c6c3d126f67ecf0a6.png) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF591B/e46b37134536ad3b6c864840e66c2932fc25c838.png)

Input

题意翻译

一个小而骄傲的公司的名字由N小写的英文字母组成。该公司已决定尝试重新品牌化:一个积极的营销策略,其中包括一系列措施来改变品牌(无论是对公司和其生产的产品)或其组成部分:名称,标志,口号。他们决定以这个名字开头。 为此,公司先后聘请了M设计人员。一旦一个公司雇佣了第i个设计师,他立即为创建一个新的公司名称做出贡献:他取名字的最新版本并替换所有的字母x【i】变为y【i】,y【i】变为x【i】 …在最后一个设计师的工作之后,名字的版本变成了公司的新名称。 Arkady经理最近在这家公司找到了一份工作,但是他已经沉浸在团队合作精神中,并且非常担心品牌重塑能不能成功。自然而然地,他迫不及待地想知道公司会收到什么新名称。 满足Arkady的好奇心,告诉他名字的最终版本。

加入题单

算法标签: