this is code for greedy dd in python3.6. I have tried every input possible and answer shown is right. but when i submit practice my code,codedhef tells that it gives wrong answer. please help me with code and kindly tell the error

t=int(input())

if(1<=t<=1001):

for _ in range(t):

max = 0

from itertools import cycle

n, k = map(int, input().split())

a = list(map(int, input().split()))

if (5 <= n <= 100001):

if (1 <= k <= n):

for index, *ans in zip(range(n + k), *[cycle(a)] * k):

# print(ans)

s = sum(ans)

if (s > max):

max = s

print(max)