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: line = input()
  n = int(input())
  array = [[i for i in input().split()] for i in range(n)]
  for i in range(n):
      if array[i][0] == "print":
          print(line[int(array[i][1]) : int(array[i][2]) + 1])
      elif array[i][0] == "reverse":
          if array[i][1] != "0":
              reline = line[int(array[i][2]) : int(array[i][1]) - 1 : -1]
          else:
              reline = line[int(array[i][2]) :: -1]
          revara = list(line)
          for i2 in range(len(reline)):
              revara[int(array[i][1]) + i2] = reline[i2]
          for i2 in range(len(revara)):
              if i2 == 0:
                  line = revara[i2]
              else:
                  line += revara[i2]
  
      elif array[i][0] == "replace":
          repara = list(line)
          inpara = list(array[i][3])
          for i2 in range(len(inpara)):
              repara[int(array[i][1]) + i2] = inpara[i2]
          for i2 in range(len(repara)):
              if i2 == 0:
                  line = repara[i2]
              else:
                  line += repara[i2]
  
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"}]