#abc314d. D - LOWER

D - LOWER

Score : 400400 points

问题描述

你得到一个长度为 NN 的字符串 SS,由大小写英文字母组成。

现在要在字符串 SS 上执行 QQ 次操作。第 ii 次操作 (1iQ)(1\leq i\leq Q) 由一个包含两个整数和一个字符的元组 (ti,xi,ci)(t _ i,x _ i,c _ i) 表示,如下所示:

  • ti=1t _ i=1,将 SS 中的第 xix _ i 个字符改为 cic _ i
  • ti=2t _ i=2,将 SS 中所有大写字母转换为小写(此操作不使用 xi,cix _ i,c _ i)。
  • ti=3t _ i=3,将 SS 中所有小写字母转换为大写(此操作不使用 xi,cix _ i,c _ i)。

输出经过 QQ 次操作后的字符串 SS

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a string SS of length NN consisting of uppercase and lowercase English letters.

Let us perform QQ operations on the string SS. The ii-th operation (1iQ)(1\leq i\leq Q) is represented by a tuple (ti,xi,ci)(t _ i,x _ i,c _ i) of two integers and one character, as follows.

  • If ti=1t _ i=1, change the xix _ i-th character of SS to cic _ i.
  • If ti=2t _ i=2, convert all uppercase letters in SS to lowercase (do not use xi,cix _ i,c _ i for this operation).
  • If ti=3t _ i=3, convert all lowercase letters in SS to uppercase (do not use xi,cix _ i,c _ i for this operation).

Print the SS after the QQ operations.

Constraints

  • 1N5×1051\leq N\leq5\times10^5
  • SS is a string of length NN consisting of uppercase and lowercase English letters.
  • 1Q5×1051\leq Q\leq5\times10^5
  • 1ti3 (1iQ)1\leq t _ i\leq3\ (1\leq i\leq Q)
  • If ti=1t _ i=1, then 1xiN (1iQ)1\leq x _ i\leq N\ (1\leq i\leq Q).
  • cic _ i is an uppercase or lowercase English letter.
  • If ti1t _ i\neq 1, then xi=0x _ i=0 and ci=c _ i= 'a'.
  • N,Q,ti,xiN,Q,t _ i,x _ i are all integers.

Input

The input is given from Standard Input in the following format:

NN

SS

QQ

t1t _ 1 x1x _ 1 c1c _ 1

t2t _ 2 x2x _ 2 c2c _ 2

\vdots

tQt _ Q xQx _ Q cQc _ Q

Output

Print the answer in a single line.

Sample Input 1

7
AtCoder
5
1 4 i
3 0 a
1 5 b
2 0 a
1 4 Y

Sample Output 1

atcYber

Initially, the string SS is AtCoder.

  • The first operation changes the 44-th character to i, changing SS to AtCider.
  • The second operation converts all lowercase letters to uppercase, changing SS to ATCIDER.
  • The third operation changes the 55-th character to b, changing SS to ATCIbER.
  • The fourth operation converts all uppercase letters to lowercase, changing SS to atciber.
  • The fifth operation changes the 44-th character to Y, changing SS to atcYber.

After the operations, the string SS is atcYber, so print atcYber.

Sample Input 2

35
TheQuickBrownFoxJumpsOverTheLazyDog
10
2 0 a
1 19 G
1 13 m
1 2 E
1 21 F
2 0 a
1 27 b
3 0 a
3 0 a
1 15 i

Sample Output 2

TEEQUICKBROWMFiXJUGPFOVERTBELAZYDOG

update @ 2024/3/10 08:58:20