CF159C.String Manipulation 1.0

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name ss , a user can pick number pp and character cc and delete the pp -th occurrence of character cc from the name. After the user changed his name, he can't undo the change.

For example, one can change name "arca" by removing the second occurrence of character "a" to get "arc".

Polycarpus learned that some user initially registered under nickname tt , where tt is a concatenation of kk copies of string ss . Also, Polycarpus knows the sequence of this user's name changes. Help Polycarpus figure out the user's final name.

输入格式

The first line contains an integer kk ( 1<=k<=20001<=k<=2000 ). The second line contains a non-empty string ss , consisting of lowercase Latin letters, at most 100100 characters long. The third line contains an integer nn ( 0<=n<=200000<=n<=20000 ) — the number of username changes. Each of the next nn lines contains the actual changes, one per line. The changes are written as " pip_{i} cic_{i} " (without the quotes), where pip_{i} ( 1<=pi<=2000001<=p_{i}<=200000 ) is the number of occurrences of letter cic_{i} , cic_{i} is a lowercase Latin letter. It is guaranteed that the operations are correct, that is, the letter to be deleted always exists, and after all operations not all letters are deleted from the name. The letters' occurrences are numbered starting from 1.

输出格式

Print a single string — the user's final name after all changes are applied to it.

输入输出样例

  • 输入#1

    2
    bac
    3
    2 a
    1 b
    2 c
    

    输出#1

    acb
    
  • 输入#2

    1
    abacaba
    4
    1 a
    1 a
    1 c
    2 b
    

    输出#2

    baa
    

说明/提示

Let's consider the first sample. Initially we have name "bacbac"; the first operation transforms it into "bacbc", the second one — to "acbc", and finally, the third one transforms it into "acb".

首页