10 5 1000000000
1 1 1 2 2 1 2 2 2 2
 5 3 3
1 2 2 1 1
 2 4 1
1 1
 1 1000000000 1000000000
100000
 5 3 2
1 1 2 1 1
 5 2 4
1 2 3 2 1
 1 10 10
1

10000000000
 0
 2
 0
 7
 0
 0

n, k, m = map(int, input().split())
a = list(map(int, input().split())) * m
flag = True
k -= 1
pr = len(a)
print(a)
while flag:
    c = k
    for i in range(1, len(a)):
        if a[i - 1] == a[i]:
            c -= 1
            if c == 0:
                a = a[:i - k] + a[i + 1:]
                break
        else:
            c = k
    print(a)
    flag = len(a) != pr
    pr = len(a)
print(len(a))