Howmanyspecificordersdoyouknow? Ascendingorder, descendingorder, orderofascendinglength, orderofascendingpolarangle... Letshavealookatanotherspecificorder: d-sorting.Thissortingisappliedtothestringsoflengt
How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... let's have a look at another specific order: d-sorting. this sorting is applied to the strings of lengt
How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... Let's have a look at another specific order:D-Sorting. This sorting is applied to the strings of length at leastD, WhereDIs some positive integer. the characters of the string are sorted in following manner: first come all the 0-th characters of the initial string, then the 1-st ones, then the 2-nd ones and so on, in the end go all (D? -? 1)-th characters of the initial string. ByI-Th characters we mean all the character whose positions are exactlyIModuloD. If two characters stand on the positions with the same remainder of integer pisionD, Their relative order after the sorting shouldn't be changed. The string is zero-indexed. For example, for string 'qwerty ':
Its 1-sorting is the string 'qwerty '(all characters stand on 0 positions ),
Its 2-sorting is the string 'qetwry' (characters 'Q', 'E' and 'T' stand on 0 positions and characters 'w ', 'R' and 'y' are on 1 positions ),
Its 3-sorting is the string 'qrwtey' (characters 'Q' and 'R' stand on 0 positions, characters 'W' and 't'stand on 1 positions and characters 'E' and 'y' stand on 2 positions ),
Its 4-sorting is the string 'qtwyer ',
Its 5-sorting is the string 'qywert '.
You are given stringSOf lengthNAndMShuffling operations of this string. Each shuffling operation accepts two integer argumentsKAndDAnd transforms stringSAs follows. For eachIFrom 0N? -?KIn the increasing order we apply the operationD-Sorting to the substringS[I..I? +?K? -? 1]. HereS[A..B] Represents a substring that consists of characters on positions fromAToBIntrusive.
After each shuffling operation you need to print stringS.