426. Double cyclic
Time limit per test: 0.75
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
Consider a sequence of numbers
a_{1},
a_{2},...,
a_{n}. Its
cyclic shift is any sequence obtained from it by taking some (possibly none) of its starting elements and moving them to the end in the same order. In other words, it is a sequence
a_{k},
a_{k+1},...,
a_{n1},
a_{n},
a_{1},
a_{2},...,
a_{k2},
a_{k1} for some
k.
The
smallest cyclic shift of a given sequence is its cyclic shift that is smallest lexicographically. A sequence is
lexicographically smaller than another sequence of the same length if and only if it has a smaller number in the first position they differ.
Now, consider a sequence
of integers
a_{1},
a_{2},...,
a_{n} where
0 ≤
a_{i} ≤
m1, where
m is some fixed constant. We define
to be the sequence
.
Given
,
m and an integer
k between 1 and
n, output
m integer numbers: the
kth element of the smallest cyclic shift of
, the
kth element of the smallest cyclic shift of
,..., the
kth element of the smallest cyclic shift of
.
Input
The first line of the input file contains three integers
n,
m and
k (
, 1 ≤
k ≤
n). The second line of the input line contains
n integers
a_{1},
a_{2},...,
a_{n} (0 ≤
a_{i} ≤
m1).
Output
Output
m integer numbers one per line —
kth elements of the smallest cyclic shifts of the sequences explained above.
Example(s)
sample input

sample output

5 6 3
1 2 1 2 3

1
2
3
5
5
0
