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

q.times do

  b, m, e = gets.split.map(&:to_i)
  k = e - b
  k_temp = a[b,k]

  k.times do |k|
    r_idx = b + (k + (e - m)) % (e - b)
    a[r_idx] = k_temp[k]
  end
end

puts a.join(" ")
