Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Transformation

  Write a program which performs a sequence of commands to a given string $str$. The command is one of:

print a b: print from the a-th character to the b-th character of $str$

reverse a b: reverse from the a-th character to the b-th character of $str$

replace a b p: replace from the a-th character to the b-th character of $str$ with p

  Note that the indices of $str$ start with 0.

Input

  In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.

Output

For each print command, print a string in a line.

Constraints

$1 \leq $ length of $str \leq 1000$

$1 \leq q \leq 100$

$0 \leq a \leq b < $ length of $str$

for replace command, $b - a + 1 = $ length of $p$

Sample Input 1

abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4

Sample Output 1

xaze

Sample Input 2

xyz
3
print 0 2
replace 0 2 abc
print 0 2

Sample Output 2

xyz
abc



Sample input:
abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4


Sample output:
xaze

Submission status: Runtime Error

Solution code:
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???
while 1:
	str = input()
	op_num = int( input() )
	# for i in range(op_num):
	# 	op = input().split()
	# 	a = int(op[1])
	# 	b = int(op[2])
		# if op[0]=="replace":
		# 	str = str.replace(str[ a:b+1 ], op[3])
		# elif op[0]=="reverse":
		# 	str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		# elif op[0]=="print":
		# 	print(str[a:b+1])

Submission status: Runtime Error

Solution code:
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???
while 1:
	# str = input()
	# op_num = int( input() )
	# for i in range(op_num):
	# 	op = input().split()
	# 	a = int(op[1])
	# 	b = int(op[2])
		# if op[0]=="replace":
		# 	str = str.replace(str[ a:b+1 ], op[3])
		# elif op[0]=="reverse":
		# 	str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		# elif op[0]=="print":
		# 	print(str[a:b+1])

Submission status: Runtime Error

Solution code:
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		str = str.replace(str[ a:b+1 ], op[3])
	elif op[0]=="reverse":
		# str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		str = str[:a] + str[a:b+1][::-1] + str[b+1:]
	else op[0]=="print":
		print(str[a:b+1])

Submission status: Runtime Error

Solution code:
string = list(input())
times = int(input())
for i in range(times):
    order = input().split()
    if order[0] == "replace":
        replace_string = order[3]
        count = 0
        for j in range(int(order[1]), int(order[2]) + 1):
            string[j] = replace_string[count]
            count += 1
            #print(count)
    elif order[0] == "reverse":
        reverse_string = string[int(order[1]):int(order[2]) + 1]
        reverse_string.reverse()
        for j in range(int(order[1]), int(order[2]) + 1):
            string[j] = reverse_string[j]
        #string[int(order[1]):int(order[2]) + 1].reverse()
        #print(string)
        #string[int(order[1]):int(order[2])] = string[int(order[1]):int(order[2])].reverse()
    elif order[0] == "print":
        print("".join(string[int(order[1]):int(order[2]) + 1]))

Submission status: Runtime Error

Solution code:
string = list(input())
times = int(input())
#a = [int(i) for i in range(0,5)]
#print(a)
for i in range(times):
    order = input().split()
    #print(order)
    if order[0] == "replace":
        replace_string = order[3]
        #print(string)
        count = 0
        for j in range(int(order[1]), int(order[2]) + 1):
            string[j] = replace_string[count]
            count += 1
            #print(count)
        #print(string)
    elif order[0] == "reverse":
        #print(string)
        reverse_string = string[int(order[1]):int(order[2]) + 1]
        reverse_string.reverse()
        for j in range(int(order[1]), int(order[2]) + 1):
            string[j] = reverse_string[j]
        #print(j)
        #print(string)
        #string[int(order[1]):int(order[2]) + 1].reverse()
        #print(string)
        #string[int(order[1]):int(order[2])] = string[int(order[1]):int(order[2])].reverse()
    elif order[0] == "print":
        #print(string)
        print("".join(string[int(order[1]):int(order[2]) + 1]))
        #print(string)

Submission status: Runtime Error

Solution code:
round=int(input())
T_pt=0
H_pt=0

for i in range(round):
	pair=raw_input().split(" ")
	T_card=pair[0].lower()
	H_card=pair[1].lower()

	if T_card<H_card:
		H_pt+=3
	elif T_card>H_card:
		T_pt+=3
	else:
		T_pt+=1
		H_pt+=1
print T_pt,H_pt

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())

for qi in range(q):
    command = input().split()

    a = command[1]
    b = command[2]
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1]) + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + p + s[b + 1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
for pi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1][::-1]) + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + x[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
for pi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1][::-1]) + s[b + 1:]
    else:
        p = command[3] == 'replace':
        s = s[:a] + x[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
for pi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1][::-1]) + s[b + 1:]
    else:
        command[3] == 'replace':
        s = s[:a] + x[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())
for pi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1][::-1]) + s[b + 1:]
    else:
        command[3] == 'replace':
        s = s[:a] + a[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
 
for i in range(int(input())):
    cmd = input().split()
          s = s[:a] + cmd[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
q = input()

for qi in range(q):
    command = input().split()
    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + p + s[b + 1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())

for qi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[1] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1]) + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + p + s[b+1:]

Submission status: Runtime Error

Solution code:
s = input()
q = int(input())

for qi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[1] == 'reverse':
        s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
    else:
        p = command[3]
        s = s[:a] + p + s[b+1:]

Submission status: Runtime Error

Solution code:
s = raw_input()
n = int(raw_input())

for i in range(n):
    message = raw_input().split(" ")
    a, b = int(message[1]), int(message[2])

    if message[0] == "print":
        print(s[a:b+1])
    elif message[0] == "reverse":
        s[a:b+1] = s[a:b+1][::-1]
    elif message[0] == "replace":
        s = s[:a] + message[3] + s[b:]

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())
for i in range(n):
 a = list(input().split())
 temp = s[int(a[1])+1:int(a[2])+2]
 if a[0] == 'replace':
  s.replace(temp, a[3])
 elif a[0] == 'reverse':
  s.replace(temp, temp[::-1])
 elif a[0] == 'print':
  print(s[int(a[1])+1:int(a[2])+2)

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())
for i in range(n):
 a = list(input().split())
 temp = s[int(a[1])-1:int(a[2])]
 if a[0] == 'replace':
  s.replace(temp, a[3])
 elif a[0] == 'reverse':
  temp2 = temp[::-1]
  s.replace(temp, temp2)
 elif a[0] == 'print':
  print(s[int(a[1])-1:int(a[2]))

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())
for i in range(n):
 a = list(input().split())
 temp = s[int(a[1]):int(a[2])+1]
 if a[0] == 'replace':
  temp3 = a[3]
  s = list(s)
  seq = 0
  for i in range(int(a[1]), int(a[2])+1):
   s[i] = temp3[seq]
   seq += 1
 elif a[0] == 'reverse':
  temp2 = temp[::-1]
  s = s.replace(temp, temp2, 1)
 elif a[0] == 'print':
  print(temp)

Submission status: Runtime Error

Solution code:
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        if instruction[1] == instruction[2]:
            string[instruction[1]] = instruction[3]
        else:
            string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[3], 1)

Submission status: Runtime Error

Solution code:
string = input()
q = int(input())
for c in range(0,q):
    instruction = input().split(' ')
    if instruction[0] == 'print':
        print(string[int(instruction[1]):int(instruction[2]) + 1])
    elif instruction[0] == 'reverse':
        string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
    elif instruction[0] == 'replace':
        if instruction[1] == instruction[2]:
            string[int(instruction[1])] = instruction[3]
        else:
            string = string.replace(string[int(instruction[1]):int(instruction[2])+1], instruction[3], 1)

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())
for i in ragne(n):
    cmd = input().split()
    a,b = map(int,[cmd[1],cmd[2]])
    if cmd[0][0] == 'p':print(s)
    elif cmd[0] =='replace':
        s = s[:a] + cmd[3] + s[b+1:]
    elif cmd[0] =='reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]

Submission status: Runtime Error

Solution code:
x=[i for i in input()]
y=[i for i in range(len(x))]
y=x.copy()
n=int(input())
for i in range(n):
    c=[j for j in input().split()]
    if len(c)==4:
        for j in range(len(c[3])):
            y[j+int(c[1])]=list(c[3])[j]
        x=y.copy()
    elif c[0]=="print":
        for j in range(int(c[1]),int(c[2])+1):
            print(x[j],end="")
        print()
    else:
        for j in range(int(c[1]),int(c[2])):
            y[int(c[2])-j]=x[int(c[1])+j]
        x=y.copy()

Submission status: Runtime Error

Solution code:
def f1(a,b,s):
	print(s[a:b+1])
	return s

def f2(a,b,s):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(a,b,p,s):
	return s[:a] + p + s[b+1:]

data = input()
q = int(input())
functions = {'print':f1, 'reverse':f2, 'replace':f3}

for i in range(q):
	temp = [s if s.isalpha() else int(s) for s in input().split(' ')]
	f = temp.pop(0)
	data = functions[f](*temp,data)

Submission status: Runtime Error

Solution code:
def f1(a,b,s):
	print(s[a:b+1])
	return s

def f2(a,b,s):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(a,b,p,s):
	return s[:a] + p + s[b+1:]
'''
data = input()
q = int(input())
'''
data = 'abcdefg'
q = 1
functions = {'print':f1, 'reverse':f2, 'replace':f3}

for i in range(q):
	temp = [s if s.isalpha() else int(s) for s in input().split(' ')]
	f = temp.pop(0)
	data = functions[f](*temp,data)

Submission status: Runtime Error

Solution code:
def main():
    STR = input()
    Q = int(input())
    ORDER = tuple(tuple(input().split()) for _ in range(Q))

    str_ = list(STR)
    for order in ORDER:
        s = int(order[1])
        e = int(order[2]) + 1
        a = str_[s:e]
        if order[0] == 'print':
            print(''.join(a))
        elif order[0] == 'reverse':
            a = a[::-1]
            for i in range(s, e):
                str_[i] = a[i]
        elif order[0] == 'replace':
            j = s
            for i in range(s, e):
                str_[i] = order[3][i-j]

main()

Submission status: Runtime Error

Solution code:
str=input()
n=int(input())
for i in range(n):
    s=input().split()
    a=int(s[1])
    b=int(s[2])
    if s[0] == 'replace':
        str=str[:a]+s[3]+str[b:]
    elif s[0] == 'reverse':
        str=str[:a]+reversed(str[a:b])+str[b:]
    else:
        print(str[a:b])

Submission status: Runtime Error

Solution code:

s = input()
????
for i in range(int(input())):
????????cmd = input().split()
????????a,b = [int(x) for x in cmd[1:3]]
????
????????if cmd[0] == 'print':
????????????????print(s[a:b+1])
????????elif cmd[0] == 'reverse':
????????????????s = s[:a] + s[a:b+1][::-1] + s[b+1:]
????????elif cmd[0] == 'replace':
????????????????s = s[:a] + cmd[3] + s[b+1:]

Submission status: Runtime Error

Solution code:
word = input()
order_num = int(input())
orders = []
for i in range(order_num):
    orders.append(input().split())
for o in orders:
    order = o[0]
    if order == 'replace':
        word = word[:int(o[1])] + o[3] + word[int(o[2]+1)]
    elif order == 'reverse':
        word = word[:int(o[1])] + word[int(o[1]):int(o[2])][::-1] + word[int(o[2])+1]
    else:
        print(word[int(o[1]):int(o[2])+1])

Submission status: Runtime Error

Solution code:
s=input()
for _ in range(int(input())):
 a=input().split()
 o=a[0];i=int(a[1]);j=int(a[2])+1
 if'p'==o[0]:print(s[i:j])
 else:
  t=(s[i:j][::-1],a[3])['p'==o[2]]
  s=s[0:i]+t+s[j:]

Submission status: Runtime Error

Solution code:
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    elif inp[0] == 'replace':
        string = string[:a] + inp[3] + string[b+1]

Submission status: Runtime Error

Solution code:
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    else:
        string = string[:a] + inp[3] + string[b+1]

Submission status: Runtime Error

Solution code:
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a:b+1])
    elif inp[0] == 'reverse':
        string = string[:a] + string[a:b+1][::-1] +string[b+1:]
    else:
        string = string[:a] + inp[3] + string[b+1]

Submission status: Runtime Error

Solution code:
s=raw_input()
n=input()
for _ in range(n):
	i=raw_input.split()
	if i[0]=='print':
		print s[int(i[1]):int(i[2])]
	elif i[0]=='reverse':
		for j in range(1+(int(i[1])+int(i[2]))/2):
			s[int(i[2])-j]=s[int(i[1])+j]
	else:
		for k in range(int(i[1]),int(i[2])+1):
			s[k]=i[4][k-int(i[1])]

Submission status: Runtime Error

Solution code:
def transformate(s, command):
    command, *op = command.split()

    op[0] = int(op[0])
    op[1] = int(op[1])
        
    if command == 'replace':
        return s[0:op[0]] + op[2] + s[op[1]+1:]
    elif command == 'reverse':
        return s[0:op[0]] + s[op[0]:op[1]+1][::-1] + s[op[1]+1:]
    elif command == 'print':
        print(output)
        return s

if __name__ == '__main__':
    s = input()
    for _ in range(int(input())):
        s = transformate(s, input())

Submission status: Runtime Error

Solution code:
x = input()
for i in range(int(input())):
	a = input().split()


	if a[0] == 'print':
		for i in range(1,len(a)):
			a[i]=int(a[i])
		print(x[a[1]:a[2]+1])
	elif a[0] == 'replace':
		for i in range(1,len(a)-1):
			a[i]=int(a[i])
		x = x[:a[1]] +a[3]+ x[a[2]:]
	elif a[0] == 'reverse':
		for i in range(1,len(a)):
			a[i]=int(a[i])
		x[a[1]:a[2]] = x[a[2]:a[1]:-1]

Submission status: Runtime Error

Solution code:
def replace(str):
    for i, c in enumerate(command[3], command[1]):
        str[i] = c
    return str

def reverse(str):
    for i, c in enumerate(reversed(str[command[1]: command[2]+1]), command[1]):
        str[i] = c
    str = ''.join(str)
    return str

def str_print(str):
    str = ''.join(str)
    print(str[command[1]: command[2]+1])

str = list(input())
q = int(input())
for i in range(q):
    command = input().split()
    command[1], command[2] = int(command[1]), int(command[2])
    if command[0] == 'replace':
        str = replace(str)
    elif command[0] == 'reverse':
        str = reverse(str)
    else:
        str_print(str)

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command == 'replace':
        a,b = map(int(),command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command == 'reverse':
        a,b = map(int(),command[1:3])
        s[a:b] = s[b:a]
    else:  
        a,b = map(int(),command[1:3])
        print(s[a:b])

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s[a:b] = s[b:a]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])

Submission status: Runtime Error

Solution code:
s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s[a:b+1] = s[b+1:a]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])

Submission status: Runtime Error

Solution code:
 s = s[0:a] + s[a:b+1][::-1] + s[b+1:]

Submission status: Runtime Error

Solution code:
# Transformation

string = input()
commandAmount = int(input())

for i in range(commandAmount):
    command = input().rstrip().split()
    start = int(command[1])
    end = int(command[2])
    if command[0] == 'print':
        # print(string[start : end + 1])
    elif command[0] == 'reverse':
        replacedString = list(string)
        a = replacedString[start]
        b = replacedString[end]
        replacedString = string.translate(str.maketrans(a + b, b + a))
        string = ''.join(replacedString)
        # print(string)
    elif command[0] == 'replace':
        string = string.translate(str.maketrans(string[start : end + 1], command[3]))
        # print(string)

Submission status: Runtime Error

Solution code:
s = input()
for i in range(int(input())):
	c = list(map(str, input().split()))
	a, b = int(c[1]), int(c[2])
	if c[0] == "print":
		print(s[a:b+1])
	elif c[0] == " reverse":
		s = s[:a] + s[a:b+1][::-1] + s[b+1:]
	else:
		s = s[:a] + c[3] + c[b+1:]

Submission status: WA: Presentation Error

Solution code:
s = list(input())
q = int(input())
for i in range(q):
    cmd = [s for s in input().split()]
    cmd[1] = int(cmd[1])
    cmd[2] = int(cmd[2])
    if cmd[0] == "replace":
        c = list(cmd[3])
        h = 0
        for j in range(cmd[1], cmd[2]+1):
            s[j] = c[h]
            h+=1
    elif cmd[0] == "reverse":
        k = cmd[1]
        l = cmd[2]
        while k < l:
            t = s[k]
            s[k] = s[l]
            s[l] = t
            k+=1
            l-=1
    else:
        for m in range(cmd[1], cmd[2]+1):
            print("{}".format(s[m]), end = "")