Queries on a String

题意翻译

# **CF598B的翻译** 给你一个字符串s,接着有m次循环移位。 循环移位的一个操作就是将s的最后一个字符移动到第一个字符的位置,并且将所有其他的字符向右移动一个位置。 例如,s='abacaba',查询是L1=3,R1=6,K1=1,那么答案是’abbacaa’(解释:从s第三个位置到第六个位置’acab’,循环1次,把b移到第一位,其他往后移一位,就是’baca’,替换之前的’acab’),之后如果我们再做处理L2=1,R2=4,K2=2,那么答案就变’baabcaa’(解释:首先从第一个位置到第四个位置’abba’,第一次通过移位得到’aabb’,第二次就得到’baab’,替换之前的’abba’)。 输入格式: 第一行一个字符串s,(1<=s的长度<=10000),s全是小写字母; 第二行一个整数m,有m个查询; 接下来有m行,包含三个整数Li,Ri, Ki(1<=Li<=Ri<=s的长度,Ki<=1000000)。 输出格式 输出经过m个查询的s。

题目描述

You are given a string $ s $ and should process $ m $ queries. Each query is described by two 1-based indices $ l_{i} $ , $ r_{i} $ and integer $ k_{i} $ . It means that you should cyclically shift the substring $ s[l_{i}...\ r_{i}] $ $ k_{i} $ times. The queries should be processed one after another in the order they are given. One operation of a cyclic shift (rotation) is equivalent to moving the last character to the position of the first character and shifting all other characters one position to the right. For example, if the string $ s $ is abacaba and the query is $ l_{1}=3,r_{1}=6,k_{1}=1 $ then the answer is abbacaa. If after that we would process the query $ l_{2}=1,r_{2}=4,k_{2}=2 $ then we would get the string baabcaa.

输入输出格式

输入格式


The first line of the input contains the string $ s $ ( $ 1<=|s|<=10000 $ ) in its initial state, where $ |s| $ stands for the length of $ s $ . It contains only lowercase English letters. Second line contains a single integer $ m $ ( $ 1<=m<=300 $ ) — the number of queries. The $ i $ -th of the next $ m $ lines contains three integers $ l_{i} $ , $ r_{i} $ and $ k_{i} $ ( $ 1<=l_{i}<=r_{i}<=|s|,1<=k_{i}<=1000000 $ ) — the description of the $ i $ -th query.

输出格式


Print the resulting string $ s $ after processing all $ m $ queries.

输入输出样例

输入样例 #1

abacaba
2
3 6 1
1 4 2

输出样例 #1

baabcaa

说明

The sample is described in problem statement.