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: # 1st line
  input_str = input().strip()
  
  # 2nd line
  command_max_times = int(input().strip())
  command_cnt = 0
  
  while command_cnt < command_max_times:
      command_cnt = command_cnt + 1
      input_line = input().strip().split(" ")
  
      input_command = input_line[0]
      input_sta = int(input_line[1])
      input_end = int(input_line[2])
  
      if input_command == "print":
          print(input_str[input_sta : input_end + 1])
      elif input_command == "replace":
          str_replace = input_line[3]
          input_str = input_str[:input_sta] + str_replace + input_str[input_end + 1 :]
      elif input_command == "reverse":
          str_temp = input_str[input_sta : input_end + 1]
          input_str = input_str[:input_sta] + str_temp[::-1] + input_str[input_end + 1 :]
  
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"}]