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: def souhei(a, b):
      c = int(a)
      d = int(b)
      return [c, d]
  
  
  moji = input()
  moji = list(moji)
  P = int(input())
  for pp in range(P):
      some = list(input().split())
      if some[0] == "print":
          some[1], some[2] = souhei(some[1], some[2])
          for a in range(some[1], some[2] + 1):
              if a == some[2]:
                  print(moji[a])
              else:
                  print(moji[a], end="")
      elif some[0] == "reverse":
          some[1], some[2] = souhei(some[1], some[2])
          nn = 0
          m = int((some[1] + some[2]) / 2)
          for bb in range(some[1], m + 1):
              X = moji[bb]
              moji[bb] = moji[some[2] - nn]
              moji[some[2] - nn] = X
              nn += 1
      elif some[0] == "replace":
          some[1], some[2] = souhei(some[1], some[2])
          g = some[3]
          g = list(g)
          n = 0
          for oo in range(some[1], some[2] + 1):
              moji[oo] = g[n]
              n += 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"}]