#d2734. 子串的循环挪动

子串的循环挪动

Cyclic Shift of a Substring

Problem Description

You are given a string ss, and you must perform mm tasks. Each task gives two indices li,ril_i, r_i and an integer kik_i (the string is 11-indexed), meaning that you cyclically shift the substring s[li…ri]s[l_i \dots r_i] exactly kik_i times. Execute the given tasks one by one, in order.

The cyclic shift operation moves the last character to the first position, and shifts every other character one position to the right.

For example, suppose ss is abacaba. If the first task is l1=3,r1=6,k1=1l_1 = 3, r_1 = 6, k_1 = 1, the answer becomes abbacaa. Then if the next task is l2=1,r2=4,k2=2l_2 = 1, r_2 = 4, k_2 = 2, we obtain baabcaa.

Input Format

The first line contains a string ss consisting only of lowercase English letters.

The second line contains an integer mm, the number of tasks.

Each of the next mm lines contains three integers li,ri,kil_i, r_i, k_i.

Output Format

Output the final string ss after performing all mm tasks.

Sample Input

abacaba
2
3 6 1
1 4 2

Sample Output

baabcaa

Constraints

For all data: 1≤∣s∣≤100001 \leq |s| \leq 10000 (∣s∣|s| denotes the length of ss), 1≤m≤3001 \leq m \leq 300, 1≤li≤ri≤∣s∣1 \leq l_i \leq r_i \leq |s|, and 1≤ki≤10000001 \leq k_i \leq 1000000.