 # HELP in BOXGAME REQUIRED

``````# cook your dish here
``````

for i in range(0,int(input())):
n,k,p=map(int,input().split())
a=input()
a=list(map(int,a.split()))
if k%2!=0:
if p==0:
print(max(a))
if p==1:
print(min(a))
else:
if p==1:
l1=a
l2=a[n-2]
if l1<l2:
min1=l1
else:
min1=l2
change=0
for i in range(1,n-1):
if change==0:
if a[i-1]<min1 and a[i+1]<min1:
change=1
if a[i-1]>a[i+1]:
max1=a[i-1]
else:
max1=a[i+1]
else:
if a[i-1]>a[i+1] and a[i-1]<max1:
max1=a[i-1]
elif a[i-1]<a[i+1] and a[i+1]<max1:
max1=a[i+1]
if change==0:
print(min1)
else:
print(max1)

``````    elif p==0:
l1=a
l2=a[n-2]
if l1<l2:
max1=l2
else:
max1=l1
change=0
for i in range(1,n-1):
if change==0:
if a[i-1]>max1 and a[i+1]>max1:
change=1
if a[i-1]>a[i+1]:
min1=a[i+1]
else:
min1=a[i-1]
else:
if a[i-1]<a[i+1] and a[i-1]>min1:
min1=a[i-1]
elif a[i-1]>a[i+1] and a[i+1]>min1:
min1=a[i+1]
if change==0:
print(max1)
else:
print(min1)
``````

Even after testing almost all test cases i could figure out i wasnt able to find a fault, i am getting a WA on this.
Kindly tell me the test case i am missing.
{a starts at a} 