You and your $n - 1$ friends have found an array of integers $a_1, a_2, \dots, a_n$. You have decided to share it in the following way: All $n$ of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.

You are standing in the $m$-th position in the line. Before the process starts, you may choose up to $k$ different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.

Suppose that you're doing your choices optimally. What is the greatest integer $x$ such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to $x$?

Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains three space-separated integers $n$, $m$ and $k$ ($1 \le m \le n \le 3500$, $0 \le k \le n - 1$)  — the number of elements in the array, your position in line and the number of people whose choices you can fix.

The second line of each test case contains $n$ positive integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$)  — elements of the array.

It is guaranteed that the sum of $n$ over all test cases does not exceed $3500$.


-----Output-----

For each test case, print the largest integer $x$ such that you can guarantee to obtain at least $x$.


-----Example-----
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2

Output
8
4
1
1



-----Note-----

In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.  the first person will take the last element ($5$) because he or she was forced by you to take the last element. After this turn the remaining array will be $[2, 9, 2, 3, 8]$;  the second person will take the first element ($2$) because he or she was forced by you to take the first element. After this turn the remaining array will be $[9, 2, 3, 8]$;  if the third person will choose to take the first element ($9$), at your turn the remaining array will be $[2, 3, 8]$ and you will take $8$ (the last element);  if the third person will choose to take the last element ($8$), at your turn the remaining array will be $[9, 2, 3]$ and you will take $9$ (the first element). 

Thus, this strategy guarantees to end up with at least $8$. We can prove that there is no strategy that guarantees to end up with at least $9$. Hence, the answer is $8$.

In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with $4$.

Difficulty: MEDIUM_HARD

Solutions:
import sys
input = sys.stdin.buffer.readline

def getmax(l, r):
	return max(a[l], a[r])
t = int(input())
for _ in range(t):
	(n, m, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	control = min(k, m - 1)
	remainingM = m - control
	ans = -1
	for l in range(control + 1):
		r = n - 1 + l - control
		minn = float('inf')
		for mm in range(remainingM):
			ll = l + mm
			rr = r - (remainingM - mm) + 1
			minn = min(minn, getmax(ll, rr))
		ans = max(ans, minn)
	print(ans)


import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def solve(N, M, K, A):
	if K >= M - 1:
		return max(max(A[:M]), max(A[-M:]))
	uncontrol = M - 1 - K
	ans = 0
	for leftcontrl in range(K + 1):
		tmp = float('inf')
		rightcontrol = K - leftcontrl
		for leftother in range(uncontrol + 1):
			front = A[leftcontrl + leftother]
			rightother = uncontrol - leftother
			tail = A[-(rightcontrol + rightother + 1)]
			tmp = min(tmp, max(front, tail))
		ans = max(ans, tmp)
	return ans
T = int(input())
ans = []
for ti in range(T):
	(N, M, K) = map(int, input().split())
	A = [int(x) for x in input().split()]
	ans.append(solve(N, M, K, A))
print('\n'.join(map(str, ans)))


t = int(input())
for i in range(t):
	(n, m, k) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	if k >= m:
		k = m - 1
	z = m - 1 - k
	sol = []
	for j in range(k + 1):
		big = max(a[j], a[j - k - z - 1])
		for o in range(z + 1):
			if max(a[j + o], a[o + j - k - z - 1]) < big:
				big = max(a[j + o], a[o + j - k - z - 1])
		sol.append(big)
	print(max(sol))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 5)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	k = min(m - 1, k)
	l = list(map(int, input().split()))
	final = 0
	for x in range(k + 1):
		ans1 = inf
		for y in range(m - k):
			ans1 = min(ans1, max(l[x + y], l[x + y + n - m]))
		final = max(final, ans1)
	print(final)


def f():
	(n, m, k) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	maxA = 1
	for a in A:
		maxA = max(maxA, a)
	limit = min(m - 1, k)
	free = m - 1 - limit
	ans = 1
	for a0 in range(limit + 1):
		minX = maxA
		for a in range(a0, a0 + free + 1):
			b = m - 1 - a
			x = max(A[a], A[-b - 1])
			minX = min(minX, x)
		ans = max(ans, minX)
	return ans
T = int(input())
for t in range(T):
	print(f())


t = int(input())
for _ in range(t):
	(n, m, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ans = 0
	control_forward = min(k, m - 1)
	for i in range(control_forward + 1):
		l = i
		r = n - 1 - control_forward + i
		non_control_forward = max(m - 1 - control_forward, 0)
		anstemp = 10 ** 10
		for j in range(non_control_forward + 1):
			l += j
			r += -non_control_forward + j
			anstemp = min(anstemp, max(a[l], a[r]))
			l -= j
			r -= -non_control_forward + j
		ans = max(anstemp, ans)
	print(ans)


def calc(l, start, end, left):
	arr = l[start:end + 1]
	ans = max(arr)
	for i in range(left + 1):
		ans = min(ans, max(arr[i], arr[len(arr) - left - 1 + i]))
	return ans
for nt in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if m == 1:
		print(max(l[0], l[-1]))
		continue
	if m > k + 1:
		ans = -1
		for i in range(k + 1):
			ans = max(ans, calc(l, i, n - 1 - k + i, m - k - 1))
		print(ans)
	else:
		ans = -1
		for i in range(m):
			if l[i] > ans:
				ans = l[i]
		for i in range(n - 1, n - 1 - m, -1):
			if l[i] > ans:
				ans = l[i]
		print(ans)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, m, k) = mp()
	arr = lmp()
	k = min(k, m - 1)
	mx = 0
	for i in range(k + 1):
		mn = inf
		for j in range(m - k):
			mn = min(mn, max(arr[i + j], arr[n - m + i + j]))
		mx = max(mx, mn)
	print(mx)


R = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, m, k) = R()
	a = R()
	k = min(k, m - 1)
	d = m - k
	ans = 0
	remove = (d - 1) // 2
	f = max if d & 1 else min
	for i in range(k + 1):
		p = 10 ** 9
		for j in range(d):
			p = min(p, max(a[i + j], a[i + n - k - 1 - (d - 1 - j)]))
		ans = max(ans, p)
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = [int(c) for c in input().split()]
	m = m - 1
	k = min(k, m)
	R = 0
	T = [max(a[i], a[i + n - 1 - m]) for i in range(m + 1)]
	if k >= m:
		print(max(T))
	elif k == 0:
		print(min(T))
	else:
		R = [min(T[j:m + 1 - k + j]) for j in range(k + 1)]
		print(max(R))


t = int(input())
for test in range(t):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k >= m:
		k = m - 1
	x = m - 1 - k
	maxi = -1
	for i in range(k + 1):
		s = i
		e = k - i
		mini = 100000000000000000
		for j in range(x + 1):
			s += j
			e += x - j
			ind1 = 0 + s
			ind2 = len(arr) - 1 - e
			ans = max(arr[ind1], arr[ind2])
			if ans < mini:
				mini = ans
			s -= j
			e -= x - j
		if mini > maxi:
			maxi = mini
	print(maxi)


for _ in range(int(input())):
	(n, me, k) = map(int, input().split())
	a = list(map(int, input().split()))
	sz = n - min(k, me - 1)
	before = max(0, me - k - 1)
	ret = -float('inf')
	for i in range(0, n - sz + 1):
		t = a[i:i + sz]
		cur = float('inf')
		for left in range(before + 1):
			right = sz - (before - left + 1)
			cur = min(cur, max(t[left], t[right]))
		ret = max(ret, cur)
	print(ret)


def solve():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k >= m - 1:
		ans = 0
		for i in range(n):
			if i <= m - 1 or n - i - 1 <= m - 1:
				ans = max(ans, a[i])
		print(ans)
		return
	ans = 0
	for i in range(k + 1):
		ost = k - i
		ost = n - ost
		b = a[i:ost]
		all = m - 1 - k
		cur = 1000000000.0
		for j in range(all + 1):
			left = j
			right = all - left
			left = b[left]
			right = b[len(b) - right - 1]
			cur = min(cur, max(left, right))
		ans = max(ans, cur)
	print(ans)
t = int(input())
while t > 0:
	t -= 1
	solve()


import collections, heapq

def main():
	T = int(input().strip())
	for _ in range(T):
		(n, m, k) = [int(x) for x in input().strip().split(' ')]
		k = min(k, m - 1)
		a = [int(x) for x in input().strip().split(' ')]
		res = []
		(l, r) = (0, n - (m - 1) - 1)
		while r < n:
			res.append(max(a[l], a[r]))
			l += 1
			r += 1
		res2 = []
		(l, r) = (0, len(res) - 1 - k)
		while r < len(res):
			res2.append(min(res[l:r + 1]))
			l += 1
			r += 1
		print(max(res2))
main()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i1 in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	x = min(k, m - 1)
	y = m - 1 - x
	ans = 99999999999999999999
	ansf = 0
	for j in range(x + 1):
		ans = 99999999999999999999
		for i in range(y + 1):
			ans = min(max(l[i + j], l[n - m + i + j]), ans)
		ansf = max(ansf, ans)
	print(ansf)


from sys import stdin, stdout

def main():
	T = int(stdin.readline())
	for zzz in range(T):
		arr = list(map(int, stdin.readline().split()))
		(n, m, k) = arr
		item = list(map(int, stdin.readline().split()))
		if m <= k:
			k = m - 1
		luck = m - k - 1
		maxer = 0
		for i in range(k + 1):
			left = i
			right = n - k + i - 1
			temp_min = 99999999999
			for j in range(luck + 1):
				left2 = j
				right2 = luck - j
				temp_max = max(item[left + left2], item[right - right2])
				temp_min = min(temp_min, temp_max)
			if maxer == 0:
				maxer = temp_min
			else:
				maxer = max(maxer, temp_min)
		stdout.write(str(maxer) + '\n')
main()


import sys
from math import log2, floor, ceil, sqrt
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	(n, m, k) = Ri()
	a = Ri()
	if k >= m:
		k = m - 1
	left = m - k - 1
	ans = -INF
	for i in range(0, k + 1):
		tminn = INF
		for j in range(0, left + 1):
			first = a[i + j]
			le = m - 1 - i - j
			last = a[n - le - 1]
			tminn = min(tminn, max(first, last))
		if tminn != INF:
			ans = max(tminn, ans)
	print(ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf, gcd
from itertools import permutations
from copy import deepcopy
from heapq import *

def main():
	for _ in range(int(input())):
		(n, m, k) = map(int, input().split())
		a = list(map(int, input().split()))
		if k >= m - 1:
			print(max(max(a[:m]), max(a[-m:])))
		else:
			ma = 0
			for i in range(k + 1):
				(mi, z) = (inf, m - k - 1)
				for j in range(z + 1):
					mi = min(mi, max(a[i + j], a[n - k - 1 - z + j + i]))
				ma = max(ma, mi)
			print(ma)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve():
	(n, m, k) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	maxg = None
	if k >= m:
		k = m - 1
	for start in range(k + 1):
		end = n - (k - start) - 1
		max_val = None
		left = None
		if m <= k + 1:
			left = 0
		else:
			left = m - k - 1
		for i in range(left + 1):
			j = left - i
			temp = max(arr[start + i], arr[end - j])
			if max_val is None:
				max_val = temp
			elif temp < max_val:
				max_val = temp
		if maxg is None:
			maxg = max_val
		elif max_val > maxg:
			maxg = max_val
	print(maxg)
t = int(input())
while t:
	t = t - 1
	solve()


t = int(input())
ans = []
for l in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k < m:
		p = m - k - 1
	else:
		k = m - 1
		p = 0
	res2 = -1
	for i in range(k + 1):
		res = 1000000001
		for j in range(p + 1):
			if max(a[k + p - i - j], a[-1 - i - j]) < res:
				res = max(a[k + p - i - j], a[-1 - i - j])
		if res > res2:
			res2 = res
	print(res2)


t = int(input())
for case in range(t):
	(n, m, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ans = 0
	for i in range(min(k, m - 1) + 1):
		tmp = 10000000000
		for j in range(m - min(k, m - 1)):
			tmp = min(tmp, max(a[i + j], a[n - m + i + j]))
		ans = max(ans, tmp)
	print(ans)


t = int(input())

def solve(n, m, k, arr):
	if m - 1 <= k:
		return max(max(arr[:m]), max(arr[n - m:]))
	else:
		res = 0
		for l in range(k + 1):
			r = k - l
			worst_case = 10 ** 9 + 1
			for ll in range(m - 1 - k + 1):
				rr = m - 1 - k - ll
				head = arr[l + ll]
				tail = arr[n - 1 - r - rr]
				worst_case = min(worst_case, max(head, tail))
			res = max(res, worst_case)
		return res
for _ in range(t):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(solve(n, m, k, arr))


t = int(input())
import math
MAX_A = 1000000002
for i in range(t):
	(n, m, k) = map(int, input().split())
	s = list(map(int, input().split()))
	if m <= k:
		print(max(max(s[:m]), max(s[-m:])))
	else:
		D = [0] * m
		for j in range(m):
			a = max(s[j], s[-(m - j)])
			D[j] = a
		a = math.sqrt(len(D))
		a = math.floor(a)
		B = []
		c = 0
		A = MAX_A
		for j in range(len(D)):
			if D[j] < A:
				A = D[j]
			c += 1
			if c == a or j == m - 1:
				B.append(A)
				A = MAX_A
				c = 0
		E = []
		for j in range(k + 1):
			l1 = j
			r1 = j + m - k
			M = []
			for x in range(len(B)):
				l = x * a
				r = a * (x + 1)
				if r > m:
					r = m
				if l1 <= l and r <= r1:
					M.append(B[x])
				elif r <= l1 or l >= r1:
					continue
				else:
					M.append(min(D[max(l1, l):min(r1, r)]))
			E.append(min(M))
		print(max(E))


t = int(input())
while t > 0:
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	if m - k - 1 > 0:
		for i in range(k + 1):
			bad = 99999999999
			for j in range(m - k):
				bad = min(bad, max(a[m - 1 - i - j], a[n - 1 - i - j]))
			x = max(x, bad)
	else:
		for i in range(m):
			y = max(a[m - 1 - i], a[n - 1 - i])
			x = max(y, x)
	print(x)
	t -= 1


t = int(input())
for i in range(t):
	(n, m, k) = input().split()
	n = int(n)
	m = int(m)
	k = int(k)
	arr = list(map(int, input().split()))
	L = min(m - 1, k)
	arr1 = []
	for i in range(L + 1):
		min1 = max(arr[i], arr[n - 1 - (m - 1 - i)])
		for j in range(0, m - L):
			if max(arr[i + j], arr[n - 1 - (m - 1 - (i + j))]) < min1:
				min1 = max(arr[i + j], arr[n - 1 - (m - 1 - (i + j))])
		arr1.append(min1)
	print(max(arr1))


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, m, k) = map(int, input().strip().split())
		a = list(map(int, input().strip().split()))
		mini = min(m - 1, k)
		ans = 0
		for x in range(mini + 1):
			res = float('inf')
			for y in range(m - mini):
				res = min(res, max(a[x + y], a[x + y + n - m]))
			ans = max(ans, res)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, sys
from sys import stdin, stdout

def modinv(n, p):
	return pow(n, p - 2, p)

def nc():
	return map(int, ns().split())

def narr():
	return list(map(int, ns().split()))

def ns():
	return input()

def ni():
	return int(input())
t = ni()
for _ in range(t):
	(n, m, k) = narr()
	a = narr()
	ans = 0
	if m <= k or m == 1:
		for i in range(m):
			ans = max(ans, a[i])
			ans = max(ans, a[n - i - 1])
	else:
		w = n - m
		best = [1000000001 for i in range(n - w)]
		for j in range(n - w):
			l = a[j]
			r = a[j + w]
			best[j] = max(l, r)
		limit = max(m - k, 0)
		for i in range(len(best) - limit + 1):
			b = best[i:i + limit]
			worst = min(b)
			ans = max(ans, worst)
	print(ans)


from collections import deque
from math import inf

def value(my_pos, sub):
	sublen = len(sub)
	size = sublen - my_pos
	ans = inf
	for i in range(sublen - size + 1):
		curr = max(sub[i], sub[i + size - 1])
		ans = min(ans, curr)
	return ans

def solve():
	(n, my_pos, no_of_infl) = map(int, input().split())
	arr = list(map(int, input().split()))
	no_of_infl = min(no_of_infl, my_pos - 1)
	size = n - no_of_infl
	my_pos -= no_of_infl + 1
	ans = 0
	sub = deque(arr[:size])
	ans = max(ans, value(my_pos, sub))
	for i in range(size, n):
		sub.popleft()
		sub.append(arr[i])
		ans = max(ans, value(my_pos, sub))
	return ans
for _ in range(int(input())):
	print(solve())


def main():
	import heapq
	from collections import Counter
	from array import array
	for _ in range(int(input())):
		(n, m, k) = map(int, input().split())
		a = array('i', map(int, input().split()))
		nmm = n - m
		ar = array('i', (max(a[i], a[i + nmm]) for i in range(m)))
		if k >= m:
			print(max(ar))
			continue
		mmk = m - k
		h = list(ar[:mmk])
		cnt = Counter(h)
		heapq.heapify(h)
		ans = h[0]
		for i in range(k):
			j = i + mmk
			arj = ar[j]
			if arj not in cnt:
				heapq.heappush(h, arj)
			cnt[arj] += 1
			ari = ar[i]
			if cnt[ari] == 1:
				del cnt[ari]
				while h[0] not in cnt:
					heapq.heappop(h)
			else:
				cnt[ari] -= 1
			ans = max(ans, h[0])
		print(ans)
main()


t = int(input())
while t:
	(n, m, k) = map(int, input().split())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	if k >= m - 1:
		ans = 0
		for i in range(min(m, n)):
			ans = max(ans, a[i])
		i = n - 1
		while n - i <= m and i >= 0:
			ans = max(ans, a[i])
			i -= 1
		print(ans)
	else:
		ans = 0
		for i in range(k + 1):
			temp = 10 ** 9 + 1
			for j in range(min(m - k, n - i)):
				temp = min(temp, max(a[i + j], a[n - m + i + j]))
			ans = max(ans, temp)
		print(ans)
	t -= 1


def main():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k = min(k, m - 1)
	ans = 0
	for i in range(k + 1):
		c = 10000000000.0 + 10
		for j in range(m - k):
			c = min(c, max(a[i + j], a[i + j + n - m]))
		ans = max(c, ans)
	print(ans)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


class Solution(object):

	def minSlidingWindow(self, nums, k):
		monotonicQueue = []
		res = []
		for i in range(len(nums)):
			while monotonicQueue and nums[monotonicQueue[-1]] >= nums[i]:
				monotonicQueue.pop()
			monotonicQueue.append(i)
			if monotonicQueue[0] == i - k:
				monotonicQueue.pop(0)
			if i >= k - 1 or i + 1 >= len(nums):
				res.append(nums[monotonicQueue[0]])
		return res

def k0case(n, m, a):
	res = n - m + 1
	ans = max(a[0], a[n - m])
	heap = []
	for i in range(m):
		j = i + res - 1
		ans = min(ans, max(a[i], a[j]))
		heap.append(max(a[i], a[j]))
	return heap

def kmaxcase(n, m, a):
	res = n - m + 1
	ans = max(a[0], a[n - m])
	for i in range(m):
		j = i + res - 1
		ans = max(ans, max(a[i], a[j]))
	return ans

def withkcase(n, m, k, a):
	if k >= m - 1:
		return kmaxcase(n, m, a)
	res = m - k
	ans = float('-inf')
	sol = Solution()
	A = [max(a[i], a[n - m + i]) for i in range(m)]
	ans = sol.minSlidingWindow(A, res)
	ans = max(ans)
	return ans
t = int(input())
for _ in range(t):
	(n, m, k) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	print(withkcase(n, m, k, a))


for _ in range(int(input())):
	(n, m, k) = list(map(int, input().split()))
	k = min(m - 1, k)
	randomDelete = m - k - 1
	a = list(map(int, input().split()))
	maxm = 0
	for i in range(k + 1):
		mini = 10 ** 10
		for j in range(i, i + randomDelete + 1):
			mini = min(mini, max(a[j], a[j + (n - randomDelete - k) - 1]))
		if mini != 10 ** 10:
			maxm = max(mini, maxm)
	print(maxm)


def Solve(k, m, n, V):
	a = None
	m = m - 1
	k = min(m, k)
	for i in range(k + 1):
		b = max(V[i], V[n - 1 - (k - i) - (m - k)])
		for j in range(m - k + 1):
			left = i + j
			right = n - 1 - (k - i) - (m - k - j)
			b = min(b, max(V[left], V[right]))
		if a == None:
			a = b
		else:
			a = max(a, b)
	return a
cases = int(input())
for i in range(cases):
	(n, m, k) = map(int, input().split())
	V = list(map(int, input().split()))
	print(Solve(k, m, n, V))


import math

def buildSparseTable(arr, n):
	for i in range(0, n):
		lookup[i][0] = arr[i]
	j = 1
	while 1 << j <= n:
		i = 0
		while i + (1 << j) - 1 < n:
			if lookup[i][j - 1] < lookup[i + (1 << j - 1)][j - 1]:
				lookup[i][j] = lookup[i][j - 1]
			else:
				lookup[i][j] = lookup[i + (1 << j - 1)][j - 1]
			i += 1
		j += 1

def query(L, R):
	j = int(math.log2(R - L + 1))
	if lookup[L][j] <= lookup[R - (1 << j) + 1][j]:
		return lookup[L][j]
	else:
		return lookup[R - (1 << j) + 1][j]
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	b = list(map(int, input().split()))
	lookup = [[0 for i in range(25)] for j in range(n + 1)]
	a = []
	for j in range(m):
		a.append(max(b[j], b[n - m + j]))
	buildSparseTable(a, m)
	ans = 0
	if k <= m - 1:
		for i in range(k + 1):
			ans = max(ans, query(i, i + m - k - 1))
	else:
		for i in range(m):
			ans = max(ans, max(b[i], b[n - 1 - (m - 1 - i)]))
	print(ans)


import sys

class CMindControl:

	def solve(self):
		for _ in range(int(input())):
			(n, m, k) = [int(_) for _ in input().split()]
			a = [int(_) for _ in input().split()]
			reachable_set = set()
			for i in range(m):
				reachable_set.add(i)
				reachable_set.add(n - 1 - i)
			reachable_sorted = []
			for idx in reachable_set:
				reachable_sorted.append([a[idx], idx])
			reachable_sorted.sort()
			if k >= m - 1:
				ans = reachable_sorted[-1][0]
				print(ans)
				continue
			global_ans = 0
			for i in range(k + 1):
				j = n - 1 + i - k
				cur_ans = float('inf')
				for u in range(i, i + m - 1 - k + 1):
					v = j + u - (m - 1 - k) - i
					cur_ans = min(cur_ans, max(a[u], a[v]))
				global_ans = max(global_ans, cur_ans)
			print(global_ans)
solver = CMindControl()
input = sys.stdin.readline
solver.solve()


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	data = list(map(int, input().split()))
	if k >= m - 1:
		output = data[0]
		for i in range(m):
			output = max(output, data[i], data[n - m + i])
		print(output)
	else:
		output = float('-inf')
		for i in range(k + 1):
			best_k = float('inf')
			for j in range(m - k):
				best_k = min(best_k, max(data[i + j], data[n + i - m + j]))
			output = max(output, best_k)
		print(int(output))


import sys
input = sys.stdin.readline
from collections import deque

class SlidingWindowAggregation:

	def __init__(self, a=None, op=lambda a, b: max(a, b)):
		self.op = op
		self.back_deq = deque()
		self.front_deq = deque()
		if a:
			self.initialize(a)

	def __len__(self):
		return len(self.back_deq) + len(self.front_deq)

	def initialize(self, a):
		s = x = a.pop()
		self.front_deq.appendleft((x, x))
		for x in a[::-1]:
			s = self.op(x, s)
			self.front_deq.appendleft((x, s))

	def fold(self):
		if not self.front_deq:
			return self.back_deq[-1][1]
		if not self.back_deq:
			return self.front_deq[0][1]
		else:
			return self.op(self.front_deq[0][1], self.back_deq[-1][1])

	def push(self, x):
		if not self.back_deq:
			self.back_deq.append((x, x))
		else:
			self.back_deq.append((x, self.op(x, self.back_deq[-1][1])))

	def pop(self):
		if not self.front_deq:
			(x, _) = self.back_deq.pop()
			self.front_deq.appendleft((x, x))
			s = x
			while self.back_deq:
				(x, _) = self.back_deq.pop()
				s = self.op(s, x)
				self.front_deq.appendleft((x, self.op(x, s)))
		self.front_deq.popleft()

def sliding_minima(a, k):
	SWAG = SlidingWindowAggregation(op=lambda a, b: min(a, b))
	ret = []
	for item in a:
		SWAG.push(item)
		if len(SWAG) >= k:
			ret.append(SWAG.fold())
			SWAG.pop()
	return ret
t = int(input())
for _ in range(t):
	(n, m, k) = [int(item) for item in input().split()]
	a = [int(item) for item in input().split()]
	b = []
	for (a1, a2) in zip(a, a[n - m:]):
		b.append(max(a1, a2))
	ret = sliding_minima(b, m - k)
	print(max(ret))


from math import inf
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	ans = 0
	if k >= m - 1:
		for i in range(m):
			x = i
			y = n - 1 - (m - 1) + i
			act = max(a[x], a[y])
			ans = max(ans, act)
		print(ans)
		continue
	for i in range(k + 1):
		x = i
		y = n - 1 - k + i
		v = []
		for j in range(m - k):
			w = x + j
			z = y - (m - 1 - k) + j
			v.append(max(a[w], a[z]))
		aux = inf
		for j in range(len(v)):
			aux = min(aux, v[j])
		ans = max(ans, aux)
	print(ans)


import collections
T = int(input())
for case in range(T):
	(n, m, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	(k, b) = (min(m - 1, k), [])
	for i in range(m):
		b.append(max(a[i], a[i + n - m]))
	ans = 0
	d = collections.deque()
	for i in range(m):
		while d and b[i] <= b[d[-1]]:
			d.pop()
		while d and i - d[0] + 1 > m - k:
			d.popleft()
		d.append(i)
		if i >= m - k - 1:
			ans = max(ans, b[d[0]])
	print(ans)


import random
t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	arccnt = m - 1
	k = min(arccnt, k)
	arclen = n - m
	mm = []
	for i in range(0, n - arclen):
		mm.append(max(a[i], a[i + arclen]))
	wl = m - k
	if wl == 1:
		print(max(mm))
	else:
		b = [0 for i in range(len(mm))]
		c = b.copy()
		num = 1
		for i in range(len(b)):
			elem = mm[i]
			if num == 1:
				b[i] = elem
			else:
				b[i] = min(b[i - 1], elem)
			num += 1
			if num == wl:
				num = 1
		num = 1
		meme = True
		if len(mm) % (wl - 1) != 0:
			num = wl - len(mm) % (wl - 1)
		for i in range(len(c) - 1, -1, -1):
			elem = mm[i]
			if num == 1 or meme:
				c[i] = elem
				meme = False
			else:
				c[i] = min(c[i + 1], elem)
			num += 1
			if num == wl:
				num = 1
		amass = 0
		for i in range(0, len(mm) - wl + 1):
			amass = max(amass, min(c[i], b[i + wl - 1]))
		print(amass)


R = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, m, k) = R()
	a = R()
	k = min(k, m - 1)
	d = m - k
	ans = 0
	for i in range(k + 1):
		p = 10 ** 9
		for j in range(d):
			p = min(p, max(a[i + j], a[i + n - k - 1 - (d - 1 - j)]))
		ans = max(ans, p)
	print(ans)


import sys
readline = sys.stdin.readline

class Segtree:

	def __init__(self, A, intv, initialize=True, segf=max):
		self.N = len(A)
		self.N0 = 2 ** (self.N - 1).bit_length()
		self.intv = intv
		self.segf = segf
		if initialize:
			self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
			for i in range(self.N0 - 1, 0, -1):
				self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
		else:
			self.data = [intv] * (2 * self.N0)

	def update(self, k, x):
		k += self.N0
		self.data[k] = x
		while k > 0:
			k = k >> 1
			self.data[k] = self.segf(self.data[2 * k], self.data[2 * k + 1])

	def query(self, l, r):
		(L, R) = (l + self.N0, r + self.N0)
		s = self.intv
		while L < R:
			if R & 1:
				R -= 1
				s = self.segf(s, self.data[R])
			if L & 1:
				s = self.segf(s, self.data[L])
				L += 1
			L >>= 1
			R >>= 1
		return s

	def binsearch(self, l, r, check, reverse=False):
		(L, R) = (l + self.N0, r + self.N0)
		(SL, SR) = ([], [])
		while L < R:
			if R & 1:
				R -= 1
				SR.append(R)
			if L & 1:
				SL.append(L)
				L += 1
			L >>= 1
			R >>= 1
		if reverse:
			for idx in SR + SL[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx + 1]):
					idx = 2 * idx + 1
				else:
					idx = 2 * idx
			return idx - self.N0
		else:
			for idx in SL + SR[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx]):
					idx = 2 * idx
				else:
					idx = 2 * idx + 1
			return idx - self.N0
Tc = int(readline())
Ans = [None] * Tc
for qu in range(Tc):
	(N, M, K) = list(map(int, readline().split()))
	A = list(map(int, readline().split()))
	Ai = A[::-1]
	table = [None] * M
	for i in range(M):
		j = M - 1 - i
		table[i] = max(A[i], Ai[j])
	inf = 10 ** 9 + 7
	T = Segtree(table, inf, initialize=True, segf=min)
	ans = min(table)
	K = min(K, M - 1)
	R = M - 1 - K
	for ki in range(K + 1):
		ans = max(ans, T.query(ki, ki + R + 1))
	Ans[qu] = ans
print('\n'.join(map(str, Ans)))


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

class SegtreeMin:

	def __init__(self, aa):
		self.inf = 10 ** 16
		n = len(aa)
		tree_width = 2
		while tree_width < n:
			tree_width *= 2
		self.tree_width = tree_width
		self.tree = [self.inf] * (tree_width * 2 - 1)
		self.tree[tree_width - 1:tree_width - 1 + n] = aa[:]
		for i in range(tree_width - 2, -1, -1):
			self.tree[i] = min(self.tree[i * 2 + 1], self.tree[i * 2 + 2])

	def update(self, i, a):
		seg_i = self.tree_width - 1 + i
		self.tree[seg_i] = a
		while seg_i != 0:
			seg_i = (seg_i - 1) // 2
			self.tree[seg_i] = min(self.tree[seg_i * 2 + 1], self.tree[seg_i * 2 + 2])

	def element(self, i):
		return self.tree[self.tree_width - 1 + i]

	def min(self, l, r, seg_i=0, segL=0, segR=-1):
		if segR == -1:
			segR = self.tree_width
		if r <= segL or segR <= l:
			return self.inf
		if l <= segL and segR <= r:
			return self.tree[seg_i]
		segM = (segL + segR) // 2
		ret0 = self.min(l, r, seg_i * 2 + 1, segL, segM)
		ret1 = self.min(l, r, seg_i * 2 + 2, segM, segR)
		return min(ret0, ret1)

def main():
	t = II()
	for _ in range(t):
		(n, m, k) = MI()
		aa = LI()
		pp = [max(aa[i], aa[i + n - m]) for i in range(m)]
		st = SegtreeMin(pp)
		ans = 0
		k = min(k, m - 1)
		for i in range(k + 1):
			ans = max(st.min(i, i + m - k), ans)
		print(ans)
main()


import sys, heapq
from collections import *
from functools import lru_cache
sys.setrecursionlimit(10 ** 6)

def main():
	t = int(input())
	for _ in range(t):
		(n, m, k) = map(int, input().split(' '))
		arr = list(map(int, input().split(' ')))
		q = deque()
		k = min(k, m - 1)
		res = -float('inf')
		for i in range(m):
			cur = max(arr[i], arr[i + n - m])
			while q and i - q[0][1] > m - 1 - k:
				q.popleft()
			while q and q[-1][0] > cur:
				q.pop()
			q.append((cur, i))
			if i >= m - 1 - k:
				res = max(res, q[0][0])
		print(res)
main()


import os
import sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd, log
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
g = lambda : input().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()

def solve(a, l, r, buff):
	ans = inf
	ri = r - buff
	while ri <= r:
		ans = min(ans, max(a[l], a[ri]))
		l += 1
		ri += 1
	return ans
for _ in range(t):
	(n, m, k) = gil()
	a = gil()
	k = min(m - 1, k)
	buff = m - k - 1
	ans = -inf
	for r in range(n - k - 1, n):
		ans = max(ans, solve(a, r - n + k + 1, r, buff))
	print(ans)


def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return [str(x) for x in stdin.readline().split()]
from sys import stdin
arr = []
for i in range(int(stdin.readline())):
	(n, m, k) = arr_inp(1)
	(a, ans) = (arr_inp(1), 0)
	if m == 1:
		arr.append(str(max(a[0], a[-1])))
		continue
	if k >= m:
		k = m - 1
	for j in range(k + 1):
		(tem, z, num) = (float('inf'), n - k - 1 + j, m - k - 1)
		for c in range(j, j + (m - k)):
			tem = min(tem, max(a[c], a[z - num]))
			num -= 1
		ans = max(tem, ans)
	arr.append(str(ans))
print('\n'.join(arr))


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	pre = a[:m]
	suf = a[-1:-m - 1:-1]
	l = [max(pre[i], suf[m - i - 1]) for i in range(m)]
	if k >= m - 1:
		ans = max(l)
	elif k != 0:
		kmin = [min(l[i:m - k + i]) for i in range(k + 1)]
		ans = max(kmin)
	else:
		ans = min(l)
	print(ans)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mn = min(k, m - 1)
	(x, y) = (m - 1, n - m)
	ans = -1
	for i in range(mn + 1):
		val = float('inf')
		for j in range(m - mn):
			v = max(a[i + j], a[n - (m - i - j)])
			val = min(val, v)
		ans = max(ans, val)
	print(ans)


from operator import itemgetter
from collections import Counter

def solve(n, m, k, a):
	if k >= m:
		k = m - 1
	b = [max(a[i], a[i + n - m]) for i in range(m)]
	c = [min(b[i:m - k + i]) for i in range(k + 1)]
	print(max(c))

def main():
	t = int(input())
	for i in range(t):
		(n, m, k) = map(int, input().split())
		a = list(map(int, input().split()))
		solve(n, m, k, a)
main()


T = int(input())
for case in range(T):
	(n, m, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	k = min(m - 1, k)
	ans = 0
	for x in range(k + 1):
		res = int(2000000000.0)
		for y in range(m - k):
			res = min(res, max(a[x + y], a[x + y + n - m]))
		ans = max(ans, res)
	print(ans)


t = int(input())
for _ in range(t):
	ans = 0
	(n, pos, control) = map(int, input().split())
	control = min(control, pos - 1)
	not_control = pos - control - 1
	num = n - control - not_control
	a = list(map(int, input().split()))
	for i in range(control + 1):
		tmp = 10 ** 10 + 1
		for j in range(not_control + 1):
			try:
				tmp = min(tmp, max(a[i + j], a[i + j + num - 1]))
			except ReferenceError:
				pass
		ans = max(ans, tmp)
	if ans == 10 ** 10:
		ans = max(a[0], a[-1])
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k = min(k, m - 1)
	ans = 0
	for l in range(k + 1):
		r = k - l
		tmp = float('inf')
		for l2 in range(m - k):
			r2 = m - k - 1 - l2
			tmp = min(tmp, max(a[l + l2], a[n - r - r2 - 1]))
		ans = max(ans, tmp)
	print(ans)


t = int(input())

def slv():
	(n, m, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	ntr = max(0, m - k - 1)
	k = min(k, m - 1)
	sls = 0
	for i in range(k + 1):
		la = 10000000000.0
		for j in range(ntr + 1):
			la = min(la, max(a[i + j], a[len(a) - (k - i) - (ntr - j) - 1]))
		sls = max(sls, la)
	print(sls)
for _ in range(t):
	slv()


from sys import stdin, stderr
readline = stdin.buffer.readline

def rl():
	return [int(w) for w in readline().split()]
(t,) = rl()
for _ in range(t):
	(n, m, k) = rl()
	a = rl()
	k = min(k, m - 1)
	print(max((min((max(a[x + y], a[n - m + x + y]) for y in range(m - k))) for x in range(k + 1))))


import sys
input = sys.stdin.readline

def f(p, b, c):
	j = 0
	d = []
	while j <= p:
		q = max(b[j], c[p - j])
		d.append(q)
		j += 1
	return min(d)

def f1(p, b, c):
	j = 0
	d = []
	while j <= p:
		q = max(b[j], c[p - j])
		d.append(q)
		j += 1
	return max(d)
t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	b = list(map(int, input().split()))
	p = m - 1
	c = b.copy()
	c.reverse()
	j = 0
	d = []
	if k >= p:
		print(f1(p, b, c))
	else:
		ms = -1
		while j <= k:
			y = f(p - k, b[j:], c[k - j:])
			if y > ms:
				ms = y
			j += 1
		print(ms)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	r = n - k
	r1 = m - k - 1
	ans2 = 0
	r2 = n - m + 1
	if r1 > 0:
		for j in range(k + 1):
			a1 = a[j:j + r]
			x = 0
			ans1 = 1000000000
			for kk in range(r1 + 1):
				x = max(a1[kk], a1[kk + r2 - 1])
				ans1 = min(ans1, x)
			ans2 = max(ans2, ans1)
	else:
		for j in range(m):
			a1 = a[j:j + r2]
			ans2 = max(ans2, a1[0], a1[-1])
	print(ans2)


t = int(input())
while t != 0:
	(n, m, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	mini = pow(10, 9) + 7
	u = 0
	list2 = list()
	k = min(k, m - 1)
	for i in range(m - 1, -1, -1):
		p = max(list1[i], list1[len(list1) - 1 - u])
		list2.append(p)
		u += 1
	temp = list()
	for i in range(k + 1):
		temp.append(min(list2[i:i + m - k]))
	print(max(temp))
	t -= 1


t = int(input())
for y in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k >= m - 1:
		ans = max(max(a[:m]), max(a[n - m:]))
	else:
		i = k
		j = 0
		ans = 0
		while i >= 0:
			ind1 = i + (m - k) - 1
			ind2 = n - j - 1
			res2 = 1000000000.0
			for kk in range(m - k):
				res = max(a[ind1 - kk], a[ind2 - kk])
				res2 = min(res, res2)
			ans = max(ans, res2)
			i -= 1
			j += 1
	print(ans)


from math import *
import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	t -= 1
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if k >= m - 1:
		b = a[:m]
		c = a[n - m:n]
		print(max(max(b), max(c)))
		continue
	mini = -999
	for i in range(k + 1):
		s = i
		e = n - k + i - 1
		mini1 = -999
		for j in range(m - k - 1):
			if mini1 == -999:
				mini1 = max(a[s + j], a[e - m + k + 1 + j])
			else:
				mini1 = min(mini1, max(a[s + j], a[e - m + k + 1 + j]))
			mini1 = min(mini1, max(a[s + j + 1], a[e - m + k + 2 + j]))
		mini = max(mini, mini1)
	print(mini)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(min(m, k + 1)):
		tmp = 10 ** 9 + 1
		for j in range(max(1, m - k)):
			tmp = min(tmp, max(a[i + j], a[n - m + j + i]))
		ans = max(tmp, ans)
	print(ans)


def ma(x):
	return max(x[0], x[-1])
z = int(input())
for zz in range(z):
	(n, m, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	segs = []
	x = n - m + 1
	for i in range(m):
		segs.append(a[i:i + x])
	x = len(segs)
	for i in range(x):
		segs[i] = ma(segs[i])
	tm = max(a) + 1
	res = -1
	st = max(0, m - k - 1)
	for i in range(min(k + 1, m)):
		te = min(i, k)
		si = max(te, i - st)
		te2 = max(x - k - 1, i + m)
		ei = min(te2, i + st)
		r = min(segs[si:ei + 1])
		res = max(res, r)
	print(res)


def chek(x, li, l):
	mn = max(li[0], li[l - 1])
	for i in range(x + 1):
		mx = max(li[i], li[l + i - 1])
		mn = min(mn, mx)
	return mn
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	b = 0
	x = m - 1 - k
	l = n - k
	y = n - (m - 1)
	if x <= 0:
		print(max(max(ar[:m]), max(ar[n - m:])))
		continue
	for j in range(k + 1):
		a = chek(x, ar[j:j + l], y)
		b = max(a, b)
	print(b)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	before = m - 1
	k = min(k, m)
	temp = [max(a[i], a[n + i - 1 - before]) for i in range(before + 1)]
	if k >= before:
		print(max(temp))
	elif k == 0:
		print(min(temp))
	else:
		temp2 = [min(temp[j:before + 1 - k + j]) for j in range(k + 1)]
		print(max(temp2))


INF = 10 ** 10

def main():
	(n, m, k) = get_list()
	li = get_list()
	k = min(m - 1, k)
	best_ans = 0
	for i in range(k + 1):
		array = li[i:i + n - k]
		worst_ans = INF
		for j in range(m - k):
			worst_ans = min(worst_ans, max(array[j], array[j + len(array) - (m - k)]))
		best_ans = max(worst_ans, best_ans)
	print(best_ans)
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()

def foo(b, before, m):
	m1 = 10 ** 9
	for j in range(m - before):
		m1 = min(m1, max(b[j], b[j + len(b) - (m - before)]))
	return m1
t = getInt()
for _ in range(t):
	(n, m, k) = getVars()
	a = getList()
	before = min(m - 1, k)
	res = 0
	if before == 0:
		res = foo(a, 0, m)
	else:
		for i in range(before + 1):
			b = a[i:i + n - before]
			m1 = foo(b, before, m)
			res = max(m1, res)
	print(res)


t = int(input())
while t != 0:
	t -= 1
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	w = m - k
	l = list(map(int, input().split()))
	a = [max(l[i], l[i + n - m]) for i in range(m)]
	b = [min(a[i:i + w]) for i in range(m - w + 1)]
	print(max(b))


import sys
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	k = min(k, m - 1)
	A = []
	for i in range(m):
		m1 = max(arr[i], arr[-m + i])
		A.append(m1)
	print(max([min(A[i:i + m - k]) for i in range(k + 1)]))


import sys
input = sys.stdin.readline
t = int(input())
for _ in [0] * t:
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = n - m + 1
	ma = [0] * (n - l + 1)
	for i in range(n - l + 1):
		if a[i] > a[i + l - 1]:
			ma[i] = a[i]
		else:
			ma[i] = a[i + l - 1]
	ha = k
	if ha >= m:
		ha = m - 1
	w = n - l + 1 - ha
	mi = [10 ** 10] * (n - l - w + 2)
	for i in range(n - l - w + 2):
		for j in range(w):
			if mi[i] > ma[i + j]:
				mi[i] = ma[i + j]
	print(max(mi))


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(t,) = I()
for t1 in range(t):
	(n, m, k) = I()
	a = I()
	a = [0] + a
	dp = [0] * m
	for i in range(m):
		dp[i] = max(a[i + 1], a[n - m + i + 1])
	max1 = 0
	for i in range(len(dp)):
		min1 = dp[i]
		for j in range(i, len(dp)):
			min1 = min(min1, dp[j])
			if i + len(dp) - j - 1 <= k:
				min1 = min(min1, dp[j])
				max1 = max(max1, min1)
	print(max1)


t = int(input())
for v in range(t):
	(n, m, k) = map(int, input().split())
	li = list(map(int, input().split()))
	k = min(k, m - 1)
	ans = 0
	for i in range(0, k + 1):
		strategy_ans = int(pow(10, 9) + 5)
		for j in range(0, m - k):
			case_ans = max(li[i + j], li[i + j + n - m])
			strategy_ans = min(case_ans, strategy_ans)
		ans = max(strategy_ans, ans)
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, m, k) = inp()
	arr = list(inp())
	if m - 1 <= k:
		ans = max(arr[:m])
		ans = max(ans, max(arr[n - m:n]))
	else:
		rem = m - 1 - k
		an = []
		org = deque(arr)
		elelist = deque()
		outer = []
		for i in range(k):
			elelist.append(org.pop())
		for i in range(k + 1):
			if i == 0:
				pass
			else:
				org.append(elelist.pop())
				org.popleft()
			ch = deque(org)
			inner = []
			empty = deque()
			for i in range(rem):
				empty.append(ch.pop())
			for i in range(rem + 1):
				if i == 0:
					pass
				else:
					ch.append(empty.pop())
					ch.popleft()
				inner.append(max(ch[0], ch[-1]))
			outer.append(min(inner))
		ans = max(outer)
	out(ans)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(before, after) = (m - 1, n - m)
	control = min(k, m - 1)
	outctrl = before - control
	ans = 0
	for i in range(control + 1):
		val = int(1000000000.0 + 1000)
		for j in range(outctrl + 1):
			val = min(val, max(a[i + j], a[i + after + j]))
		ans = max(val, ans)
	print(ans)


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	if k >= m - 1:
		for j in range(m):
			ans = max(ans, max(a[j], a[n - m + j]))
	else:
		for j in range(k + 1):
			tmp = 99999999999
			for l in range(m - k):
				tmp = min(tmp, max(a[j + l], a[n + j - m + l]))
			ans = max(ans, tmp)
	print(ans)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, m, k) = mapin()
	a = [int(c) for c in input().split()]
	if k > m - 1:
		k = m - 1
	ans = 0
	for i in range(k + 1):
		temp = int(1000000000.0) + 5
		for j in range(m - k):
			t2 = max(a[i + j], a[i + j + n - m])
			temp = min(temp, t2)
		ans = max(ans, temp)
	print(ans)


def check(arr, m):
	n = len(arr)
	min_val = float('inf')
	for i in range(m):
		min_val = min(min_val, max(arr[i], arr[n - m + i]))
	arr.reverse()
	for i in range(m):
		min_val = min(min_val, max(arr[i], arr[n - m + i]))
	if min_val == float('inf'):
		return 0
	return min_val

def solve(arr, n, m, k, ans):
	max_val = 0
	if m <= k:
		max_val = max(arr[:m])
		arr.reverse()
		max_val = max(max_val, max(arr[:m]))
	else:
		m -= k
		for i in range(k + 1):
			arr1 = arr[i:i + n - k]
			max_val = max(max_val, check(arr1, m))
	ans.append(max_val)

def main():
	ans = []
	t = int(input())
	for i in range(t):
		(n, m, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		solve(arr, n, m, k, ans)
	for i in ans:
		print(i)
main()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, M, K) = MAP()
	A = LIST()
	K = min(K, M - 1)
	L = M - K - 1
	ans = 0
	for i in range(K + 1):
		j = N - K + i
		mn = INF
		for k in range(L + 1):
			l = L - k
			mx = max(A[i + k], A[j - l - 1])
			mn = min(mn, mx)
		ans = max(ans, mn)
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class RangeMinimumQuery:

	def __init__(self, n, F=min, e=float('inf'), fill=None):
		self.n = n
		self.n0 = 2 ** (n - 1).bit_length()
		self.F = F
		self.e = e
		if fill is None:
			fill = e
		self.data = [fill] * (2 * self.n0)

	def construct(self, a):
		for (i, x) in enumerate(a):
			self.data[i + self.n0 - 1] = x
		for i in range(self.n0 - 2, -1, -1):
			self.data[i] = self.F(self.data[2 * i + 1], self.data[2 * i + 2])

	def query(self, l, r):
		l += self.n0
		r += self.n0
		res = self.e
		while l < r:
			if r & 1:
				r -= 1
				res = self.F(res, self.data[r - 1])
			if l & 1:
				res = self.F(res, self.data[l - 1])
				l += 1
			l >>= 1
			r >>= 1
		return res

	def update(self, i, x):
		i += self.n0 - 1
		self.data[i] = x
		while i:
			i = ~-i // 2
			self.data[i] = self.F(self.data[2 * i + 1], self.data[2 * i + 2])

	def show(self):
		ret = [self.query(i, i + 1) for i in range(self.n)]
		print(ret)

def solve():
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	b = []
	for i in range(m):
		left = i
		right = n - m + i
		cost = max(a[left], a[right])
		b.append(cost)
	n = len(b)
	RMQ = RangeMinimumQuery(n, fill=0)
	RMQ.construct(b)
	ans = 0
	w = n - k
	for i in range(n - w + 1):
		ma = RMQ.query(i, i + w)
		ans = max(ans, ma)
	print(ans)
t = int(input())
for i in range(t):
	solve()


import math

def solve(n, m, k, a_s):
	ans = 1
	k = min(k, m - 1)
	rand_thresh = m - 1 - k
	for st_init in range(k + 1):
		ed_init = n - 1 - (k - st_init)
		rands = max(rand_thresh, 0)
		st = st_init
		ed = ed_init
		if rands > 0:
			rand_ans = math.inf
			for st_offset in range(rands + 1):
				ed_offset = rands - st_offset
				rand_ans = min(rand_ans, max(a_s[st + st_offset], a_s[ed - ed_offset]))
			ans = max(ans, rand_ans)
		else:
			ans = max(ans, max(a_s[st], a_s[ed]))
	return ans
t = int(input())
for _ in range(t):
	(n, m, k) = [int(ch) for ch in input().split(' ')]
	a_s = [int(ch) for ch in input().split(' ')]
	print(solve(n, m, k, a_s))


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	b = []
	for i in range(m):
		b.append(max(a[i], a[i + n - m]))
	sz = m - k
	ans = 0
	j = 0
	q = []
	for i in range(k + 1):
		while q and q[0] < i:
			q.pop(0)
		while j < i + sz:
			while q and b[q[-1]] >= b[j]:
				q.pop()
			q.append(j)
			j += 1
		ans = max(ans, b[q[0]])
	print(ans)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = -1
	if k >= m:
		for i in range(n):
			if i < m or i > n - m - 1:
				mx = max(mx, a[i])
		print(mx)
	else:
		ans = 0
		for t in range(k + 1):
			val = 10000000000
			for i in range(m - k):
				val = min(val, max(a[t + i], a[n - 1 - k + t - (m - k - 1) + i]))
			ans = max(ans, val)
		print(ans)


from collections import deque

def main():
	t = int(input().strip())
	for _ in range(t):
		(n, m, k) = [int(s) for s in input().strip().split()]
		A = [int(s) for s in input().strip().split()]
		k = min(k, m - 1)
		B = []
		for i in range(m):
			j = i + n - m
			B.append(max(A[i], A[j]))
		result = float('-inf')
		dq = deque()
		for i in range(len(B) - k - 1):
			while dq and dq[-1] > B[i]:
				dq.pop()
			dq.append(B[i])
		for i in range(len(B) - k - 1, len(B)):
			while dq and dq[-1] > B[i]:
				dq.pop()
			dq.append(B[i])
			result = max(result, dq[0])
			if dq[0] == B[i - len(B) + k + 1]:
				dq.popleft()
		print(result)
main()


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	(n, m, k) = rinput()
	a = rlinput()
	ans = 0
	for first1 in range(min(m - 1, k) + 1):
		ans1 = float('inf')
		for first2 in range(m - min(m - 1, k)):
			(idx1, idx2) = (first1 + first2, n - m + first2 + first1)
			ans1 = min(ans1, max(a[idx1], a[idx2]))
		ans = max(ans, ans1)
	print(ans)


def solve(l, r, p):
	res = 1000000000
	for i in range(0, p + 1):
		res = min(res, max(a[l + i], a[r - (p - i)]))
	return res
T = int(input())
while T > 0:
	T -= 1
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	ans = 0
	for l in range(0, k + 1):
		ans = max(ans, solve(l, n - (k - l) - 1, m - k - 1))
	print(ans)


(V, IDX) = ([0] * 3501, [0] * 3501)

def solve(A, n, m, k):
	d = n - m
	B = [0] * m
	for i in range(m):
		B[i] = max(A[i], A[i + d])
	w = max(1, m - k)
	res = 0
	l = r = 0
	for i in range(m):
		while r > l and V[r - 1] >= B[i]:
			r -= 1
		(V[r], IDX[r]) = (B[i], i)
		r += 1
		if IDX[l] == i - w:
			l += 1
		if i >= w - 1:
			res = max(res, V[l])
	return res
n = int(input())
for i in range(n):
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().strip().split()))
	print(solve(A, n, m, k))


from collections import deque
t = int(input())
for i2 in range(t):
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	d = deque()
	x = list(map(int, input().split()))
	(bigger, left, ans) = ([], n - m, 0)
	for i in range(n):
		if i + left < n:
			bigger.append(max(x[i], x[i + left]))
	left2 = len(bigger) - k
	for i in range(len(bigger)):
		while len(d) > 0 and d[len(d) - 1][0] >= bigger[i]:
			d.pop()
		if len(d) > 0 and d[0][1] == i:
			d.popleft()
		d.append([bigger[i], i + left2])
		if i >= left2 - 1:
			ans = max(ans, d[0][0])
	print(ans)


t = int(input())
for _ in range(t):
	(n, m, control) = map(int, input().split())
	a = list(map(int, input().split()))
	control = min(m - 1, control)
	not_control = m - control - 1
	num = n - control - not_control
	ans = 0
	for i in range(control + 1):
		temp = 10 ** 9
		for j in range(not_control + 1):
			temp = min(temp, max(a[i + j], a[i + j + num - 1]))
		ans = max(temp, ans)
	print(ans)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]

def solve(N, M, K, A):
	if M == 1:
		return max(A[0], A[N - 1])
	K = min(K, M - 1)
	v_max = 0
	i1 = 0
	i2 = N - 1 - K
	for _ in range(K + 1):
		B = A[i1:i2 + 1]
		n = N - K
		m = M - 1 - K
		v = min((max(B[i], B[i + n - m - 1]) for i in range(0, m + 1)))
		v_max = max(v_max, v)
		i1 += 1
		i2 += 1
	return v_max

def main():
	T0 = int(input())
	for _ in range(T0):
		(N, M, K) = map(int, input().split())
		A = list(map(int, input().split()))
		ans = solve(N, M, K, A)
		print(ans)
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	if k >= m:
		k = m - 1
	a = list(map(int, input().split()))
	l = [max(a[i], a[i + n - m]) for i in range(m)]
	l2 = [min(l[i:i + m - k]) for i in range(k + 1)]
	print(max(l2))


a = [0 for i in range(3505)]
q = int(input())
for _ in range(q):
	(n, m, k) = map(int, input().split())
	a[1:] = list(map(int, input().split()))
	k = min(k, m - 1)
	(re, ans) = (n - k, 0)
	for l in range(1, n - re + 2):
		(r, x, len) = (l + re - 1, int(1000000000.0), n - m + 1)
		for i in range(l, r - len + 2):
			x = min(x, max(a[i], a[i + len - 1]))
		ans = max(ans, x)
	print(ans)


import math

def solve():
	(n, m, k) = map(int, input().split())
	table = list(map(int, input().split()))
	k = min(k, m - 1)
	ans = -1
	for i in range(0, k + 1, 1):
		j = k - i
		left = m - k - 1
		(ls, re) = (i, n - 1 - j)
		tempans = 10 ** 9 + 7
		for p in range(0, left + 1, 1):
			tempans = min(tempans, max(table[ls + p], table[re - (left - p)]))
		ans = max(ans, tempans)
	print(ans)

def main():
	T = 1
	T = int(input())
	while T:
		solve()
		T -= 1
main()


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		(n, m, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = [0]
		if k >= m:
			for p in range(m):
				b.append(max(a[p], a[n - p - 1]))
		else:
			for p in range(k + 1):
				t = a[p:n - k + p]
				s = len(t)
				f = -1
				d = []
				for p in range(m - k):
					d.append(max(t[p], t[p + s - (m - k - 1) - 1]))
				b.append(min(d))
		print(max(b))
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, M, K) = getInts()
	A = dq(getInts())
	best = -10 ** 10
	K = min(K, M - 1)
	for x in range(K + 1):
		tmp_best = 10 ** 10
		for m in range(M - K):
			tmp_best = min(tmp_best, max(A[x + m], A[-(M - m - x)]))
		best = max(tmp_best, best)
	return best
for _ in range(getInt()):
	print(solve())


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	left = n - m
	done = m - 1
	k = min(k, done)
	ans = 0
	for i in range(k + 1):
		temp = 10 ** 9 + 3
		for j in range(done - k + 1):
			t = max(l[i + j], l[i + j + left])
			temp = min(temp, t)
		ans = max(ans, temp)
	print(ans)


t = int(input())
for _ in range(t):
	(n, m, K) = map(int, input().split())
	a = [int(x) for x in input().split()]
	k = min(K, m - 1)
	ptr1 = k - 1
	ptr2 = 0
	ans = min(a)
	for i in range(k + 1):
		e1 = ptr1 + (m - k - 1)
		e2 = ptr2
		c = max(a)
		for j in range(m - k):
			c = min(c, max(a[e1 + 1], a[e2 - 1]))
			e1 -= 1
			e2 -= 1
		ans = max(ans, c)
		ptr1 -= 1
		ptr2 -= 1
	print(ans)


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, m, k) = map(int, input().split())
		a = list(map(int, input().split()))
		n_con = max(0, m - k - 1)
		con = m - 1 - n_con
		arr = [10 ** 20] * (con + 1)
		for i in range(n_con + 1):
			(u, v) = (i, n - 1 + i - n_con)
			for j in range(con + 1):
				arr[j] = min(arr[j], max(a[u + j], a[v - con + j]))
		print(max(arr))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
t = input()

def solve(n, m, k, nums):
	ans = 0
	new_k = min(m - 1, k)
	for kk in range(new_k + 1):
		left = kk
		right = new_k - kk
		temp = nums[left:len(nums) - right]
		c = min([max(temp[i], temp[-(m - new_k - i)]) for i in range(m - new_k)])
		ans = max(ans, c)
	return ans
for _ in range(int(t)):
	temp = [int(s) for s in sys.stdin.readline().split(' ')]
	n = temp[0]
	m = temp[1]
	k = temp[2]
	nums = [int(s) for s in sys.stdin.readline().split(' ')]
	print(solve(n, m, k, nums))


t = int(input())
for _ in range(t):
	(n, m, k) = tuple(map(int, input().split()))
	l = list(map(int, input().split()))
	M = max(l)
	k = min(k, m - 1)
	realp = m - k - 1
	ma = -1
	for i in range(k + 1):
		tmp = M
		for j in range(realp + 1):
			tmp = min(tmp, max(l[i + j], l[i + j + n - m]))
		ma = max(ma, tmp)
	print(ma)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	b = []
	for i in range(m):
		b.append(max(a[i], a[i + n - m]))
		j = i + n - m
	ans = 0
	for i in range(k + 1):
		ans = max(ans, min(b[i:i + m - k]))
	print(ans)


a = int(input())
for i in range(a):
	(n, m, k) = map(int, input().split())
	z = list(map(int, input().split()))
	if m - 1 <= k:
		ans1 = z[::-1]
		print(max(max(z[0:m]), max(ans1[0:m])))
	else:
		alpha = []
		for i in range(k + 1):
			ans = z[i:len(z) - (k - i)]
			t = m - k - 1
			kapa = []
			for i in range(t + 1):
				kapa.append(max(ans[i], ans[-1 * (t - i + 1)]))
			alpha.append(min(kapa))
		print(max(alpha))


from sys import stdin
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	k = min(k, m - 1)
	b = [max(l[i], l[n + i - m]) for i in range(m)]
	x = max((min(b[i:i + m - k]) for i in range(k + 1)))
	print(x)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	b = list(map(int, input().split()))
	ans = 0
	if k <= m - 1:
		for i in range(k + 1):
			q = float('inf')
			for j in range(m - k):
				q = min(q, max(b[i + j], b[n - m + (i + j)]))
			ans = max(ans, q)
	else:
		for i in range(m):
			ans = max(ans, max(b[i], b[n - 1 - (m - 1 - i)]))
	print(ans)


import io
import os
from collections import Counter, defaultdict, deque

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

def solve(N, M, K, A):
	K = min(K, M - 1)
	bestEnds = []
	for i in range(N):
		front = A[i]
		j = i + (N - (M - 1)) - 1
		if j >= N:
			break
		back = A[j]
		bestEnds.append(max(front, back))
	rangeMin = RangeQuery(bestEnds)
	ans = float('-inf')
	for left in range(K + 1):
		for right in range(K - left + 1):
			assert left + right <= K
			others = M - left - right - 1
			if others == 0:
				ans = max(ans, bestEnds[left])
			else:
				ans = max(ans, rangeMin.query(left, left + others + 1))
	return ans
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, M, K) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, M, K, A)
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	List = [int(x) for x in input().split()]
	ans = 0
	k = min(k, m - 1)
	a = [max(List[i], List[i + n - m]) for i in range(m)]
	x = 0
	for i in range(k + 1):
		x = max(x, min(a[i:i + (m - k)]))
	print(x)


for _ in range(int(input())):
	(n, m, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	mi = 0
	for i in range(min(k, m - 1) + 1):
		temp = 100000000000
		for j in range(m - min(k, m - 1)):
			temp = min(temp, max(l[i + j], l[n - m + i + j]))
		mi = max(mi, temp)
	print(mi)


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	ans = 0
	(n, m, k) = nm()
	a = nl()
	g = max(m - k - 1, 0)
	for i in range(min(k, m - 1) + 1):
		lidx = i
		ridx = n - min(k, m - 1) - 1 + i
		cur = min((max(a[lidx + j], a[ridx - g + j]) for j in range(g + 1)))
		ans = max(cur, ans)
	print(ans)
	return
T = ni()
for _ in range(T):
	solve()


import sys
input = sys.stdin.readline
t = int(input())

class SegTree:

	def segfunc(self, x, y):
		return min(x, y)

	def __init__(self, n, ide_ele, init_val):
		self.ide_ele = ide_ele
		self.num = 2 ** (n - 1).bit_length()
		self.seg = [self.ide_ele] * 2 * self.num
		for i in range(n):
			self.seg[i + self.num - 1] = init_val[i]
		for i in range(self.num - 2, -1, -1):
			self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])

	def update(self, k, x):
		k += self.num - 1
		self.seg[k] = x
		while k + 1:
			k = (k - 1) // 2
			self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])

	def query(self, p, q):
		if q <= p:
			return self.ide_ele
		p += self.num - 1
		q += self.num - 2
		res = self.ide_ele
		while q - p > 1:
			if p & 1 == 0:
				res = self.segfunc(res, self.seg[p])
			if q & 1 == 1:
				res = self.segfunc(res, self.seg[q])
				q -= 1
			p = p // 2
			q = (q - 1) // 2
		if p == q:
			res = self.segfunc(res, self.seg[p])
		else:
			res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
		return res
for _ in range(t):
	(N, M, K) = map(int, input().split())
	a = list(map(int, input().split()))
	dp = [0] * M
	for l in range(M):
		r = M - l - 1
		dp[l] = max(a[l], a[-1 - r])
	res = 0
	if K >= M - 1:
		print(max(dp))
		continue
	if K == 0:
		print(min(dp))
		continue
	seg = SegTree(M, 10 ** 10, dp)
	for l in range(K):
		tt = seg.query(l, min(M, l + M - K))
		res = max(res, tt)
	dp.reverse()
	seg = SegTree(M, 10 ** 10, dp)
	for l in range(K):
		tt = seg.query(l, min(M, l + M - K))
		res = max(res, tt)
	print(res)


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for fashjufjh in range(t):
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	ans = []
	for i in range(m):
		ans.append([max(a[i], a[i + n - m]), i])
	ans.sort()
	ans1 = [0]
	for i in ans:
		ans1.append(i[1] + 1)
		ans1.append(len(ans) + 1)
		ans1.sort()
		aans = 100000000000
		for j in range(len(ans1) - 1):
			aans = min(aans, ans1[j] + len(ans) - ans1[j + 1] + 1)
		ans1.pop()
		if aans > k:
			print(i[0])
			break


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
MAX = 10 ** 9
ans = []
for _ in range(ii()):
	(n, m, k) = mi()
	d = li()
	k = min(m - 1, k)
	u = max(0, m - 1 - k)
	up = [(i, u - i) for i in range(u + 1)]
	kp = [(i, k - i) for i in range(k + 1)]
	res = 0
	for a in kp:
		temp = MAX
		for b in up:
			x = a[0] + b[0]
			y = a[1] + b[1]
			temp = min(temp, max(d[x], d[n - y - 1]))
		res = max(res, temp)
	ans.append(res)
prr(ans, '\n')


from collections import deque
import copy
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	candidate = [0] * m
	for i in range(m):
		l_ = l[i:n - (m - i) + 1]
		candidate[i] = max(l_[0], l_[-1])
	if k >= m - 1:
		print(max(candidate))
		continue
	candidate = deque(candidate)
	temps = [0] * (k + 1)
	for a in range(k + 1):
		candidate_ = copy.copy(candidate)
		b = k - a
		for i in range(a):
			candidate_.popleft()
		for j in range(b):
			candidate_.pop()
		temp = min(candidate_)
		temps[a] = temp
	print(max(temps))


def Input():
	tem = input().split()
	ans = []
	for it in tem:
		ans.append(int(it))
	return ans
T = Input()[0]
for t in range(T):
	(n, m, k) = Input()
	a = Input()
	if k + 1 >= m:
		(l, r) = (0, n - m)
		ans = -10000000000000
		while r < n:
			ans = max(ans, a[l], a[r])
			l += 1
			r += 1
		print(ans)
	else:
		b = []
		(l, r) = (0, n - m)
		while r < n:
			b.append(max(a[l], a[r]))
			l += 1
			r += 1
		(l, r) = (1, m - k)
		que = []
		max_que = []
		for i in range(m - k):
			que.append([b[i], i])
			while len(max_que) > 0 and max_que[-1][0] >= b[i]:
				max_que.pop()
			max_que.append([b[i], i])
		ans = max_que[0][0]
		while r < m:
			que.append([b[r], r])
			while len(max_que) > 0 and max_que[-1][0] >= b[r]:
				max_que.pop()
			max_que.append([b[r], r])
			while que[0][1] >= max_que[0][1]:
				del max_que[0]
			del que[0]
			ans = max(ans, max_que[0][0])
			l += 1
			r += 1
		print(ans)


t = int(input())

def remchoice(a2, rem):
	ans = float('inf')
	for i in range(rem + 1):
		ans = min(ans, max(a2[i], a2[-rem + i - 1]))
	return ans
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if m - 1 <= k:
		print(max(max(a[:m]), max(a[-m:])))
	else:
		rem = m - 1 - k
		ans = 0
		for j in range(k + 1):
			ans = max(ans, remchoice(a[j:n - (k - j)], rem))
		print(ans)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for _ in range(int(input())):
	(n, m, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	controlled = min(m - 1, k)
	score = 0
	for i in range(controlled + 1):
		uncontrolled = max(0, m - k - 1)
		low = 10 ** 9 + 1
		for j in range(uncontrolled + 1):
			best = max(a[i + j], a[len(a) - (controlled - i) - (uncontrolled - j) - 1])
			low = min(low, best)
		score = max(score, low)
	print(score)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

class SegmentTree:

	def __init__(self, N, operator, identity_element):
		self.__N = 2 ** int(math.ceil(math.log(N, 2)))
		self.__table = [identity_element] * (self.__N * 2 - 1)
		self.__op = operator
		self.__ie = identity_element

	def update(self, idx, x):
		i = self.__N - 1 + idx
		t = self.__table
		o = self.__op
		t[i] = x
		while i != 0:
			pi = (i - 1) // 2
			li = 2 * pi + 1
			ri = 2 * pi + 2
			v = o(t[li], t[ri])
			if t[pi] != v:
				t[pi] = v
			else:
				break
			i = pi

	def query(self, a, b):
		stack = [(0, 0, self.__N)]
		t = self.__table
		o = self.__op
		ans = self.__ie
		c = 0
		while stack:
			c += 1
			(k, l, r) = stack.pop()
			cnd = t[k]
			if a <= l and r <= b:
				ans = o(ans, cnd)
			else:
				if (l + r) // 2 > a and b > l:
					stack.append((2 * k + 1, l, (l + r) // 2))
				if r > a and b > (l + r) // 2:
					stack.append((2 * k + 2, (l + r) // 2, r))
		return ans

	def print(self):
		print(self.__table)

def slv(N, M, K, A):
	K = min(M - 1, K)
	R = M - K - 1
	ans = -1
	for i in range(K + 1):
		cand = INF
		for j in range(R + 1):
			k = i + j
			l = N - 1 - (K - i) - (R - j)
			cand = min(cand, max(A[k], A[l]))
		ans = max(ans, cand)
	return ans

def main():
	T = read_int()
	for _ in range(T):
		(N, M, K) = read_int_n()
		A = read_int_n()
		print(slv(N, M, K, A))
main()


def inp(dtype=str, strip=True):
	s = input()
	res = [dtype(p) for p in s.split()]
	res = res[0] if len(res) == 1 and strip else res
	return res

def problemA():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		s = [int(el) for el in s]
		res = '-1'
		cum = sum(s)
		i = 1
		while i <= n:
			if s[-i] % 2 != 0 and cum % 2 == 0:
				res = ''.join([str(s[j]) for j in range(n - i + 1)])
				break
			cum -= s[-i]
			i += 1
		print(res)

def problemB():
	t = int(input())
	for tcase in range(t):
		n = int(input())
		a = inp(int, strip=False)
		next = a[0] + 1 if a[0] <= 0 else 1
		i = 1
		while i < n and a[i] >= next:
			if a[i] < 0:
				next = a[i] + 1
			elif next <= 0:
				next = 1
			else:
				next += 1
			i += 1
		if i == n:
			print('YES')
			continue
		ileft = i - 1
		gapleft = a[ileft] < next - 1
		i = n - 1
		next = a[i] + 1 if a[i] <= 0 else 1
		i -= 1
		while i >= 0 and a[i] >= next:
			if a[i] < 0:
				next = a[i] + 1
			elif next <= 0:
				next = 1
			else:
				next += 1
			i -= 1
		if i < 0:
			print('YES')
			continue
		iright = i + 1
		gapright = a[iright] < next - 1
		if ileft + 1 > iright:
			print('YES')
		elif ileft + 1 == iright:
			if a[ileft] != a[iright]:
				print('YES')
			elif a[ileft] > 0 and (gapleft or gapright):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')

def problemC():
	t = int(input())
	for _ in range(t):
		(n, m, k) = inp(int)
		k = min(k, m - 1)
		a = inp(int, strip=False)
		b = [max(a[i], a[i + (n - m)]) for i in range(0, m)]
		x = max((min(b[i:i + (m - k)]) for i in range(k + 1)))
		print(x)
problemC()


from collections import deque

class MonotonicDeque(deque):

	def __init__(self):
		self.aux = deque()

	def append(self, x):
		super().append(x)
		while len(self.aux) and self.aux[-1] > x:
			self.aux.pop()
		self.aux.append(x)

	def popleft(self):
		x = super().popleft()
		if self.aux[0] == x:
			self.aux.popleft()
		return x

	def min(self):
		return self.aux[0]
for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	k = min(k, m - 1)
	a = list(map(int, input().split()))
	b = [max(a[i], a[i + n - m]) for i in range(m)]
	md = MonotonicDeque()
	ans = -1
	for j in range(len(b)):
		md.append(b[j])
		if j >= m - k:
			md.popleft()
		if len(md) == m - k:
			ans = max(ans, md.min())
	print(ans)