a = []

n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i

for i in 0...q
	b, m, e = gets.split.map(&:to_i)
	c = []
	for i in 0...(e-b)
		c[i] = a[b+i]
	end
	for i in 0...(e-b)
		j = (i+e-m) % (e-b)
		a[b+j] = c[i]
	end
end

for i in 0...(n-1)
	print "#{a[i]} "
end

print "#{a[n-1]}\n"
