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$.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Complete search


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))


def solve(n, m, k, a):
	prior_selections = m - 1
	forced_choice = min(k, prior_selections)
	free_choice = prior_selections - forced_choice
	best_selection = [0] * (prior_selections + 1)
	for selected_first in range(prior_selections + 1):
		first_element = a[selected_first]
		selected_last = prior_selections - selected_first
		last_element = a[-(selected_last + 1)]
		best_selection[selected_first] = max(first_element, last_element)
	return max((min((best_selection[forced_first + picked_first] for picked_first in range(free_choice + 1))) for forced_first in range(forced_choice + 1)))
for T in range(int(input())):
	(n, m, k) = map(int, input().split())
	print(solve(n, m, k, list(map(int, input().split()))))


q = int(input())
for rwewe in range(q):
	(n, m, k) = list(map(int, input().split()))
	k = min(k, m - 1)
	l = list(map(int, input().split()))
	cyk = []
	for i in range(n):
		try:
			cyk.append(max(l[i], l[n - m + i]))
		except Exception:
			xx = 0
	p = len(cyk) - k
	wyn = -1231314134411312
	i = 0
	while i + p <= len(cyk):
		wyn = max(wyn, min(cyk[i:i + p]))
		i += 1
	print(wyn)


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	(N, M, K) = list(map(int, input().split()))
	K = min(K, M - 1)
	A = [int(a) for a in input().split()]
	B = [max(A[i], A[-M + i]) for i in range(M)]
	print(max([min(B[i:i + M - K]) for i in range(K + 1)]))


T = int(input())
for cs in range(T):
	(n, m, k) = map(int, input().split())
	a = tuple(map(int, input().split()))
	k = min(k, m - 1)
	p = m - k
	mx = 0
	for dummy in range(10):
		for i in range(k + 1):
			mn = 1000000007
			for j in range(p):
				mn = min(mn, max(a[i + j], a[n - k + i - p + j]))
			mx = max(mx, mn)
	print(mx)


t = int(input())
for _ in range(t):
	(n, m, k) = [int(x) for x in input().split(' ')]
	v = [int(x) for x in input().split(' ')]
	(i, j) = (0, n - 1)
	k = min(k, m - 1)
	kk = k
	mm = m
	ans = max(v)
	final = min(v)
	for x in range(0, k + 1):
		ans = max(v)
		for y in range(0, m - k):
			ans = min(ans, max(v[x + y], v[n - 1 - (m - 1 - x - y)]))
		final = max(final, ans)
	print(final)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m, k) = inputnums()
	a = inputlist()
	m -= 1
	if k > m - 1:
		k = m
	ans = 0
	for r in range(k + 1):
		l = k - r
		mn = 1000000001
		for j in range(l, m - r + 1):
			mn = min(mn, max(a[j], a[n - 1 - (m - j)]))
		ans = max(ans, mn)
	print(ans)


t = int(input())
for testo in range(t):
	(n, m, k) = list(map(int, input().split(' ')))
	array = list(map(int, input().split(' ')))
	k += 1
	k = min(k, m)
	import sys
	ans = 0
	for i in range(k):
		val = sys.maxsize
		for j in range(m - k + 1):
			val = min(val, max(array[i + j], array[-m + (i + j)]))
		ans = max(ans, val)
	print(ans)


def main():

	def solve():
		(n, m, k) = map(int, input().split())
		aa = [int(a) for a in input().split()]
		k = min(k, m - 1)
		u = m - k - 1
		best = 0
		for f in range(k + 1):
			b = n - k + f
			worst = 10000000000.0 + 1
			for j in range(0, u + 1):
				w = max(aa[f + j], aa[b - u + j - 1])
				if w < worst:
					worst = w
			if worst > best:
				best = worst
		print(best)
	q = int(input())
	for _ in range(q):
		solve()
main()


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if k >= m - 1:
		print(max(max(arr[:m]), max(arr[n - m:n])))
		continue
	remaining = m - k
	ans = []
	for l in range(k + 1):
		temp = []
		i = l
		j = n - (k - l) - 1
		for index in range(remaining):
			temp.append(max(arr[i + index], arr[j - remaining + 1 + index]))
		if temp:
			ans.append(min(temp))
	print(max(ans))


import heapq, collections
for _ in range(int(input())):
	c = collections.Counter()
	(n, m, k) = map(int, input().split())
	s = list(map(int, input().split()))
	heap = []
	if k >= m:
		k = m - 1

	def f(i):
		return max(s[i], s[i + n - m])
	for i in range(k, m):
		heap.append(f(i))
	heapq.heapify(heap)
	ans = heap[0]
	for i in range(k):
		c[f(m - 1 - i)] += 1
		heapq.heappush(heap, f(k - i - 1))
		while c[heap[0]] != 0:
			c[heap[0]] -= 1
			heapq.heappop(heap)
		ans = max(heap[0], ans)
	print(ans)


t = int(input().rstrip())
for i in range(t):
	(n, m, k) = map(int, input().rstrip().split())
	k = min(k, m - 1)
	nums = list(map(int, input().rstrip().split()))
	pk = tuple((max(nums[i], nums[i + (n - m)]) for i in range(m)))
	best = 0
	for j in range(k + 1):
		best = max(best, min(pk[j:j + m - k]))
	print(best)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	k = min(k, m - 1)
	p = m - k
	a = ans = 0
	for i in range(k + 1):
		aa = 1000000000
		for j in range(p):
			a = max(lis[i + j], lis[n - m + i + j])
			aa = min(a, aa)
		ans = max(aa, ans)
	print(ans)


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


from collections import deque
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	k = min(m - 1, k)
	a = list(map(int, input().split()))
	ans = 0
	for i in range(k + 1):
		ans1 = 10 ** 10
		for j in range(m - k):
			ans1 = min(ans1, max(a[i + j], a[i + j + n - m]))
		ans = max(ans, ans1)
	print(ans)


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)


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	Query.append((N, M, K, A))
INF = 10 ** 14
for (N, M, K, A) in Query:
	ans = 0
	M -= 1
	if K <= M:
		remain = M - K
		for left in range(K + 1):
			length = N - left - (K - left) - remain
			score = INF
			for r in range(remain + 1):
				score = min(max(A[left + r], A[left + r + length - 1]), score)
			ans = max(ans, score)
	else:
		ans = max(A[:M + 1] + A[N - M - 1:])
	print(ans)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	k = min(m - 1, k)
	a = list(map(int, input().split()))
	a2 = [a[i] if a[i] > a[j] else a[j] for (i, j) in zip(range(n), range(n - m, n))]
	(front, back) = ([(a2[0], a2[0])], [])
	for i in range(1, m - k):
		front.append((a2[i], min(a2[i], front[-1][1])))
	ans = front[-1][1]
	inf = 10 ** 9
	for i in range(m - k, m):
		front.append((a2[i], min(front[-1][1], a2[i]) if front else a2[i]))
		if not back:
			while front:
				x = front.pop()[0]
				back.append((x, min(x, back[-1][1]) if back else x))
		back.pop()
		ans = max(ans, min(front[-1][1] if front else inf, back[-1][1] if back else inf))
	print(ans)


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()))
	glob_ans = 0
	for start_eat in range(k + 1):
		(l_bound, r_bound) = (start_eat, n - k + start_eat)
		free = m - 1 - k
		ans = max(a[l_bound], a[r_bound - 1 - free])
		for i in range(free + 1):
			ans = min(ans, max(a[l_bound + i], a[r_bound - 1 - free + i]))
		glob_ans = max(glob_ans, ans)
	print(glob_ans)


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)


import sys
import math
import heapq
import bisect
import re
from collections import deque
from decimal import *
from fractions import gcd

def YES_NO(flag):
	if flag:
		print('YES')
	else:
		print('NO')

def main():
	(n, m, k) = [int(i) for i in sys.stdin.readline().split()]
	q = [int(i) for i in sys.stdin.readline().split()]
	res = 0
	if k >= m - 1:
		for i in range(m):
			res = max(res, max(q[i], q[n - m + i]))
	else:
		for i in range(k + 1):
			f = -1
			for o in range(m - k):
				ans = max(q[i + o], q[n - m + o + i])
				if f == -1 or ans < f:
					f = ans
			res = max(res, f)
	print(res)
for i in range(int(sys.stdin.readline())):
	main()


import os
import sys
from io import BytesIO, IOBase
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')
from collections import deque
for j in range(int(input())):
	(n, m, k) = map(int, input().split())
	vals = list(map(int, input().split()))
	k = min(k, m - 1)
	maxsofar = 0
	for s in range(k + 1):
		l1 = s
		r1 = k - s
		maxy = 10 ** 9 + 1
		for i in range(m - k):
			left = l1 + i
			right = r1 + m - 1 - k - i
			a = max(vals[left], vals[-1 - right])
			maxy = min(maxy, a)
		if maxy != 10 ** 9 + 1:
			maxsofar = max(maxy, maxsofar)
	print(maxsofar)


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	(n, m, k) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	s = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	if k >= m:
		k = m - 1
	sol2 = []
	for i in range(k + 1):
		l = n - k + i - 1
		f = i
		sol = []
		for j in range(m - k):
			f2 = f + j
			l2 = l - (m - k - 1 - j)
			sol.append(max([s[f2], s[l2]]))
		sol2.append(min(sol))
	print(max(sol2))


import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 4)
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m, k) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	x = n - m + 1
	dp = [[-1 for _ in range(n)] for q in range(n)]
	for i in range(n - 1, -1, -1):
		for j in range(i, n):
			if j - i + 1 == x:
				dp[i][j] = max(arr[i], arr[j])
			elif j - i + 1 > x:
				(a, b) = (max(arr[i], arr[i + x - 1]), max(arr[j - x + 1], arr[j]))
				dp[i][j] = min(a, b, dp[i + 1][j], dp[i][j - 1])
	ans = -float('inf')
	for i in range(n):
		for j in range(i, n):
			if j - i + 1 >= x and i + (n - j - 1) <= k:
				ans = max(ans, dp[i][j])
	print(ans)


from collections import deque
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	k = min(m - 1, k)
	a = list(map(int, input().split()))
	a2 = [a[i] if a[i] > a[j] else a[j] for (i, j) in zip(range(n), range(n - m, n))]
	(front, back) = (deque([(a2[0], a2[0])]), deque())
	for i in range(1, m - k):
		front.appendleft((a2[i], min(a2[i], front[0][1])))
	ans = front[0][1]
	inf = 10 ** 9
	for i in range(m - k, m):
		front.appendleft((a2[i], min(front[0][1], a2[i]) if front else a2[i]))
		if not back:
			while front:
				x = front.popleft()[0]
				back.appendleft((x, min(x, back[0][1]) if back else x))
		back.popleft()
		ans = max(ans, min(front[0][1] if front else inf, back[0][1] if back else inf))
	print(ans)


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(k + 1, m)):
		j = k - i
		tmp = 10 ** 9
		for l in range(max(1, m - k)):
			r = m - k - 1 - l
			left = i + l
			right = -j - r - 1
			tmp = min(tmp, max(a[left], a[right]))
		ans = max(ans, tmp)
	print(ans)


t = int(input())
for ti in range(t):
	(n, m, k) = input().split()
	n = int(n)
	m = int(m)
	k = int(k)
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	if m <= k + 1:
		b = a[:m] + a[-m:]
		print(str(max(b)))
	else:
		notcontrol = m - k - 1
		allans = []
		for j in range(k + 1):
			if j == k:
				newa = a[j:]
			else:
				newa = a[j:-k + j]
			rang = notcontrol + 1
			b = newa[:rang] + newa[-rang:]
			allpairs = []
			for i in range(rang):
				if b[i] > b[i + rang]:
					allpairs.append(b[i])
				else:
					allpairs.append(b[i + rang])
			ans = min(allpairs)
			allans.append(ans)
		print(str(max(allans)))


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	s = list(map(int, input().split()))
	ss = list(reversed(s))
	if m <= k:
		print(max(max(s[:m]), max(ss[:m])))
	else:
		D = {}
		for j in range(m):
			a = max(s[j], ss[m - 1 - j])
			D[j, m - 1 - j] = a
		B = 0
		for j in range(k + 1):
			A = 10000000000
			for u in range(m - k):
				a = D[j + u, m - 1 - j - u]
				if A > a:
					A = a
			if B < A:
				B = A
		print(B)


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()


from sys import stdin, stdout
import math as np
dp = list()
item = list()

def top_down(left, right):
	global dp
	global item
	level = int(np.ceil(np.log2(right - left + 1)))
	if dp[level][left] != 0:
		return dp[level][left]
	neu = int(pow(2, level - 1) * np.floor(right / pow(2, level - 1)))
	res_left = top_down(left, neu - 1)
	res_right = top_down(neu, right)
	res = min(res_left, res_right)
	if right - left + 1 - 2 == 0 and left % 2 == 0:
		dp[level][left] = res
	return res

def testing(n):
	global dp
	global item
	dp = [[0] * n for i in range(int(np.ceil(np.log2(n)) + 1))]
	dp[0] = list(item)
	top_down(0, n - 1)

def main():
	global dp
	global item
	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()))
		for i in range(m):
			item[i] = max(item[i], item[n - m + i])
		testing(m)
		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 = top_down(left, left + luck)
			if maxer == 0:
				maxer = temp_min
			else:
				maxer = max(maxer, temp_min)
		stdout.write(str(maxer) + '\n')
main()


import sys
input = sys.stdin.buffer.readline

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


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)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	al = list(map(int, input().split()))
	mind = min(m - 1, k)
	ans = 0
	for i in range(mind + 1):
		d = al[i:n - (mind - i)]
		p = m - mind - 1
		l = []
		for j in range(p + 1):
			g = d[j:len(d) - (p - j)]
			l.append(max(g[0], g[-1]))
		ans = max(min(l), ans)
	print(ans)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k = min(k, m - 1)
	best = 0
	before = m - 1
	behind = n - m
	for x in range(k + 1):
		sans = float('inf')
		for y in range(m - k):
			cans = max(a[x + y], a[n - (m - x - y)])
			sans = min(sans, cans)
		best = max(best, sans)
	print(best)


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))


def resolve():
	(n, pos, control) = map(int, input().split())
	before = pos - 1
	behind = n - pos
	control = min(before, control)
	uncontrol = pos - 1 - control
	line = list(map(int, input().split()))
	best = 0
	for my_first in range(control + 1):
		strategy = float('inf')
		for op_first in range(uncontrol + 1):
			case_ans = max(line[my_first + op_first], line[my_first + op_first + behind])
			strategy = min(strategy, case_ans)
		best = max(best, strategy)
	print(best)
n = int(input())
while n:
	n -= 1
	resolve()


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()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7

def mn(p):
	return max(p[0], p[-1])
h = I()
for _ in range(h):
	(n, m, k) = R()
	a = L()
	if k + 1 >= m:
		print(max(max(a[:m]), max(a[::-1][:m])))
		continue
	val = []
	for i in range(m):
		val += (max(a[i], a[n - m + i]),)
	res = m - (k + 1)
	ans = 0
	for i in range(k + 1):
		mn = N
		for j in range(res + 1):
			mn = min(val[i + j], mn)
		ans = max(mn, ans)
	print(ans)


import sys
input = sys.stdin.readline
nn = int(input())
for i in range(nn):
	(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[n - m + i]))
	ans = -float('inf')
	for i in range(k + 1):
		ans = max(ans, min(B[i:len(B) - k + i]))
	print(ans)


def solve():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k = min(m - 1, k)
	ans = 0
	for i in range(k + 1):
		pos1 = i
		pos2 = n - 1 - (k - i)
		cur_ans = int(1000000000.0 * 2)
		for j in range(m - k):
			cur_ans = min(cur_ans, max(a[pos1 + j], a[pos2 - (m - 1 - k - j)]))
		ans = max(ans, cur_ans)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


def find_optimum(length, pos, fix, arr):
	if pos < length // 2:
		arr = arr[:pos] + arr[length - pos:]
		length = len(arr)
	if fix > pos - 1:
		fix = pos - 1
	picks = []
	for i in range(pos):
		picks += [max(arr[i], arr[i + length - pos])]
	pick_range = pos - fix
	optimal = 0
	for i in range(fix + 1):
		m = min(picks[i:i + pick_range])
		if m > optimal:
			optimal = m
	return optimal
t = int(input())
for i in range(t):
	(n, m, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	print(find_optimum(n, m, k, a))


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)


import sys
t = int(sys.stdin.readline())
ans_arr = []
for x in range(t):
	[n, m, k] = [int(j) for j in sys.stdin.readline().split()]
	a = [int(g) for g in sys.stdin.readline().split()]
	if m - 1 > k:
		ans = -2
		for i in range(k + 1):
			tmp = pow(10, 9) + 10
			for j in range(m - k):
				val = max(a[i + j], a[i + j + n - m])
				tmp = min(tmp, val)
			ans = max(ans, tmp)
		ans_arr.append(str(ans))
	else:
		ans = 0
		for g in range(m):
			ans = max(ans, a[g])
		for h in range(n - 1, n - 1 - m, -1):
			ans = max(ans, a[h])
		ans_arr.append(str(ans))
print('\n'.join(ans_arr))


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 collections import deque
T = int(input())
for _ in range(T):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	arr = []
	for (a, b) in zip(A, A[N - M:]):
		arr.append(max(a, b))
	w = len(arr) - K
	if w <= 1:
		print(max(arr))
		continue
	qmin = deque()
	ans = 0
	for (i, a) in enumerate(arr):
		while qmin and qmin[-1] > a:
			qmin.pop()
		qmin.append(a)
		if i - w >= 0 and arr[i - w] == qmin[0]:
			qmin.popleft()
		if i >= w - 1:
			ans = max(ans, qmin[0])
	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)


import collections
import functools
import math
import random
import sys
import bisect
import io, os
input = sys.stdin.readline

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

def mindcon():
	for _ in range(int(input())):
		(n, m, k) = In()
		l = list(In())
		if m == 1:
			ans = max(l[0], l[-1])
		else:
			ans = 0
			left = max(m - k - 1, 0)
			lim = min(k + 1, m)
			for c in range(lim):
				new = math.inf
				for i in range(c, c + left + 1):
					new = min(new, max(l[i], l[n + i - lim - left]))
				ans = max(new, ans)
		print(ans)
mindcon()


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().split()))
	k = min(k, m - 1)
	ANS = -1
	LEN = n - k
	for start in range(k + 1):
		ANSSTART = 1 << 31
		last = start + LEN
		s = start
		l = last - (m - k)
		while l < last:
			ANSSTART = min(ANSSTART, max(A[s], A[l]))
			s += 1
			l += 1
		ANS = max(ANS, ANSSTART)
	print(ANS)


def solve(n, m, k, a):
	prior_selections = m - 1
	forced = min(k, prior_selections)
	free_choice = prior_selections - forced
	best_selection = [0] * (prior_selections + 1)
	for selected_first in range(prior_selections + 1):
		first_element = a[selected_first]
		selected_last = m - 1 - selected_first
		last_element = a[-(selected_last + 1)]
		selection = max(first_element, last_element)
		best_selection[selected_first] = selection
	best_of_worst = None
	for forced_first in range(forced + 1):
		worst_selection = None
		for picked_first in range(free_choice + 1):
			selected_first = forced_first + picked_first
			selection = best_selection[selected_first]
			if worst_selection is None or selection < worst_selection:
				worst_selection = selection
		if best_of_worst is None or worst_selection > best_of_worst:
			best_of_worst = worst_selection
	return best_of_worst
for T in range(int(input())):
	(n, m, k) = map(int, input().split())
	print(solve(n, m, k, list(map(int, input().split()))))


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


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 loop in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	if k < m - 1:
		for w in range(k + 1):
			x = k - w
			nmin = float('inf')
			for y in range(m - k):
				z = m - k - 1 - y
				nmin = min(nmin, max(a[w + y], a[n - 1 - x - z]))
			ans = max(nmin, ans)
		print(ans)
	else:
		ans = 0
		for i in range(m):
			ans = max(ans, a[i], a[n - 1 - i])
		print(ans)


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
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')

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		(n, m, k) = RL()
		arr = list(RL())
		ret = float('-inf')
		for i in range(min(k + 1, m)):
			e = n - (min(k, m - 1) - i) - 1
			pt = max(m - k - 1, 0)
			res = float('inf')
			for j in range(pt + 1):
				nb = i + j
				ne = e - (pt - j)
				res = min(res, max(arr[nb], arr[ne]))
			ret = max(res, ret)
		print(ret)
main()


t = int(input())

def solve(n, m, k, a):
	pairs = {}
	for j in range(m + 1):
		pairs[j] = max(a[j], a[n - 1 - (m - j)])
	ans = 0
	for f in range(k + 1):
		l = k - f
		alpha = f
		beta = m - l
		delans = 10000000000
		for j in range(alpha, beta + 1):
			delans = min(delans, pairs[j])
		ans = max(ans, delans)
	return ans
for _ in range(t):
	(n, m, k) = map(int, input().split())
	m -= 1
	k = min(m, k)
	a = list(map(int, input().split()))
	print(solve(n, m, k, a))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = ri()
	for _ in range(tc):
		(n, m, k) = ria()
		a = deque(ria())
		k = min(k, m - 1)
		ans = 0
		for i in range(k + 1):
			ca = 99999999999999999999999999999
			for j in range(m - k):
				ca = min(ca, max(a[i + j], a[i + j + n - m]))
			ans = max(ca, ans)
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


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)