VK Cup 2012 Qualification Round 2
C
String Manipulation 1.0
Codeforces
1400
原题
← BD →
翻译中…

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 $*s*$, a user can pick number $*p*$ and character $*c*$ and delete the $*p*$-th occurrence of character $*c*$ 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 $*t*$, where $*t*$ is a concatenation of $*k*$ copies of string $*s*$. Also, Polycarpus knows the sequence of this user's name changes. Help Polycarpus figure out the user's final name.

翻译中…

Input

翻译中…

The first line contains an integer $*k*$ ($1 ≤ *k* ≤ 2000$). The second line contains a non-empty string $*s*$, consisting of lowercase Latin letters, at most $100$ characters long. The third line contains an integer $*n*$ ($0 ≤ *n* ≤ 20000$) — the number of username changes. Each of the next $*n*$ lines contains the actual changes, one per line. The changes are written as "$*p*_{*i*}$ $*c*_{*i*}$" (without the quotes), where $*p*_{*i*}$ ($1 ≤ *p*_{*i*} ≤ 200000$) is the number of occurrences of letter $*c*_{*i*}$, $*c*_{*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.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
2
bac
3
2 a
1 b
2 c
Output #1
acb
InputCopy OutputCopy
Input #2
1
abacaba
4
1 a
1 a
1 c
2 b
Output #2
baa
InputCopy OutputCopy
题目信息
题号
159C
时间限制
3 s
内存限制
256 MB
标签
*special
二分
暴力
数据结构
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。