output_description: For each print command, print a string in a line.
input_description: 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.
attempt: import copy
  
  function = 0
  start = 1
  end = 2
  replaceStr = 3
  reverseStart = 0
  reverseEnd = 0
  str = 3
  reverseTarget = []
  reversedStr = []
  inStr = list(input())
  outStr = copy.deepcopy(inStr)
  commandNumber = int(input())
  for currentNumber in range(commandNumber):
      command = input().split(" ")  # [commandName, start, end (replaceStr)]
      if command[function] == "print":
          printStart = int(command[start])
          printEnd = int(command[end])
          print("".join(outStr[printStart : printEnd + 1]))
  
      elif command[function] == "reverse":
          reverseStart = int(command[start])
          reverseEnd = int(command[end])
          reverseTarget.append(outStr[reverseStart : reverseEnd + 1])
          reversedStr = reverseTarget[-1][::-1]
          outStr[reverseStart : reverseEnd + 1] = reversedStr
  
      elif command[function] == "replace":
          replaceStart = int(command[start])
          replaceEnd = int(command[end])
          replaceStr = list(command[str])
          outStr[replaceStart : replaceEnd + 1] = replaceStr
  
problem_description: 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.
samples: [{"input": "abcde\n    3\n    replace 1 3 xyz\n    reverse 0 2\n    print 1 4", "output": "xaze"}, {"input": "xyz\n    3\n    print 0 2\n    replace 0 2 abc\n    print 0 2", "output": "xyz\n    abc"}]