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: n = input()
  q = int(input())
  
  
  def printdef(z, a, b):
      print(z[a:b])
  
  
  def replacedef(z, a, b, c):
      z = z.replace(z[a:b], c)
      return z
  
  
  def reversedef(z, a, b):
      ichi = z[a:b]
      ichi = ichi[::-1]
      z = z.replace(z[a:b], ichi)
      return z
  
  
  for _ in range(q):
      order_str = list(input().split(" "))
      order_str[1] = int(order_str[1])
      order_str[2] = int(order_str[2]) + 1
  
      if order_str[0] == "print":
          printdef(n, order_str[1], order_str[2])
      elif order_str[0] == "replace":
          n = replacedef(n, order_str[1], order_str[2], order_str[3])
      elif order_str[0] == "reverse":
          n = reversedef(n, order_str[1], order_str[2])
  
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"}]