
str = gets.chomp
n = gets.to_i

n.times{

ord = gets.split

d = ord[0][2]

a = ord[1].to_i
b = ord[2].to_i

case d

when "i"
puts str[a, b-a+1]

when "p"
t = ord[3]

for i in 0..(b-a)
str[a+i] = t[i]
end

when "v"
t = str.clone

for i in 0..(b-a)
str[a+i] = t[b-i]
end

end

}



