# AOJ ITP2_4_B: Rotate

# Python3 2018.6.24 bal4u



from collections import deque

n = int(eval(input()))

a = list(map(int, input().split()))

q = int(eval(input()))

for i in range(q):

	b, m, e = list(map(int, input().split()))

	s = deque(a[b:e])

	s.rotate(e-m)

	a = a[:b] + list(s) + a[e:]

print((*a))

# AOJ ITP2_4_B: Rotate

# Python3 2018.6.24 bal4u



from collections import deque

n = int(eval(input()))

a = list(map(int, input().split()))

q = int(eval(input()))

for i in range(q):

	b, m, e = list(map(int, input().split()))

	s = a[b:e]

	a = a[:b] + s[m-b:] + s[:m-b] + a[e:]

print((*a))

# AOJ ITP2_4_B: Rotate
# Python3 2018.6.24 bal4u
from collections import deque

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
for i in range(q):
    b, m, e = list(map(int, input().split()))
    s = deque(a[b:e])
    s.rotate(e - m)
    a = a[:b] + list(s) + a[e:]
print((*a))

# AOJ ITP2_4_B: Rotate
# Python3 2018.6.24 bal4u
from collections import deque

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
for i in range(q):
    b, m, e = list(map(int, input().split()))
    s = a[b:e]
    a = a[:b] + s[m - b :] + s[: m - b] + a[e:]
print((*a))

-    s = deque(a[b:e]) -    s.rotate(e - m) -    a = a[:b] + list(s) + a[e:] +    s = a[b:e] +    a = a[:b] + s[m - b :] + s[: m - b] + a[e:]