After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you).

You are given an array $h_1, h_2, \dots, h_n$, where $h_i$ is the height of the $i$-th mountain, and $k$ — the number of boulders you have.

You will start throwing boulders from the top of the first mountain one by one and they will roll as follows (let's assume that the height of the current mountain is $h_i$):

if $h_i \ge h_{i + 1}$, the boulder will roll to the next mountain;

if $h_i < h_{i + 1}$, the boulder will stop rolling and increase the mountain height by $1$ ($h_i = h_i + 1$);

if the boulder reaches the last mountain it will fall to the waste collection system and disappear.

You want to find the position of the $k$-th boulder or determine that it will fall into the waste collection system.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases.

Each test case consists of two lines. The first line in each test case contains two integers $n$ and $k$ ($1 \le n \le 100$; $1 \le k \le 10^9$) — the number of mountains and the number of boulders.

The second line contains $n$ integers $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 100$) — the height of the mountains.

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


-----Output-----

For each test case, print $-1$ if the $k$-th boulder will fall into the collection system. Otherwise, print the position of the $k$-th boulder.


-----Examples-----

Input
4
4 3
4 1 2 3
2 7
1 8
4 5
4 1 2 3
3 1
5 3 1
Output
2
1
-1
-1


-----Note-----

Let's simulate the first case:

The first boulder starts at $i = 1$; since $h_1 \ge h_2$ it rolls to $i = 2$ and stops there because $h_2 < h_3$.

The new heights are $[4,2,2,3]$.

The second boulder starts at $i = 1$; since $h_1 \ge h_2$ the boulder rolls to $i = 2$; since $h_2 \ge h_3$ the boulder rolls to $i = 3$ and stops there because $h_3 < h_4$.

The new heights are $[4,2,3,3]$.

The third boulder starts at $i = 1$; since $h_1 \ge h_2$ it rolls to $i = 2$ and stops there because $h_2 < h_3$.

The new heights are $[4,3,3,3]$.

The positions where each boulder stopped are the following: $[2,3,2]$.

In the second case, all $7$ boulders will stop right at the first mountain rising its height from $1$ to $8$.

The third case is similar to the first one but now you'll throw $5$ boulders. The first three will roll in the same way as in the first test case. After that, mountain heights will be equal to $[4, 3, 3, 3]$, that's why the other two boulders will fall into the collection system.

In the fourth case, the first and only boulders will fall straight into the collection system.

Source: codeforces | Difficulty: EASY
Tags: Complete search

Implementation

Greedy algorithms


Solutions:
for tc in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	if k > 10000:
		print(-1)
		continue
	k -= 1

	def fun():
		global k
		(cha, diao) = (0, 0)
		for i in range(n - 1):
			if h[i] < h[i + 1]:
				k -= 1
				h[i] += 1
				return i + 1
		k -= 1
		return -1
	while 1:
		if k == 0:
			break
		fun()
	print(fun())


def NewColony(n, kk, a):
	i = 0
	for k in range(kk):
		i = 0
		while i < n - 1:
			if a[i] < a[i + 1]:
				a[i] += 1
				break
			i += 1
		if i == n - 1:
			return -1
	return i + 1
t = int(input())
for tt in range(t):
	(n, k) = map(int, input().rstrip().split())
	a = list(map(int, input().rstrip().split()))
	ans = NewColony(n, k, a)
	print(ans)


x = int(input())
for i in range(x):
	f = [int(f) for f in input().split()]
	d = [int(d) for d in input().split()]
	s = []
	for i in range(f[1]):
		cnt = 0
		if f[0] == 1:
			s.append(-1)
		else:
			for j in range(len(d) - 1):
				cnt += 1
				if d[j] < d[j + 1]:
					d[j] += 1
					s.append(cnt)
					break
				if cnt == len(d) - 1:
					s.append(-1)
			if s[-1] == -1:
				break
	print(s[-1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	flag = True
	curr_index = -1
	while k > 0 and flag:
		c = 0
		for i in range(1, n):
			if arr[i] > arr[i - 1]:
				k -= 1
				arr[i - 1] += 1
				curr_index = i
				c += 1
				break
		if c == 0:
			flag = False
	if flag and k <= 0:
		print(curr_index)
	else:
		print(-1)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	h = input().split()
	for i in range(len(h)):
		h[i] = int(h[i])
	final = 0

	def roll(h):
		for i in range(k):
			for j in range(n):
				if j == n - 1:
					return -1
				if h[j] < h[j + 1]:
					h[j] += 1
					break
			final = j
		return final + 1
	print(roll(h))


def process(h):
	for i in range(1, len(h)):
		if h[i] > h[i - 1]:
			h[i - 1] += 1
			return i - 1
	return -1
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	h = list(map(int, input().split()))
	for j in range(k):
		res = process(h)
		if res == -1:
			print(-1)
			break
	else:
		print(res + 1)


def read():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = read()
	a = read()
	if n * max(a) < k:
		print(-1)
		continue
	res = n + 1
	for _ in range(k):
		pos = -2
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				pos = i
				break
		res = pos + 1
		if res == -1:
			break
		a[pos] += 1
	print(res)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ind = 0
	ok = 1
	while k and ok:
		i = 0
		while i < n - 1:
			if h[i] < h[i + 1]:
				h[i] += 1
				ind = i
				break
			i += 1
		if i >= n - 1:
			ok = 0
		k -= 1
	if ok:
		print(ind + 1)
	else:
		print(-1)


import math
import bisect
import copy
from collections import defaultdict
from collections import OrderedDict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	for i in range(k):
		j = 0
		while j < n - 1:
			if ar[j] < ar[j + 1]:
				ar[j] += 1
				break
			j += 1
		if j == n - 1:
			break
	if j == n - 1:
		print(-1)
	else:
		print(j + 1)


t = int(input())
for i in range(t):
	(n, k) = (int(_) for _ in input().split(' '))
	mt = []
	mt.extend((int(x) for x in input().split(' ')))
	flag = 0
	for j in range(k):
		if n == 1:
			flag = -1
			break
		if flag == -1:
			break
		for p in range(n - 1):
			if mt[p] < mt[p + 1]:
				mt[p] += 1
				if j == k - 1:
					flag = p + 1
				break
			elif p == n - 2:
				flag = -1
				break
	print(flag)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	h = list(map(int, input().split()))
	c = 1
	h.append(101)
	while True:
		for i in range(x):
			if h[i + 1] > h[i]:
				h[i] += 1
				break
		if i + 1 == x:
			print(-1)
			break
		if c == y:
			print(i + 1)
			break
		c += 1


def mozeli(plan, k):
	i = 0
	t = 0
	while k > 0 and t < len(plan) - 1:
		if plan[t] < plan[t + 1]:
			plan[t] = plan[t] + 1
			k -= 1
			i = t
			if t > 0:
				t -= 1
		else:
			t += 1
	if t == len(plan) - 1:
		return '-1'
	else:
		return i + 1
n = int(input())
while n > 0:
	lista = input().split(' ')
	k = int(lista[1])
	plan = input().split(' ')
	plan = [int(i) for i in plan]
	print(mozeli(plan, k))
	n -= 1


n = int(input())
inlist = []
numlist = []
for i in range(n):
	inlist.append([int(num) for num in input().split()])
	numlist.append([int(num) for num in input().split()])
for i in range(n):
	k = inlist[i][1]
	m = inlist[i][0]
	mlist = numlist[i]
	miner = [-1]
	for j in range(1, m):
		miner.append(mlist[j] - mlist[j - 1])
	time = 0
	while time <= m:
		if miner[time] > 0:
			miner[time] -= 1
			miner[time - 1] += 1
			k -= 1
			if k == 0:
				print(time)
				break
			time = 0
		time += 1
		if time == m:
			print(-1)
			break


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	t = 0
	i = 1
	mv = a[-1]
	while i <= n:
		mv = max(mv, a[-i])
		if a[-i] < mv:
			t += abs(a[-i] - mv)
		i += 1
	if k > t:
		print(-1)
	else:
		ck = -1
		while k != 0:
			i = 0
			while i < n - 1:
				if a[i + 1] > a[i]:
					a[i] += 1
					ck = i
					k -= 1
					break
				i += 1
		print(ck + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	lst = -1
	while k > 0:
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				a[i] += 1
				k -= 1
				lst = i + 1
				break
		else:
			break
	print(-1 if k > 0 else lst)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	flag = True
	while k:
		for i in range(1, n):
			if arr[i - 1] < arr[i]:
				arr[i - 1] += 1
				break
		else:
			flag = False
			print(-1)
			break
		k -= 1
	if flag:
		print(i)


t = int(input())
for _ in range(t):
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	h_vec = input().split(' ')
	h_vec = [int(h) for h in h_vec]
	boulders = None
	k_index = 0
	for b in range(k):
		stopped = False
		for j in range(n - 1):
			if h_vec[j] >= h_vec[j + 1]:
				continue
			else:
				h_vec[j] += 1
				boulders = j
				stopped = True
				break
		if stopped == False:
			boulders = -1
			break
	if boulders == -1:
		print(boulders)
	else:
		print(boulders + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	a = []
	for i in range(n):
		a.append(max(h[i:]))
	count = 0
	for i in range(n):
		count += a[i] - h[i]
	if k > count:
		print(-1)
		continue
	for i in range(k):
		for j in range(1, n):
			if h[j] > h[j - 1]:
				h[j - 1] += 1
				break
	print(j)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	h = list(map(int, input().split()))
	a = [max(h[i:]) - h[i] for i in range(N)]
	if K > sum(a):
		print(-1)
		continue
	(i, j) = (0, 0)
	while K:
		w = 1
		i = 0
		while i < N and h[i] >= h[i + 1]:
			i += 1
		h[i] += 1
		K -= 1
		j = i
	print(j + 1)


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, k) = R()
	a = [*R(), 101]
	i = 1
	while i % n * k:
		i = 1
		while a[i - 1] >= a[i]:
			i += 1
		a[i - 1] += 1
		k -= 1
	print(i % n or -1)


for _ in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	h = [int(x) for x in input().split()]
	if n == 1:
		print('-1')
	else:
		cou = 0
		val = h[n - 1]
		for i in range(n - 1, 0, -1):
			if h[i - 1] < val:
				cou += val - h[i - 1]
			elif h[i - 1] > val:
				val = h[i - 1]
		if k > cou:
			print('-1')
		else:
			perfe = -1
			ji = 0
			while ji != n - 1 and k > 0:
				if h[ji] >= h[ji + 1]:
					ji += 1
					continue
				elif ji == 0:
					k -= h[ji + 1] - h[ji]
					h[ji] = h[ji + 1]
					ji = 1
					perfe = 0
					continue
				elif h[ji + 1] <= h[ji - 1]:
					perfe = ji
					k -= h[ji + 1] - h[ji]
					h[ji] = h[ji + 1]
					ji += 1
					continue
				else:
					perfe = ji
					k -= h[ji - 1] + 1 - h[ji]
					h[ji] = h[ji - 1] + 1
					ji -= 1
					continue
			print(perfe + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = -2
	while k > 0:
		f = 0
		for i in range(n - 1):
			if l[i] < l[i + 1]:
				l[i] += 1
				f = 1
				k -= 1
				ans = i
				break
		if f == 0:
			break
	if k != 0:
		print(-1)
	else:
		print(ans + 1)


import sys
from collections import deque

class Group(object):

	def __init__(self, ids, height):
		self.ids = ids
		self.height = height

	def __repr__(self):
		return '[h={} ids={}]'.format(self.height, self.ids)
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	H = deque(enumerate(map(int, sys.stdin.readline().split())))
	groups = list()
	groups.append(Group([1], H.popleft()[1]))
	while True:
		if not len(H):
			print('-1')
			break
		(mountain_id, forward_height) = H[0]
		mountain_id += 1
		if forward_height == groups[-1].height:
			groups[-1].ids.append(mountain_id)
			H.popleft()
		elif forward_height < groups[-1].height:
			groups.append(Group([mountain_id], forward_height))
			H.popleft()
		else:
			group_size = len(groups[-1].ids)
			if len(groups) > 1:
				next_height = min(groups[-2].height, forward_height)
			else:
				next_height = forward_height
			cost = group_size * (next_height - groups[-1].height)
			if k > cost:
				k -= cost
			else:
				num_in_group = len(groups[-1].ids)
				print(groups[-1].ids[-(k % num_in_group)])
				break
			groups[-1].height = next_height
			if forward_height == groups[-1].height:
				H.popleft()
				groups[-1].ids.append(mountain_id)
			if len(groups) > 1:
				if groups[-1].height == groups[-2].height:
					groups[-2].ids.extend(groups[-1].ids)
					del groups[-1]


t = int(input())
for i in range(t):
	l = list(map(int, input().rstrip().split()))
	n = l[0]
	k = l[1]
	count = 0
	h = list(map(int, input().rstrip().split()))
	for b in range(k):
		for a in range(1, n):
			if h[a - 1] < h[a]:
				h[a - 1] += 1
				count += 1
				ans = a
				break
		if count < b + 1:
			break
	if count != k:
		print(-1)
	else:
		print(ans)


for _ in range(int(input())):
	(__, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	r = -1
	br = False
	for i in range(k):
		for j in range(1, len(a)):
			if a[j] > a[j - 1]:
				r = j - 1
				a[j - 1] += 1
				break
			elif j == len(a) - 1:
				r = -1
				br = True
				break
		if br:
			break
	if r == -1:
		print(-1)
	else:
		print(r + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	flag = True
	count = 0
	pos = 0
	ans = 0
	while flag:
		if pos == n - 1 and count < k:
			break
		else:
			if l[pos] < l[pos + 1]:
				l[pos] += 1
				count += 1
				ans = pos + 1
			if pos > 0:
				if l[pos - 1] < l[pos]:
					pos -= 1
			if l[pos] >= l[pos + 1]:
				pos += 1
			if count == k:
				break
	if pos == n - 1 and count < k:
		print(-1)
	elif count == k:
		print(ans)


def ceil(a, b):
	if a % b == 0:
		return a // b
	return a // b + 1

def find(arr, key):
	for i in range(len(arr)):
		if arr[i] == key:
			return i
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 1
	while k > 0 and ans != -1:
		i = 0
		while i < n:
			if i == n - 1:
				ans = -1
			elif arr[i] < arr[i + 1]:
				arr[i] += 1
				ans = i + 1
				break
			i += 1
		k -= 1
	print(ans)


import math
import sys
for m in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = 0
	cnt = 0
	while i < n - 1:
		if arr[i + 1] > arr[i]:
			arr[i] += 1
			cnt += 1
			if cnt == k:
				print(i + 1)
				break
			i = 0
		else:
			i += 1
	if cnt != k:
		print(-1)


try:
	t = int(input())
	for _ in range(t):
		(n, k) = [int(x) for x in input().split()]
		h = [int(x) for x in input().split()]
		z = 0
		if n == 1:
			print(-1)
		else:
			for x in range(k):
				if z == 1:
					break
				i = 0
				while i < n - 1:
					if h[i] >= h[i + 1]:
						i += 1
						if i == n - 1:
							z = 1
							break
					else:
						h[i] += 1
						y = i
						break
			if z == 0:
				print(y + 1)
			else:
				print(-1)
except:
	pass


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(I()):
	(n, k) = tup()
	ls = lint()
	p = None
	while k:
		i = 0
		while i < n - 1 and ls[i] >= ls[i + 1]:
			i += 1
		if i < n - 1:
			ls[i] += 1
			k -= 1
			p = i + 1
		else:
			break
	if k == 0:
		print(p)
	else:
		print(-1)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


def newColony(n, k, array):
	while k > 0:
		x = 0
		while x < n - 1 and array[x] >= array[x + 1]:
			x += 1
		if x == n - 1:
			return -1
		if x > 0:
			p = min(array[x - 1] + 1, array[x + 1])
		else:
			p = array[x + 1]
		if k <= p - array[x]:
			return x + 1
		else:
			k -= p - array[x]
			array[x] = p
	return -1
t = int(input())
final = []
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	final.append(newColony(n, k, l))
for _ in range(t):
	print(final[_])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	h = list(map(int, input().split()))
	pk = 1
	for i in range(0, n - 1):
		(el1, el2) = (h[i], h[i + 1])
		if el2 > el1:
			for _ in range(el2 - el1):
				if pk <= k:
					a.append(i + 1)
					h[i] += 1
					pk += 1
				else:
					break
				for z in range(i - 1, -1, -1):
					if h[z + 1] > h[z]:
						if pk <= k:
							a.append(z + 1)
							h[z] += 1
							pk += 1
						else:
							break
	if pk > k:
		ans = a[-1]
	else:
		ans = -1
	print(ans)


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = -1
	for c in range(k):
		i = 0
		while i < n - 1 and h[i] >= h[i + 1]:
			i = i + 1
		if i == n - 1:
			break
		elif c == k - 1:
			ans = i + 1
		h[i] = h[i] + 1
	print(ans)


I = input
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	stack = [(-1, float('inf'))]
	res = None
	for (i, c) in zip(range(n), map(int, I().split())):
		while c > stack[-1][1]:
			if res:
				break
			(j, d) = stack.pop()
			w = i - stack[-1][0] - 1
			h = min(c, stack[-1][1]) - d
			remain = w * h
			k -= remain
			if k <= 0:
				res = stack[-1][0] + -k % w + 2
		if res:
			print(res)
			break
		stack.append((i, c))
	if k > 0:
		print(-1)


t = int(input())
out = ''
while t > 0:
	(n, k) = map(int, input().split(' '))
	h = list(map(int, input().split(' ')))
	if k > n * max(h):
		out += '-1\n'
		t -= 1
		continue
	for i in range(0, k):
		count = 1
		for j in range(0, len(h)):
			if j + 1 < n and h[j] >= h[j + 1]:
				count += 1
				continue
			elif j + 1 < n and h[j] < h[j + 1]:
				h[j] = h[j] + 1
				break
		if count == n and i == k - 1:
			out += '-1\n'
		elif i == k - 1:
			out += str(count) + '\n'
	t -= 1
print(out)


for _ in range(int(input())):
	(h, k) = map(int, input().split())
	a = list(map(int, input().split()))
	kk = 0
	hell = 0
	if h == 1:
		print(-1)
		continue
	for i in range(k):
		for j in range(h):
			if a[j] < a[j + 1]:
				a[j] += 1
				kk = j + 1
				break
			elif j == h - 2:
				hell = 1
				break
		if hell == 1:
			break
	print(kk if hell == 0 else -1)


import collections
import string
import math
import copy
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mo = 998244353

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return --1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res

def dis(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def getpref(x):
	if x > 1:
		return x * (x - 1) >> 1
	else:
		return 0

def orafli(upp):
	primes = []
	marked = [False for i in range(upp + 3)]
	for i in range(2, upp):
		if not marked[i]:
			primes.append(i)
		for j in primes:
			if i * j >= upp:
				break
			marked[i * j] = True
			if i % j == 0:
				break
	return primes
t = int(input())
for ti in range(t):
	(n, k) = map(int, input().split())
	li = [int(i) for i in input().split()]
	ans = 0
	for i in range(k):
		for j in range(n):
			if j == n - 1:
				ans = -1
				break
			elif li[j + 1] > li[j]:
				li[j] += 1
				ans = j + 1
				break
		if ans == -1:
			break
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	ct = 0
	ans = -1
	mx = ar[n - 1]
	c = 0
	for i in range(n - 2, -1, -1):
		if ar[i] < mx:
			c += mx - ar[i]
		else:
			mx = ar[i]
	if k > c:
		print(-1)
	else:
		while ct < k:
			for i in range(n - 1):
				if ar[i + 1] > ar[i]:
					ar[i] += 1
					ct += 1
					ans = i + 1
					break
		print(ans)


ttt = int(input())
for i in range(0, ttt):
	(nn, kk) = map(int, input().split())
	hh = [int(ii) for ii in input().split()]
	flag = True
	for q in range(0, kk):
		position = 1
		for j in range(0, nn - 1):
			if hh[j] >= hh[j + 1]:
				position += 1
			else:
				hh[j] += 1
				break
		if position >= nn:
			print(-1)
			flag = False
			break
	if flag:
		print(position)


def boulder(n, k, h):
	if n == 1:
		return -1
	a = 0
	for _ in range(k):
		for i in range(n - 1):
			if h[i] >= h[i + 1]:
				a = i + 2
			else:
				h[i] += 1
				a = i + 1
				break
			if a == n:
				return -1
	return a
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	print(boulder(n, k, h))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	if arr == sorted(arr, reverse=True):
		print(-1)
	else:
		ans = 0
		while k > 0:
			for i in range(n - 1):
				if arr[i] < arr[i + 1]:
					k -= 1
					arr[i] += 1
					ans = i + 1
					break
			if arr == sorted(arr, reverse=True) and k > 0:
				ans = -1
				break
		print(ans)


for _ in range(int(input())):
	(n, k) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	if n == 1:
		print(-1)
		continue
	flag = False
	for i in range(k):
		if flag:
			break
		for j in range(n - 1):
			if arr[j] < arr[j + 1]:
				arr[j] += 1
				break
			elif j == n - 2:
				flag = True
				break
	if flag:
		print(-1)
		continue
	else:
		print(j + 1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	pos = 0
	for i in range(1, a):
		while l[i] > l[i - 1]:
			for j in range(i - 1, -1, -1):
				l[j] += 1
				pos += 1
				if pos >= b:
					print(j + 1)
					pos = -1
					break
				if j != 0 and l[j] <= l[j - 1]:
					break
			if pos == -1:
				break
		if pos == -1:
			break
	if pos == -1:
		continue
	print(-1)


for i in range(int(input())):
	(x, n) = map(int, input().split())
	y = list(map(int, input().split()))
	i = 0
	while i < x - 1:
		if y[i] >= y[i + 1]:
			i += 1
		else:
			y[i] += 1
			n -= 1
			if n == 0:
				break
			i = 0
	if i + 1 < x:
		print(i + 1)
	else:
		print('-1')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	now = 0
	cnn = 0
	while now <= n - 1:
		if now == n - 1:
			if k >= cnn:
				print(-1)
			break
		elif h[now] >= h[now + 1]:
			now += 1
		elif h[now] < h[now + 1]:
			h[now] += 1
			cnn += 1
			if cnn == k:
				print(now + 1)
				break
			now = 0


try:
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		l = list(map(int, input().split()))
		c = 0
		for i in range(b):
			if l == sorted(l, reverse=True):
				print(-1)
				break
			else:
				for i in range(len(l) - 1):
					if l[i] >= l[i + 1]:
						continue
					else:
						l[i] += 1
						c = i
						break
			b -= 1
		if l == sorted(l, reverse=True) and b > 0:
			pass
		else:
			print(c + 1)
except:
	pass


def h(k):
	ret = -2
	while k > 0:
		ret = -2
		for i in range(len(arr) - 1):
			if arr[i] < arr[i + 1]:
				k -= 1
				arr[i] += 1
				ret = i
				break
		if ret == -2:
			break
	return ret + 1
for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(h(k))


def Solve():
	for t in range(int(input())):
		(n, k) = map(int, input().split())
		h = list(map(int, input().split()))
		e = True
		for i in range(k):
			for o in range(n - 1):
				if h[o] < h[o + 1]:
					h[o] += 1
					break
			else:
				print(-1)
				e = False
				break
		if e:
			print(o + 1)
Solve()


n = int(input())
for _ in range(n):
	(n, k) = [int(i) for i in input().split()]
	h = [int(i) for i in input().split()] + [-1]
	c = 0
	for i in range(k):
		h[0] += 1
		for g in range(n):
			if h[g] > h[g + 1]:
				h[g] -= 1
				h[g + 1] += 1
			else:
				c = g + 1
				break
		else:
			c = -1
			break
	print(c)


T = int(input())
r = 1
while r <= T:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	stack = [float('+inf')]
	flag = False
	for i in range(n):
		if arr[i] > stack[-1]:
			temp = []
			while arr[i] > stack[-1]:
				temp.append(stack.pop())
			temp = temp[::-1]
			needed = arr[i] * len(temp) - sum(temp)
			if needed < k:
				k -= arr[i] * len(temp) - sum(temp)
				stack += [arr[i]] * len(temp)
			else:
				flag = True
				temp = [arr[i]] + temp
				end = len(temp)
				front = end - 1
				while k > 0:
					diff = temp[front - 1] - temp[front]
					if diff * (end - front) >= k:
						ans = i - 1 - (k - 1) % (end - front)
						k = 0
					else:
						k -= diff * (end - front)
						front -= 1
		stack.append(arr[i])
	if not flag:
		print('-1')
	else:
		print(ans + 1)
	r += 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	heights = list(map(int, input().split()))
	rocks = 0
	i = 0
	while rocks <= k - 1:
		if i == n - 1:
			print('-1')
			break
		elif heights[i] < heights[i + 1]:
			heights[i] += 1
			rocks += 1
			if rocks == k:
				print(i + 1)
				break
			else:
				i = 0
		else:
			i += 1


import math
import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	(f, j, c) = (1, 0, 0)
	if n == 1:
		print(-1)
	else:
		while f != -1 and f != 0:
			if c == k:
				print(ans + 1)
				f = 0
				break
			elif a[j + 1] > a[j]:
				a[j] += 1
				ans = j
				j = 0
				c += 1
			elif j == n - 2:
				f = -1
			else:
				j += 1
		if f == -1:
			print('-1')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(-1)
	else:
		c = 0
		test = 0
		while c < k:
			i = 1
			while i < n:
				if a[i] <= a[i - 1]:
					i += 1
				else:
					a[i - 1] += 1
					c += 1
					break
			if i == n:
				test = 1
				break
		if test:
			print(-1)
		else:
			print(i)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 1
	a = 1
	b = n - 1
	while len(l) >= 2 and l[-1] <= l[-2]:
		l.pop()
		b -= 1
	if len(l) < 2:
		print(-1)
		continue
	a = 0
	ans = -1
	for i in range(1, k + 1):
		x = 1
		for j in range(a, b):
			if l[j + 1] > l[j]:
				l[j] += 1
				ans = j + 1
				x = 0
				break
		if x:
			ans = -1
			break
		while len(l) >= 2 and l[-1] <= l[-2]:
			l.pop()
			b -= 1
	print(ans)


t = int(input())
for i in range(t):
	n = tuple(map(int, input().split(' ')))
	x = list(map(int, input().split(' ')))
	flag = 0
	for i in range(n[1]):
		k = 0
		cnt = 1
		for i in range(n[0] - 1):
			if x[i] < x[i + 1]:
				x[i] += 1
				k = cnt
				break
			else:
				cnt += 1
		if cnt == n[0]:
			print(-1)
			flag = 1
			break
	if flag == 0:
		print(k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	mountain = 0
	boulders = 1
	b = []
	while mountain < n - 1 and boulders <= k:
		if h[mountain] >= h[mountain + 1]:
			mountain += 1
		else:
			h[mountain] += 1
			b.append(mountain + 1)
			mountain = 0
			boulders += 1
	if len(b) < k:
		print(-1)
	else:
		print(b[k - 1])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ma = max(arr)
	if k > ma * n:
		print(-1)
	else:
		ar = arr.copy()
		ar.append(-100000)
		arr.append(-100000)
		ar.append(100000)
		arr.append(100000)
		ind = n
		for i in range(k):
			j = 0
			while j < n:
				if ar[j] >= ar[j + 1]:
					j = j + 1
				else:
					break
			ar[j] = ar[j] + 1
			ind = j
		if ind >= n - 1:
			print(-1)
		else:
			print(ind + 1)


def rightMinimum(arr):
	n = len(arr)
	for i in range(n - 1):
		if arr[i] < arr[i + 1]:
			return i
	return -1

def solve(arr, k):
	for i in range(k):
		index = rightMinimum(arr)
		if index == -1:
			return -1
		arr[index] += 1
	return index + 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	print(solve(h, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	b = 1
	while b <= k:
		stop = -1
		for i in range(n - 1):
			if h[i + 1] > h[i]:
				stop = i + 1
				h[i] += 1
				break
		if stop == -1:
			break
		b += 1
	print(stop)


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	c = 0
	temp = c
	while k >= 1:
		temp = c
		if c >= n - 1:
			break
		if h[c] >= h[c + 1]:
			c += 1
		elif c == 0:
			k -= h[c + 1] - h[c]
			h[c] = h[c + 1]
			c += 1
		elif h[c] == h[c - 1]:
			k -= 1
			h[c] += 1
			c -= 1
		elif h[c - 1] >= h[c + 1]:
			k -= h[c + 1] - h[c]
			h[c] = h[c + 1]
			c += 1
		else:
			k -= 1 + h[c - 1] - h[c]
			h[c] = h[c - 1] + 1
			c -= 1
	if temp >= n - 1:
		print(-1)
	else:
		print(temp + 1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	for i in range(k):
		flag = False
		for j in range(len(s) - 1):
			if s[j] < s[j + 1]:
				s[j] += 1
				break
		else:
			flag = True
		if flag:
			break
	if flag:
		print(-1)
	else:
		print(j + 1)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.append(0)
	flag = 0
	for _ in range(k):
		c = 0
		for i in range(len(a) - 1):
			if a[i] < a[i + 1]:
				break
			else:
				c += 1
		if c == len(a) - 1:
			flag == 1
			break
		else:
			a[i] += 1
	if i + 1 == len(a) - 1:
		print('-1')
	else:
		print(i + 1)


import sys
input = sys.stdin.readline
from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	fall = defaultdict(lambda : -1)
	cnt = 0
	flag = True
	while flag:
		for i in range(n):
			if i == n - 1:
				flag = False
				break
			if h[i] < h[i + 1]:
				cnt += 1
				h[i] += 1
				fall[cnt] = i + 1
				break
	print(fall[k])


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	l = list(map(int, input().split(' ')))
	maxi = 100
	total = 0
	for j in l:
		if maxi - j > 0:
			total = total + maxi - j
	if total < n:
		print(-1)
		continue
	ans = -1
	for i in range(0, n):
		ans = -1
		j = 0
		while j < m - 1 and l[j] >= l[j + 1]:
			j += 1
		if j < m - 1:
			l[j] += 1
			ans = j + 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	isDecreased = True
	for i in range(1, n):
		if l[i] > l[i - 1]:
			isDecreased = False
			break
	if isDecreased:
		print(-1)
	else:
		start = 1
		while start <= k:
			for i in range(1, n):
				if l[i - 1] >= l[i]:
					if start == k and i == n - 1:
						print(-1)
						break
					continue
				else:
					if start == k:
						print(i)
						break
					l[i - 1] += 1
					break
			isDecreased = True
			for j in range(1, n):
				if l[j] > l[j - 1]:
					isDecreased = False
					break
			if isDecreased:
				print(-1)
				break
			start += 1


tests = int(input())
for _ in range(tests):
	(n, k) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	s += [0]
	for i in range(k):
		b = 0
		while b < n:
			if s[b] >= s[b + 1]:
				b += 1
			else:
				s[b] += 1
				break
		if b == n:
			print(-1)
			break
		if i == k - 1:
			print(b + 1)


import sys
input = sys.stdin.readline

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

def solve(k, heights):
	max_item = max(heights)
	s = 0
	for h in heights:
		s += max_item - h
	if s < k:
		return -1
	last_height = -1
	for i in range(k):
		for h_index in range(1, len(heights)):
			if heights[h_index - 1] >= heights[h_index]:
				if h_index == len(heights) - 1:
					return -1
			else:
				heights[h_index - 1] += 1
				last_height = h_index
				break
	return last_height
for _ in range(int(input())):
	(n, k) = read()
	h = read()
	print(solve(k, h))


t = int(input())
while t:
	t -= 1
	l = list(map(int, input().split()))
	n = l[0]
	k = l[1]
	h = list(map(int, input().split()))
	j = -1
	while k != 0:
		k -= 1
		m = 0
		for i in range(n - 1):
			if h[i] < h[i + 1]:
				m += 1
				h[i] += 1
				j = i + 1
				break
		if m == 0:
			j = -1
			break
	print(j)


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

def f(h_seq, k):
	h_seq = list(h_seq)
	if k > max(h_seq) * len(h_seq):
		return -1
	pos = None
	for i_k in range(k):
		i = 0
		while i + 1 != len(h_seq) and h_seq[i] >= h_seq[i + 1]:
			i += 1
		if i == len(h_seq) - 1:
			return -1
		pos = i
		h_seq[pos] += 1
	return pos
(t_n,) = read_ints()
for i_t in range(t_n):
	(n, k) = read_ints()
	h_seq = tuple(read_ints())
	result = f(h_seq, k)
	print(result + 1 if result != -1 else result)


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

def solve(N, K, H):
	assert len(H) == N
	k = 0
	while True:
		for i in range(N):
			if i == N - 1:
				return -1
			if H[i] < H[i + 1]:
				H[i] += 1
				k += 1
				if k == K:
					return i + 1
				break
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, K) = [int(x) for x in input().split()]
	H = [int(x) for x in input().split()]
	ans = solve(N, K, H)
	print(ans)


import sys
import math

def fn(n, k, h):
	if n == 1:
		return -1
	for i in range(k):
		j = 0
		while j < n - 1 and h[j + 1] <= h[j]:
			if j == n - 2:
				return -1
			j = j + 1
		h[j] = h[j] + 1
	return j + 1
input = sys.stdin.read()
data = list(map(int, input.split()))
t = data[0]
l = 0
for i in range(t):
	n = data[l + 1]
	k = data[l + 2]
	h = data[l + 3:l + 3 + n]
	l = l + 2 + n
	print(fn(n, k, h))


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

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

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

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

def pr(n):
	return stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, k) = mp()
	l = li()
	for i in range(k):
		j = 0
		while j < n - 1 and l[j] >= l[j + 1]:
			j += 1
		if j == n - 1:
			pr(-1)
			return
		l[j] += 1
		if i == k - 1:
			pr(j + 1)
			return
for _ in range(inp()):
	solve()


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	heights = list(map(int, input().split()))
	val = -2
	while k > 0:
		ind = 0
		while ind < n - 1 and heights[ind] >= heights[ind + 1]:
			ind += 1
		if ind == n - 1:
			val = -2
			break
		else:
			heights[ind] += 1
			k -= 1
			val = ind
			ind += 1
	print(val + 1)
	t -= 1


def solve(n, k, h):
	i = 0
	if n == 1:
		return -1
	while k > 0 and i < n - 1:
		if h[i] >= h[i + 1]:
			i += 1
			continue
		if i == 0:
			a = h[1] - h[0]
			h[0] += a
			k -= a
		elif h[i - 1] == h[i]:
			h[i] += 1
			k -= 1
			if k == 0:
				return i + 1
			i -= 1
		else:
			a = min(h[i - 1] - h[i], h[i + 1] - h[i])
			h[i] += a
			k -= a
	if k > 0:
		return -1
	else:
		return i + 1
T = int(input())
for t in range(T):
	(n, k) = tuple(map(int, input().split()))
	h = list(map(int, input().split()))
	print(solve(n, k, h))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lst = -1
	while k > 0:
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				a[i] += 1
				k -= 1
				lst = i + 1
				break
		else:
			break
	print(-1 if k > 0 else lst)


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

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

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

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

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

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	(n, k) = RL()
	a = RLL()
	for _ in range(k - 1):
		f = False
		for i in range(1, n):
			if a[i] > a[i - 1]:
				a[i - 1] += 1
				f = True
				break
		if not f:
			break
	f = False
	for i in range(1, n):
		if a[i] > a[i - 1]:
			print(i)
			f = True
			break
	if not f:
		print(-1)


def solve(n, k, arr):
	ans = n + 1
	for __ in range(k):
		to = -2
		for i in range(0, n - 1):
			if arr[i] < arr[i + 1]:
				to = i
				break
		ans = to + 1
		if to == -2:
			break
		arr[to] += 1
	print(ans)
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(s) for s in input().split()]
	mx = max(arr)
	if n * mx < k:
		print('-1')
		continue
	solve(n, k, arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	res = 0
	for i in range(k):
		key = 0
		for j in range(n - 1):
			if arr[j] < arr[j + 1]:
				arr[j] += 1
				key = 1
				break
			else:
				continue
		if key == 0:
			res = -1
			break
		if i == k - 1:
			res = j + 1
	print(res)


def solve(arr, n, k):
	i = 0
	while k and i < n - 1:
		if arr[i] < arr[i + 1]:
			if k == 1:
				return i + 1
			arr[i] += 1
			k -= 1
			i = 0
		else:
			i = i + 1
	if i == n - 1:
		return -1
t = int(input())
while t:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(solve(arr, n, k))
	t -= 1


t = int(input())
for j in range(t):
	coords = input().split()
	n = int(coords[0])
	k = int(coords[1])
	nums = input().split()
	height = [int(nums[i]) for i in range(n)]
	index = 0
	while k > 0 and index < n - 1:
		dip = False
		while not dip:
			if index == n - 1:
				break
			elif height[index] >= height[index + 1]:
				index += 1
			else:
				dip = True
		if index != n - 1:
			increase = index
			height[index] += 1
			k -= 1
			if index != 0 and height[index] > height[index - 1]:
				index -= 1
	if index < n - 1:
		print(increase + 1)
	else:
		print(-1)


def NewColony(n, k, arr):
	i = 0
	for kk in range(k):
		i = 0
		while i < n - 1:
			if arr[i] < arr[i + 1]:
				arr[i] += 1
				break
			i += 1
		if i == n - 1:
			return -1
	return i + 1
t = int(input())
for test in range(t):
	(n, k) = map(int, input().rstrip().split())
	arr = list(map(int, input().rstrip().split()))
	result = NewColony(n, k, arr)
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = []
	i = 0
	while k > 0:
		i = 0
		while i < n - 1 and h[i + 1] <= h[i]:
			i += 1
		if i == n - 2 and h[i + 1] <= h[i] or i == n - 1:
			ans.append(-1)
			break
		h[i] += 1
		ans.append(i + 1)
		k -= 1
	print(ans[-1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	if sorted(h, reverse=True) == h:
		print(-1)
	else:
		pos = 0
		count = 0
		flag = 0
		for x in range(k):
			c = 0
			if flag == 1:
				print(-1)
				break
			for y in range(n - 1):
				if h[y] < h[y + 1]:
					h[y] += 1
					pos = y
					break
				else:
					c += 1
			if c == n - 1:
				if x == k - 1:
					print(-1)
				flag = 1
			count += 1
		if count == k and flag == 0:
			print(pos + 1)


try:
	for _ in range(int(input())):
		(n, K) = map(int, input().split())
		h = list(map(int, input().split()))
		i = 0
		while i < n - 1 and h[i] >= h[i + 1]:
			i += 1
		for k in range(K - 1):
			if i == n - 1:
				break
			h[i] += 1
			if i > 0:
				i -= 1
			while i < n - 1 and h[i] >= h[i + 1]:
				i += 1
		if i == n - 1:
			print(-1)
		else:
			print(i + 1)
except:
	pass


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	c = False
	ans = 0
	d = 0
	for i in range(y):
		if d:
			c = True
			break
		for j in range(x):
			if j == x - 1:
				d = 1
				break
			if a[j] < a[j + 1]:
				ans = j
				break
		a[j] += 1
		if d:
			c = True
			break
	if c:
		print(-1)
	else:
		print(j + 1)


t = int(input())
for _ in range(t):
	(_, k) = map(int, input().split())
	heights = [int(i) for i in input().split()]
	stack = [(float('inf'), 0)]
	for (i, h) in enumerate(heights):
		i += 1
		level = 0
		found = False
		while True:
			(stack_h, stack_i) = stack[-1]
			dh = min(stack_h, h) - level
			di = i - stack_i - 1
			dk = di * dh
			if dk >= k:
				found = True
				pos = stack_i + di - (k - 1) % di
				break
			k -= dk
			level = min(stack_h, h)
			if stack_h > h:
				break
			stack.pop()
		stack.append((h, i))
		if found:
			break
	if found:
		print(pos)
	else:
		print(-1)


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

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

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

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

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

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7

def solve():
	now = -1
	for _ in range(k):
		for i in range(n - 1):
			if aa[i] < aa[i + 1]:
				aa[i] += 1
				now = i + 1
				break
		else:
			return -1
	return now
for _ in range(II()):
	(n, k) = MI()
	aa = LI()
	print(solve())


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = list(map(int, input().strip().split()))[:n]
	index = 1
	flag = 0
	for a in range(0, k):
		index = 1
		flag = 0
		for j in range(n - 1):
			if arr[j] < arr[j + 1]:
				arr[j] = arr[j] + 1
				flag = 1
				index = j + 1
				break
			else:
				continue
		if flag == 0:
			break
	if index == 1 and flag == 0:
		print('-1')
	else:
		print(index)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)

def number_to_list(a):
	b = []
	while a >= 1:
		c = a % 10
		a = int(a / 10)
		b.append(c)
	return list(reversed(b))

def str_list_to_int_list(a):
	a = list(map(int, a))
	return a

def make_1d_array(n, inti=0):
	a = [inti for _ in range(n)]
	return a

def make_2d_array(n, m, inti=0):
	a = [[inti for _ in range(m)] for _ in range(n)]
	return a

def make_3d_array(n, m, k, inti=0):
	a = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]
	return a

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input()))

def check(h):
	prev = h[0]
	idx = 0
	for i in range(1, len(h)):
		if prev >= h[i]:
			idx = i
			prev = h[i]
		else:
			return idx
	if idx == len(h) - 1:
		return -1
(t,) = I()
for t1 in range(t):
	(n, k) = I()
	h = I()
	count = 0
	for i in range(k - 1):
		if check(h) == -1:
			print(-1)
			count = 1
			break
		else:
			h[check(h)] += 1
	if count == 1:
		pass
	elif check(h) == -1:
		print(-1)
	else:
		print(check(h) + 1)


t = lambda : map(int, input().split())
for _ in range(int(input())):
	(g, k) = t()
	l = list(t())
	for i in range(k):
		w = -1
		for j in range(1, g):
			if l[j - 1] < l[j]:
				l[j - 1] += 1
				w = j
				break
		if w == -1:
			break
	print(w)


t = int(input())

def get_answer(n, k, h):
	pos = 0
	while k > 0 and pos < n - 1:
		if h[pos] < h[pos + 1]:
			k -= 1
			h[pos] += 1
			if k > 0:
				pos = 0
		else:
			pos += 1
	if pos == n - 1:
		return -1
	else:
		return pos + 1
for _ in range(t):
	(n, k) = tuple(map(int, input().split()))
	h = list(map(int, input().split()))
	print(get_answer(n, k, h))


for _ in range(int(input())):
	(n, k) = [*map(int, input().split())]
	l = [*map(int, input().split())]
	ans = 0
	for i in range(k):
		cnt = 0
		for j in range(n - 1):
			if l[j] < l[j + 1]:
				l[j] += 1
				ans = j + 1
				break
			cnt += 1
		if cnt == n - 1:
			ans = -1
			break
	print(ans)


from itertools import accumulate as ac
from collections import Counter as cc
from bisect import bisect_left as bsl
from bisect import bisect as bs
from math import factorial
from collections import OrderedDict as odict
from collections import defaultdict as dfd
import itertools
from statistics import mean
from math import ceil, sqrt, log, gcd
import math
import os
import sys
from io import BytesIO, IOBase
import random
import copy
import time
from itertools import islice
from functools import lru_cache
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))

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

def lcm(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def intinput():
	return int(input())

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

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

def intinputlist():
	return list(intinputiter())

def intinputset():
	return set(intinputiter())
n = int(input())
for _ in range(n):
	(n, k) = list(map(int, input().split()))
	mountains = list(map(int, input().split()))
	for i in range(k):
		ans = -1
		for j in range(n - 1):
			if mountains[j] < mountains[j + 1]:
				ans = j
				mountains[j] += 1
				break
		if ans == -1:
			break
	print(ans if ans == -1 else ans + 1)


t = int(input())
for _ in range(t):
	(n, k) = [int(d) for d in input().split()]
	h = [int(d) for d in input().split()]
	c = 0
	i = 0
	while c != k:
		if i < n - 1:
			if h[i] < h[i + 1]:
				c = c + 1
				h[i] += 1
				curr = i
				if h[i] == h[i + 1]:
					if i > 0 and h[i - 1] < h[i]:
						i = i - 1
					else:
						i = i + 1
				elif i > 0 and h[i] > h[i - 1]:
					i = i - 1
				if c == k:
					print(curr + 1)
					break
			else:
				i = i + 1
		else:
			print(-1)
			break


for test in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	if a == 1:
		print(-1)
	else:
		d = 1
		e = 0
		f = 0
		for i in range(a - 1):
			if c[i] < c[i + 1]:
				f = 1
				break
		if f == 0:
			print(-1)
		else:
			for j in range(b):
				for i in range(1, a):
					if c[i - 1] < c[i]:
						c[i - 1] += 1
						d = i
						break
				p = 0
				for i in range(a - 1):
					if c[i] < c[i + 1]:
						p = 1
						break
				if p == 0 and j != b - 1:
					e = 1
					break
			if e == 1:
				print(-1)
			else:
				print(d)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = -1
	for i in range(k):
		ans = -1
		for j in range(n - 1):
			if h[j] < h[j + 1]:
				h[j] = h[j] + 1
				ans = j + 1
				break
		if ans == -1:
			break
	print(ans)


def simulate(n, k, xs):
	i = 0
	while i + 1 < n:
		if xs[i + 1] <= xs[i]:
			i += 1
			continue
		xs[i] += 1
		k -= 1
		if k == 0:
			return i + 1
		if i > 0 and xs[i] >= xs[i - 1]:
			i -= 1
	return -1

def solve(n, k, xs):
	return simulate(n, k, xs)

def driver():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		xs = list(map(int, input().split()))
		print(solve(n, k, xs))

def test():
	assert solve(4, 3, [4, 1, 2, 3]) == 2
	assert solve(2, 7, [1, 8]) == 1
	assert solve(4, 5, [4, 1, 2, 3]) == -1
	assert solve(3, 1, [5, 3, 1]) == -1
	solve(4, 5, [1, 1, 1, 4])
driver()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	hills = list(map(int, input().split()))
	for l in range(k):
		j = 0
		while j < len(hills) - 1 and hills[j] >= hills[j + 1]:
			j += 1
		if j == len(hills) - 1:
			out = -2
			break
		out = j
		hills[j] += 1
	print(out + 1)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	prev = 0
	for i in range(k):
		j = 0
		while j < n - 1:
			if arr[j] < arr[j + 1]:
				arr[j] += 1
				break
			j += 1
		prev = j + 1
		if prev == n:
			print(-1)
			break
	if prev != n:
		print(prev)


def ass(a, b):
	print(f'Assertion error: {a} != {b}' if a != b else 'OK')

def number():
	return int(input())

def numbers():
	return [int(item) for item in input().split()]

def word():
	return input()

def words():
	return [item for item in input().split()]

def dump(lst):
	for (i, item) in enumerate(lst):
		print(i, item)

def binsearch(arr, a, b):
	m = (a + b) // 2
	if a >= b:
		return a - 1 if arr[a] == 0 else a
	return binsearch(arr, a, m - 1) if arr[m] == 0 else binsearch(arr, m + 1, b)

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def f(k, arr):
	res = 0
	for i in range(k):
		for j in range(len(arr)):
			if j == len(arr) - 1:
				return -1
			if arr[j] < arr[j + 1]:
				arr[j] += 1
				res = j
				break
	return 1 + res
for i in range(number()):
	(n, k) = numbers()
	print(f(k, numbers()))


testcase = int(input())
for i in range(testcase):
	(n, k) = [int(x) for x in input().split()]
	lst = [int(x) for x in input().split()]
	i = 0
	while i < n:
		if i == n - 1:
			print(-1)
			break
		if lst[i] >= lst[i + 1]:
			i += 1
		else:
			lst[i] += 1
			if k > 1:
				i = 0
			k -= 1
		if k == 0:
			print(i + 1)
			break


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	flag = 0
	i = 0
	pos = 0
	if n == 1:
		print('-1')
	else:
		while k > 0:
			for i in range(n - 1):
				if p[i + 1] <= p[i] and i == n - 2:
					pos = -1
					break
				elif p[i + 1] > p[i]:
					p[i] = p[i] + 1
					k -= 1
					if k == 0:
						pos = i + 1
					break
				if k == 0:
					pos = i + 1
					break
			if pos != 0:
				break
		print(pos)


from sys import stdin

def main():
	cases = int(stdin.readline().strip())
	while cases:
		(n, k) = map(int, stdin.readline().split())
		v = [int(x) for x in stdin.readline().split()]
		(j, c) = (0, True)
		while k and c:
			(j, c) = (0, False)
			while j < n - 1 and (not c):
				if v[j] < v[j + 1]:
					v[j] += 1
					k -= 1
					c = True
				j += 1
		if k == 0:
			print(j)
		else:
			print(-1)
		cases -= 1
main()


import sys
input = sys.stdin.readline

def solution(n, k, hs):
	hs = [10 ** 20] + hs
	carry = 0
	new_carry = 0
	pos = 0
	while True:
		pos = 0
		new_carry = 0
		while pos <= n:
			if pos == n:
				print(-1)
				return
			if hs[pos] >= hs[pos + 1]:
				pos += 1
			else:
				pos_r = pos + 1
				pos_l = pos
				while hs[pos_l] == hs[pos]:
					pos_l -= 1
				new_carry = (min(hs[pos_r], hs[pos_l]) - hs[pos]) * (pos_r - pos_l - 1)
				if carry + new_carry >= k:
					rest = k - carry - 1
					print(-(rest % (pos_r - pos_l - 1)) + pos_r - pos_l - 1 + pos_l)
					return
				else:
					carry += new_carry
					for p in range(pos_l + 1, pos_r):
						hs[p] = min(hs[pos_r], hs[pos_l])
					break
T = int(input())
for t in range(T):
	[n, k] = list(map(int, input().split()))
	hs = list(map(int, input().split()))
	solution(n, k, hs)


import heapq
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	diff = []
	for i in range(n - 1):
		diff.append([l[i] - l[i + 1], i + 1])
	heap = []
	heapq.heapify(heap)
	for i in diff:
		if i[0] < 0:
			heapq.heappush(heap, i[1])
	while heap != [] and k != 0:
		ind = heapq.heappop(heap)
		k -= 1
		diff[ind - 1][0] += 1
		if diff[ind - 1][0] < 0:
			heapq.heappush(heap, diff[ind - 1][1])
		if ind > 1:
			diff[ind - 2][0] -= 1
			if diff[ind - 2][0] < 0:
				heapq.heappush(heap, diff[ind - 2][1])
	if k == 0:
		print(ind)
	else:
		print(-1)


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))

def solve():
	(n, x) = inm()
	a = ina()
	if n == 1:
		print(-1)
		return
	b = a[:]
	total = 0
	for i in range(n - 1, 0, -1):
		total += max(a[i] - a[i - 1], 0)
		a[i - 1] = max(a[i - 1], a[i])
	if x > total:
		print(-1)
		return
	i = 0
	while i < n - 1:
		if b[i] >= b[i + 1]:
			i += 1
		else:
			x -= 1
			if x == 0:
				print(i + 1)
				return
			b[i] += 1
			if i > 0:
				if b[i - 1] < b[i]:
					i -= 1

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	i = 0
	while k != 0 and i < n - 1:
		if l[i] < l[i + 1]:
			l[i] += 1
			k -= 1
			if k != 0:
				i = max(0, i - 1)
		else:
			i += 1
	if k == 0:
		print(i + 1)
	else:
		print(-1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	pos = -1
	while k > 0:
		for i in range(n - 1):
			if h[i] < h[i + 1]:
				h[i] += 1
				k -= 1
				pos = i + 1
				break
		else:
			break
	print('-1' if k > 0 else pos)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if k > 10000:
		print(-1)
		continue
	res = []
	for i in range(k):
		pos = 0
		for j in range(1, n):
			if a[j] <= a[j - 1]:
				pos += 1
			else:
				a[pos] += 1
				break
		if pos >= n:
			pos = -1
	if pos >= n - 1:
		pos = -2
	print(pos + 1)


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ans = 0
	if n == 1:
		ans = -1
	for j in range(k):
		if ans > -1:
			for x in range(1, n):
				if a[x - 1] < a[x]:
					a[x - 1] += 1
					ans = x
					break
				if x == n - 1:
					ans = -1
					break
		else:
			break
	print(ans)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	s = [int(x) for x in input().split()]
	b_pos = []
	bo = False
	i = 0
	while i < b and bo == False:
		for j in range(a - 1):
			if s[j + 1] > s[j]:
				b_pos.append(j)
				s[j] += 1
				break
		else:
			print(-1)
			bo = True
		i += 1
	if i == b and b - 1 < len(b_pos):
		print(b_pos[b - 1] + 1)


test = int(input())
while test:
	(n, k) = map(int, input().split())
	li = list(map(int, input().split()))
	pos = 0
	pt = 0
	while k > 0 and pt < n - 1:
		if li[pt] >= li[pt + 1]:
			pt += 1
		else:
			pos = pt + 1
			li[pt] += 1
			if pt == 0:
				pt = 0
			else:
				pt -= 1
			k -= 1
	if pt >= n - 1:
		print(-1)
	else:
		print(pos)
	test -= 1


def sort(lst):
	flag = 0
	i = 1
	while i < len(lst):
		if lst[i] > lst[i - 1]:
			flag = 1
		i += 1
	if not flag:
		return 1
	else:
		return 0

def solution(n, k, lst):
	if len(lst) == 1 or len(lst) == 0:
		print(-1)
		return
	while k > 0:
		req_idx = -2
		j = 0
		for i in range(n - 1):
			if lst[i] < lst[i + 1]:
				lst[i] = lst[i] + 1
				k = k - 1
				break
		if sort(lst) and k > 0:
			print(-1)
			return
		elif k == 0:
			print(i + 1)
			return
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	solution(n, k, lst)


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	queue = [[200, 0]]
	res = 0
	index = -1
	con = True
	for i in range(n):
		if arr[i] < queue[-1][0]:
			queue.append([arr[i], 1])
		elif arr[i] == queue[-1][0]:
			queue[-1][1] += 1
		else:
			while arr[i] > queue[-1][0]:
				(h, c) = queue.pop()
				target = min(queue[-1][0], arr[i])
				if res + (target - h) * c >= k:
					diff = k - res
					if diff % c == 0:
						index = i + 1 - c
					else:
						index = i + 1 - diff % c
					con = False
					break
				else:
					res += (target - h) * c
					if target == queue[-1][0]:
						queue[-1][1] += c
					if target == arr[i]:
						if queue[-1][0] == arr[i]:
							queue[-1][1] += 1
						else:
							queue.append([arr[i], c + 1])
		if not con:
			break
	print(index)
	T -= 1


try:
	t = int(input())
	while t != 0:
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		p = max(arr)
		if k > n * p:
			print(-1)
		else:
			popi = 0
			for i in range(k):
				j = 0
				flag = 0
				while j < n - 1:
					if j == 0:
						if arr[j] < arr[j + 1]:
							popi = j
							arr[j] += 1
							flag = 1
							break
					elif arr[j - 1] >= arr[j] and arr[j] < arr[j + 1]:
						popi = j
						arr[j] += 1
						flag = 1
						break
					j += 1
				if flag == 0:
					popi = -1
			if popi == -1:
				print(-1)
			else:
				print(popi + 1)
		t -= 1
except EOFError:
	print(' ')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	while k > 0:
		kol = 0
		for i in range(n - 1):
			if h[i] < h[i + 1]:
				h[i] += 1
				k -= 1
				if k <= 0:
					print(i + 1)
					break
				break
			else:
				kol += 1
		if kol == n - 1:
			print(-1)
			break


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	j = 0
	while True:
		if len(h) - 2 == j and h[j] >= h[j + 1] or j == len(h) - 1:
			print(-1)
			break
		if h[j] >= h[j + 1]:
			j += 1
		else:
			h[j] += 1
			k -= 1
			if not k:
				print(j + 1)
				break
			j = 0


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

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

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	ans = ''
	for _ in range(ii()):
		(n, k) = mi()
		arr = li()
		if n == 1:
			ans += '-1\n'
		else:
			tmp = -1
			while k > 0:
				flag = 1
				for i in range(n - 1):
					if arr[i] < arr[i + 1]:
						if i != 0:
							x = min(arr[i + 1] - arr[i], arr[i - 1] - arr[i] + 1)
							k -= x
							arr[i] += x
						else:
							k -= arr[i + 1] - arr[i]
							arr[i] = arr[i + 1]
						flag = 0
						if k <= 0:
							tmp = i + 1
							flag = 1
							break
						break
				if flag:
					break
			ans += str(tmp) + '\n'
	print(ans)
main()


def jj():
	ax = int(input())
	for i in range(ax):
		(dd, ww) = map(int, input().split())
		kk = [int(zz) for zz in input().split()]
		gg = True
		for q in range(ww):
			qq = 1
			for j in range(dd - 1):
				if kk[j] >= kk[j + 1]:
					qq += 1
				else:
					kk[j] += 1
					break
			if qq >= dd:
				print(-1)
				gg = False
				break
		if gg:
			print(qq)
jj()


test_cases = int(input())

def func():
	(n, k) = list(map(int, input().strip().split()))
	heights = list(map(int, input().strip().split()))
	curr_idx = 0
	for boulder in range(k):
		curr_idx = 0
		while curr_idx + 1 != n and heights[curr_idx] >= heights[curr_idx + 1]:
			curr_idx += 1
		if curr_idx >= n - 1:
			print(-1)
			return
		heights[curr_idx] += 1
	print(curr_idx + 1)
	return
for _ in range(test_cases):
	func()


from time import process_time_ns
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	h = [int(x) for x in input().split(' ')]
	for i in range(k):
		c = -1
		for j in range(n - 1):
			if h[j] < h[j + 1]:
				h[j] += 1
				c = j + 1
				break
		if c == -1:
			break
	print(c)


import sys

def input():
	return sys.stdin.readline()
for t in range(int(input())):
	(n, k) = map(int, input().split())
	st = [[int(2000000000.0), 0]]
	ans = None
	for h in map(int, input().split()):
		if ans is None:
			if h > st[-1][0]:
				while h > st[-1][0]:
					w = st[-1][1]
					have = min(k // w, h - st[-1][0])
					if have >= 1:
						if have + st[-1][0] >= st[-2][0]:
							have = st[-2][0] - st[-1][0]
							k -= have * w
							st.pop()
							if k == 0:
								ans = -w
								break
							st[-1][1] += w
						else:
							st[-1][0] += have
							k -= have * w
							if k == 0:
								ans = -w
								break
					else:
						ans = -k
						break
				if ans is None:
					if st[-1][0] == h:
						st[-1][1] += 1
					else:
						st.append([h, 1])
			elif h == st[-1][0]:
				st[-1][1] += 1
			else:
				st.append([h, 1])
	if ans is None:
		print(-1)
	else:
		res = 0
		for (_, w) in st:
			res += w
		print(res + ans + 1)


for _ in range(int(input())):
	(m, n) = tuple((int(n) for n in input().split(' ')))
	ms = [int(n) for n in input().split(' ')]
	f = -1
	for i in range(n):
		for j in range(m - 1):
			if ms[j] < ms[j + 1]:
				ms[j] += 1
				f = j + 1
				break
			else:
				f = -1
		if f == -1:
			break
	print(f)


def get_colony(nums, K, N):
	boulder = 0
	while K > 0:
		isFall = True
		for i in range(1, N):
			if nums[i] > nums[i - 1]:
				nums[i - 1] += 1
				isFall = False
				boulder = i
				break
		if isFall:
			return -1
		K -= 1
	return boulder
T = int(input())
for i in range(T):
	(N, K) = map(int, input().split())
	nums = list(map(int, input().split()))
	print(get_colony(nums, K, N))


k = 0
tcs = int(input())
for i in range(tcs):
	(n, k) = [int(x) for x in input().split()]
	heights = [int(x) for x in input().split()]
	while k > 0:
		for i in range(len(heights)):
			try:
				if heights[i + 1] > heights[i]:
					k -= 1
					heights[i] += 1
					ans = i + 1
					break
			except:
				ans = -1
				k = 0
				break
	print(ans)


import sys
input = sys.stdin.readline

def solve():
	(n, k) = map(int, input().split())
	H = list(map(int, input().split()))
	cnt = idx = 0
	while idx < n - 1:
		if H[idx] >= H[idx + 1]:
			idx += 1
		else:
			H[idx] += 1
			cnt += 1
			if cnt == k:
				return idx + 1
			idx = 0
	return -1
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	h.append(0)
	for __ in range(k):
		nomer = 1
		flag = False
		for i in range(0, len(h) - 1):
			if h[i] < h[i + 1]:
				h[i] += 1
				break
			else:
				nomer += 1
				continue
		if nomer == len(h):
			flag = True
			nomer = -1
			break
	print(nomer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	flag = 0
	if n == 1:
		print(-1)
	else:
		for i in range(k):
			for j in range(n - 1):
				if l[j] < l[j + 1]:
					l[j] += 1
					if i == k - 1:
						print(j + 1)
					break
				if j == n - 2:
					print(-1)
					flag = 1
			if flag == 1:
				break


import sys
input = sys.stdin.readline
MIS = lambda : map(int, input().rstrip().split())
t = int(input().rstrip())
for _ in range(t):
	(n, k) = MIS()
	data = list(MIS())
	mx = max(data)
	if n * mx < k:
		print(-1)
		continue
	ans = n + 1
	for b in range(k):
		to = -2
		for i in range(n - 1):
			if data[i] < data[i + 1]:
				to = i
				break
		ans = to + 1
		if to == -2:
			break
		data[to] += 1
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

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

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

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

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
for _ in range(L()[0]):
	(n, k) = L()
	A = L()
	ans = -1
	while k > 0:
		i = 0
		while i + 1 < n and A[i] >= A[i + 1]:
			i += 1
		if i == n - 1:
			ans = -1
			break
		i += 1
		if k > 0 and 0 < i < n:
			A[i - 1] += 1
			k -= 1
			if k == 0:
				ans = i
				break
	print(ans)
endtime = time.time()


def boulder(arr, k):
	while True and k:
		flag = True
		for i in range(0, len(arr) - 1):
			if arr[i + 1] > arr[i]:
				arr[i] += 1
				k -= 1
				flag = False
				if k == 0:
					return i + 1
				break
		if flag == True:
			return -1
for i in range(int(input())):
	(a, b) = map(int, input().strip().split())
	lst = list(map(int, input().strip().split()))
	print(boulder(lst, b))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 100000.0 + 1
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	h = list(map(int, stdin.readline().rstrip().split()))
	if n == 1:
		print(-1)
		continue
	isOk = True
	ans = []
	ix = 0
	while isOk:
		if h[ix] >= h[ix + 1]:
			ix += 1
		else:
			h[ix] += 1
			ans.append(ix + 1)
			ix = 0
		if ix == n - 1:
			break
	if k > len(ans):
		print(-1)
	else:
		print(ans[k - 1])


import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	c = 0
	while k != 0:
		stop = 0
		for i in range(0, n - 1):
			if arr[i] < arr[i + 1]:
				stop = 1
				arr[i] += 1
				k -= 1
				c = i
				break
		if stop == 0:
			print(-1)
			break
	if stop != 0:
		print(c + 1)
	else:
		continue


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	l = [int(k) for k in input().split()]
	idx = 0
	f = 0
	for c in range(k):
		i = 1
		while i < n and l[i] <= l[i - 1]:
			i += 1
		if i == n:
			idx = -1
			break
		else:
			idx = i - 1
			l[i - 1] = l[i - 1] + 1
	if idx > -1:
		print(idx + 1)
	else:
		print(-1)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	h = list(map(int, input().strip().split()))[:n]
	sum = 0
	l = h[n - 1]
	for i in range(n - 1, 0, -1):
		if h[i - 1] < l:
			sum = sum + l - h[i - 1]
		else:
			l = h[i - 1]
	if k > sum:
		print(-1)
	else:
		ans = 0
		while k > 0:
			for i in range(1, n, 1):
				if h[i] > h[i - 1]:
					k -= 1
					h[i - 1] += 1
					ans = i
					break
		print(ans)
	t = t - 1


for _ in range(int(input())):
	(n, boulder) = map(int, input().split())
	arr = list(map(int, input().split()))
	while True:
		found = False
		for k in range(n - 1):
			if arr[k] < arr[k + 1]:
				found = True
				boulder -= 1
				arr[k] += 1
				break
		if boulder == 0:
			print(k + 1)
			break
		if found == False and boulder > 0:
			print('-1')
			break


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	ans = -1
	for i in range(k):
		found = False
		for j in range(n - 1):
			if a[j] < a[j + 1]:
				found = True
				a[j] += 1
				ans = j
				break
		if not found:
			break
	if not found:
		print(-1)
	else:
		print(ans + 1)


sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())
mod = 10 ** 9 + 7

def hnbhai():
	(n, k) = sd()
	a = sd()
	if n == 1:
		print(-1)
		return
	x = 1
	q = 0
	s = 0
	for i in range(n - 1):
		if a[i] < a[i + 1]:
			s = 1
			break
	if s == 0:
		print(-1)
		return
	for j in range(k):
		for i in range(1, n):
			if a[i - 1] < a[i]:
				a[i - 1] += 1
				x = i
				break
		p = 0
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				p = 1
				break
		if p == 0 and j != k - 1:
			q = 1
			break
	if q == 1:
		print(-1)
	else:
		print(x)
for _ in range(sb()):
	hnbhai()


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = 0
	f = 1
	while f:
		if n >= 2:
			d = h[1] - h[0]
			if d > 0:
				if k > d:
					k -= d
					h[0] = h[1]
					f = 1
				else:
					ans = 1
					f = 0
					break
		for i in range(2, n):
			d = h[i] - h[i - 1]
			if d > 0:
				d2 = h[i - 2] - h[i - 1]
				if d2 < d and d2 >= 0:
					if k > d2 + 1:
						k -= d2 + 1
						h[i - 1] = h[i - 2] + 1
					else:
						ans = i
						f = 0
				elif k > d:
					k -= d
					h[i - 1] = h[i]
				else:
					ans = i
					f = 0
				break
		else:
			f = 0
			ans = n
	print(ans if n > ans > 0 else -1)


for _ in range(int(input())):
	(n_nui, da) = map(int, input().split())
	nui = list(map(int, input().split()))
	waste = False
	for i in range(da):
		j = 0
		while j < n_nui - 1:
			if nui[j] < nui[j + 1]:
				nui[j] += 1
				break
			else:
				j += 1
		if j == n_nui - 1:
			waste = True
			break
	if waste:
		print(-1)
	else:
		print(j + 1)


from collections import *
n = int(input())
for _ in range(n):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	x = l.copy()
	ap = []
	for i in range(k):
		f = 0
		for i in range(n - 1):
			if l[i] < l[i + 1]:
				f = 1
				ap.append(i)
				x[i] += 1
				break
		l = x.copy()
		if f == 0:
			break
	if f == 0:
		print(-1)
	else:
		print(ap[k - 1] + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	prev = arr[0]
	l = 1
	s = prev
	k_ = 0
	i = 0
	while i < n - 1:
		if arr[i] < arr[i + 1]:
			k_ += 1
			if k_ >= k:
				print(i + 1)
				break
			arr[i] += 1
			i = 0
			continue
		i += 1
	else:
		print(-1)


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


def solve(n, k, hill):
	if n < 2:
		return -1
	count = 0
	while count < k:
		for i in range(1, n):
			if hill[i - 1] >= hill[i]:
				if i == n - 1:
					return -1
			else:
				hill[i - 1] += 1
				count += 1
				if count == k:
					return i
				break
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	print(solve(n, k, h))


loopcount = int(input())
for loop in range(loopcount):
	x = input()
	x = x.split(' ')
	x = list(map(int, x))
	y = input()
	y = y.split(' ')
	y = list(map(int, y))
	output = 0
	while x[1] > 0:
		flag = True
		for i in range(x[0] - 1):
			if y[i + 1] > y[i]:
				y[i] += 1
				output = i + 1
				flag = False
				break
		if flag:
			output = -1
			break
		x[1] -= 1
	print(output)


def boulder_run(n, h):
	for i in range(n - 1):
		if h[i] < h[i + 1]:
			h[i] += 1
			return i + 1
	return -1

def answer(n, k, h):
	position = 1
	for _ in range(k):
		position = boulder_run(n, h)
		if position == -1:
			return -1
	return position
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	print(answer(n, k, h))


n = int(input())
res = [0] * n
for i in range(n):
	s = input().split()
	(n, k) = (int(s[0]), int(s[1]))
	arr_h = [0] * n
	arr = input().split()
	for j in range(n):
		arr_h[j] = int(arr[j])
	index = 0
	while k > 0:
		index = 0
		k -= 1
		while index < n - 1 and arr_h[index] >= arr_h[index + 1]:
			index += 1
		if index + 1 == n:
			res[i] = -1
			k = -1
		arr_h[index] += 1
	if k != -1:
		res[i] = index + 1
for it in res:
	print(it)


t = int(input())
for trial in range(0, t):
	(mountains, boulders) = [int(x) for x in input().split(' ')]
	heights = [int(x) for x in input().split()]
	try:
		for boulder in range(0, boulders):
			i = 0
			while heights[i] >= heights[i + 1]:
				i += 1
			heights[i] += 1
		print(i + 1)
	except IndexError:
		print(-1)


t = int(input())
for d in range(t):
	li = [int(x) for x in input().split()]
	n = li[0]
	k = li[1]
	arr = [int(x) for x in input().split()]
	flag = 0
	while k != 0:
		x = 0
		for i in range(n - 1):
			if arr[i] < arr[i + 1]:
				arr[i] += 1
				break
			else:
				x += 1
		if x == n - 1:
			flag = 1
			break
		k = k - 1
	if flag == 1:
		print('-1')
	else:
		print(x + 1)


import math

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a / gcd(a, b) * b
try:
	t = int(input())
	while t > 0:
		t -= 1
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		ans = -1
		for i in range(k):
			flag = False
			for j in range(n):
				if j == n - 1:
					flag = True
					break
				elif l[j] >= l[j + 1]:
					continue
				else:
					if i == k - 1:
						ans = j + 1
					l[j] += 1
					break
			if flag == True:
				break
		print(ans)
except:
	pass


t = int(input())
for _ in range(t):
	(n, k) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	mx = max(a)
	if mx * n < k:
		ans = -1
	else:
		ans = n + 1
		for i in range(k):
			pos = -2
			for i in range(n - 1):
				if a[i] < a[i + 1]:
					pos = i
					break
			ans = pos + 1
			if pos == -2:
				break
			a[pos] += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = 0
	for i in range(k):
		count = False
		for j in range(n - 1):
			if h[j] < h[j + 1]:
				h[j] += 1
				ans = j + 1
				count = True
				break
		if count == False:
			ans = -1
			break
	print(ans)


for _ in range(int(input())):
	(m, l) = map(int, input().split())
	h = list(map(int, input().split()))
	y = 1
	i = 0
	j = 0
	while i < m - 1 and y <= l:
		if h[i] >= h[i + 1]:
			i += 1
		else:
			h[i] += 1
			j = i
			y += 1
			i = 0
	print(-1 if i == m - 1 else j + 1)


def roll(h):
	for i in range(len(h) - 1):
		if h[i] < h[i + 1]:
			h[i] += 1
			return (h, i)
	return (h, -1)
for t in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	for i in range(k):
		(h, ans) = roll(h)
		if ans == -1:
			break
	print(ans if ans == -1 else ans + 1)


import operator
import sys
inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

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

def check_seq(n, k, h):
	max_h = max(h)
	cur_sum = 1
	for h_i in h:
		cur_sum += max_h - h_i
	if cur_sum <= k:
		return -1
	cur_stop = 0
	while True:
		l = 0
		r = 1
		while True:
			if h[l] >= h[r]:
				r += 1
				l += 1
				if r == n:
					return -1
				continue
			else:
				cur_stop = l
				h[l] += 1
				k -= 1
				if k == 0:
					return cur_stop + 1
				break

def main():
	samples = read_one_int()
	for _ in range(samples):
		(n, k) = read_list_of_ints()
		h = read_list_of_ints()
		cur_res = check_seq(n, k, h)
		print(cur_res)
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ans = 0
	i = 0
	m = -1
	while i != n - 1:
		if a[i] < a[i + 1]:
			ans += 1
			a[i] += 1
			if ans == k:
				m = i + 1
			if i > 0:
				i -= 1
		else:
			i += 1
	print(m)


n = int(input())
for i in range(n):
	(height, rocks) = map(int, input().split())
	throwHeight = list(map(int, input().split()))
	throwHeight.append('$')
	for j in range(rocks):
		for k in range(height):
			if throwHeight[k + 1] == '$':
				ans = -1
				break
			elif throwHeight[k] >= throwHeight[k + 1]:
				continue
			elif throwHeight[k] < throwHeight[k + 1]:
				throwHeight[k] = throwHeight[k] + 1
				ans = k + 1
				break
		if ans == -1:
			break
	print(ans)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c1 = 0
	bo = []
	for p in range(k):
		x = 0
		x1 = 0
		for i in range(len(a) - 1):
			if a[i] < a[i + 1]:
				x1 += 1
				a[i] += 1
				x += 1
				break
			else:
				x += 1
		if x == len(a) - 1:
			if x1 == 0:
				c1 += 1
				break
		bo.append(x)
	if c1 > 0:
		print(-1)
	else:
		print(bo[len(bo) - 1])


_ = int(input())
for _i in range(_):
	(n, k) = [int(i) for i in input().split()]
	li = [int(i) for i in input().split()]
	for i in range(k):
		for j in range(n - 1):
			if li[j] >= li[j + 1]:
				continue
			else:
				li[j] += 1
				flag = j + 1
				break
		else:
			print(-1)
			break
	else:
		print(flag)


t = int(input())
for l in range(t):
	(n, k) = map(int, input().split())
	lst = input()
	arr = list(map(int, lst.split(' ')))
	stop = -2
	for i in range(k):
		flg = 0
		for j in range(n - 1):
			if arr[j] < arr[j + 1]:
				stop = j
				arr[j] += 1
				flg = 1
				break
		if flg == 0:
			stop = -2
			break
	print(stop + 1)


x = int(input())
for _ in range(x):
	(n, k) = map(int, input().split())
	mountains = list(map(int, input().split()))
	if k > 10000:
		print(-1)
		continue
	b = False
	i = 0
	for _ in range(k):
		i = 0
		while i < n - 1 and mountains[i] >= mountains[i + 1]:
			i += 1
		if i == n - 1:
			print(-1)
			b = True
			break
		mountains[i] += 1
	if not b:
		print(i + 1)


def some_random_function():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function5():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
import os, sys
from io import BytesIO, IOBase

def solve(n, k, h):
	x = 0
	while 1:
		fl = 0
		for i in range(n - 1):
			if h[i] < h[i + 1]:
				h[i] += 1
				ans = i + 1
				fl = 1
				break
		x += 1
		if not fl:
			return -1
		if x == k:
			return ans

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		h = list(map(int, input().split()))
		print(solve(n, k, h))
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 some_random_function1():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function2():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function3():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function4():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function6():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function7():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function8():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(-1)
	else:
		for j in range(k):
			start = 0
			ok = True
			while start != n - 1:
				if arr[start] >= arr[start + 1]:
					start += 1
					if start == n - 1:
						ok = False
						break
				else:
					arr[start] += 1
					break
			if not ok:
				print(-1)
				break
		if ok:
			print(start + 1)


import sys
from sys import stdin, stdout
import math

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

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

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

def code(n, k, h):
	i = kk = 0
	while i < n - 1:
		if h[i] >= h[i + 1]:
			i += 1
			continue
		else:
			h[i] += 1
			kk += 1
			if kk == k:
				break
			i = 0
	if i == n - 1:
		return -1
	else:
		return i + 1
t = int(input())
for j in range(t):
	(n, k) = get_ints()
	h = get_list()
	ans = code(n, k, h)
	print(ans)


ans = []
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	heights = list(map(int, input().split()))
	min_stck = 200
	strt_ptr = 0
	k_needed = 0
	h_iter = 0
	while h_iter < len(heights) - 1:
		flag = False
		currh = heights[h_iter]
		next_h = heights[h_iter + 1]
		if currh < next_h:
			if next_h <= min_stck or h_iter == 0:
				k_needed += next_h - currh
				heights[h_iter] = next_h
				h_iter += 1
				min_stck = heights[h_iter]
			else:
				k_needed += min_stck + 1 - currh
				heights[h_iter] = min_stck + 1
				h_iter -= 1
				flag = True
		else:
			min_stck = heights[h_iter]
			h_iter += 1
		if k_needed >= k:
			if flag:
				h_iter += 1
			else:
				h_iter -= 1
			break
	if h_iter == len(heights) - 1:
		ans.append(-1)
	else:
		ans.append(h_iter + 1)
for an in ans:
	print(an)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = 100 * n
	s = sum(a)
	f = {}
	st = 0
	while s < d:
		st += 1
		out = True
		for i in range(n - 1):
			if a[i] < a[i + 1]:
				a[i] += 1
				s += 1
				f[st] = i + 1
				out = False
				break
		if out:
			ans = -1
			break
	if k in f:
		print(f[k])
	else:
		print(-1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	maximum = max(h)
	co = 0
	for i in h:
		co += maximum - i
	if k > co:
		print(-1)
	else:
		i = 0
		ans = -1
		for i in range(k):
			result = 0
			for j in range(n - 1):
				if h[j] < h[j + 1]:
					ans = j + 1
					h[j] += 1
					result = 1
					break
			if result == 0:
				ans = -1
		print(ans)