Infinite fraction
You are given two numbers, N and K, along with an array D[0..N-1] that contains decimal digits (0 ≤ D[i] ≤ 9), where each D[i] is an integer.
Now, consider an array A made up of real numbers. Each element A[i] has an integer part of zero, and its fractional part is an infinite decimal sequence formed by the digits D[(i+0k) mod N], D[(i+1k) mod N], D[(i+2k) mod N], and so forth.
For instance, if N = 3, K = 2, and D = '194':
A[1] = 0.1491491491.., A[2] = 0.9149149149.., A[3] = 0.4914914914..
Your task is to find the element in the array A that has the largest value and then output the first N digits of its fractional part.
Input
The first line of the input contains the numbers N and K (1 ≤ N ≤ 150000, 0 ≤ K ≤ 10^9). The second line provides the array D.
Output
Print the first N digits of the fractional part of the maximum element from the array A.