Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.

There are N players with IDs from 1 to N, who are participating in the Javelin throw competition which has two rounds. The first is the qualification round, followed by the final round. The qualification round has gotten over, and you are given the longest distance that each of the N players has thrown as A_{1}, A_{2}, \ldots, A_{N}. Now, the selection process for the final round happens in the following two steps:

1) If the longest throw of a player in the qualification round is greater than or equal to the qualification mark of M cm, they qualify for the final round.

2) If after step 1, less than X players have qualified for the finals, the remaining spots are filled by players who have thrown the maximum distance among the players who have not qualified yet.

You are given the best throws of the N players in the qualification round A_{1}, A_{2}, \ldots, A_{N} and the integers M and X. Print the list of the players who will qualify for the finals in increasing order of their IDs.

------ Input Format ------ 

- The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains three space-separated integers N, M, X.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \dots, A_{N}.

------ Output Format ------ 

- For each test case, print a single line containing K + 1 space-separated integers, where K is the number of players qualified.
- First, print the integer K, then followed by a space, print K space-separated integers ID_{1}, ID_{2}, \dots, ID_{K} where ID_{i} denotes the players' *ID* who qualified for the finals. 
- You have to print the IDs of the qualified players in increasing order.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$2 ≤ X ≤ N ≤ 30$
$5000 ≤ A_{i} ≤ 8000$
$7000 ≤ M ≤ 8000$
- All $A_{i}$-s are distinct

----- Sample Input 1 ------ 
3
3 8000 2
5000 5001 5002
3 5000 2
7999 7998 8000
4 6000 3
5999 5998 6000 6001
----- Sample Output 1 ------ 
2 2 3
3 1 2 3
3 1 3 4
----- explanation 1 ------ 
Test Case $1$: Since no player crosses the qualification mark, they are chosen based on the distance thrown. So player $3$ who has thrown the maximum distance gets selected followed by the player $2$. Now since we have got the required number of players, player $1$ isn't selected.

Test Case $2$: Since all the players cross the qualification mark, they all are selected.

Test Case $3$: The player $3$ and player $4$ cross the qualification mark. So for the third and final spot in the final, the player $1$ is selected since he has the maximum distance thrown amongst the remaining two players.

Difficulty: MEDIUM
Tags: Sorting

Data structures

Implementation

Ad-hoc
Skill types: Sorting

Data structures

Starter code:

Solutions:
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	ans = []
	lvl2 = []
	for i in range(n):
		if lis[i] >= m:
			ans.append(i + 1)
		else:
			lvl2.append((lis[i], i + 1))
	if len(ans) >= x:
		print(len(ans), *ans)
	else:
		lvl2.sort(reverse=True)
		l = [lvl2[i][1] for i in range(x - len(ans))]
		ans += l
		ans.sort()
		print(x, *ans)


(p, o) = (0, 1)
k = int(input())
for z in range(k):
	(n, n1, n2) = map(int, input().split())
	A = list(map(int, input().split()))
	s = []
	for i in range(n):
		if A[i] >= n1:
			s.append(i + 1)
	if len(s) < n2:
		flag = [[A[i], i + 1] for i in range(n) if A[i] < n1]
		flag.sort(key=lambda n2: (n2[0], n2[1]))
		flag = flag[::-1]
		i = 0
		while len(s) < n2:
			s.append(flag[i][1])
			i += 1
	s.sort()
	print(len(s), *s)


test = int(input())
for z in range(test):
	(n, m, x) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = []
	for i in range(n):
		if A[i] >= m:
			ans.append(i + 1)
	if len(ans) < x:
		temp = [[A[i], i + 1] for i in range(n) if A[i] < m]
		temp.sort(key=lambda x: (x[0], x[1]))
		temp = temp[::-1]
		i = 0
		while len(ans) < x:
			ans.append(temp[i][1])
			i += 1
	ans.sort()
	print(len(ans), *ans)


t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = []
	list3 = []
	quali_pl = 0
	for j in range(n):
		if list1[j] >= m:
			list2.append(j + 1)
		else:
			list3.append([list1[j], j + 1])
	quali_pl = len(list2)
	if quali_pl < x:
		list3.sort(reverse=True)
		for j in range(x - quali_pl):
			list2.append(list3[j][1])
	quali_pl = len(list2)
	list2.sort()
	print(quali_pl, end=' ')
	for item in list2:
		print(item, end=' ')
	print()


a = int(input())
for i in range(a):
	(b, c, d) = map(int, input().split())
	e = list(map(int, input().split()))
	f = 0
	h = []
	z = 0
	for i in range(len(e)):
		if e[i] >= c:
			f = f + 1
			h.append(i + 1)
	if f < d:
		for i in range(d - f):
			k = 0
			hh = 0
			for j in range(b):
				if e[j] < c and e[j] > k:
					k = e[j]
					hh = j
			e[hh] = -668888
			h.append(hh + 1)
	if f > d:
		z = f
	else:
		z = d
	print(z, end=' ')
	h.sort()
	print(*h)


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	q = []
	f = []
	for i in range(n):
		if a[i] >= m:
			q.append(i + 1)
		else:
			f.append([a[i], i + 1])
	if len(q) < x:
		f.sort(reverse=True)
		x -= len(q)
		for i in range(x):
			q.append(f[i][1])
	q.sort()
	print(len(q), *q)


t = int(input())
while t > 0:
	(n, m, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list4 = []
	list5 = []
	list6 = []
	for i in range(0, len(list1)):
		if list1[i] >= m:
			list4.append(i + 1)
		elif list1[i] < m:
			list5.append(list1[i])
	if len(list4) < x:
		k = len(list4)
		while k < x:
			if len(list5) > 0:
				maxx = max(list5)
				ind = 0
				for i in range(0, len(list1)):
					if list1[i] == maxx:
						ind = i
						list1[i] = -1
						break
				list4.append(ind + 1)
				list5.remove(maxx)
			k = k + 1
	print(len(list4), end=' ')
	list4.sort()
	for i in list4:
		print(i, end=' ')
	print()
	t = t - 1


for _ in range(int(input())):
	(n, m, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	for i in range(1, n + 1):
		l[i - 1] = [l[i - 1], i]
	l.sort(reverse=True)
	ans = []
	for i in range(x):
		if x > len(ans):
			ans.append(l[i][1])
	while x < len(l) and l[x][0] >= m:
		ans.append(l[x][1])
		x += 1
	ans.sort()
	print(len(ans), *ans)


import sys
for i in range(int(input())):
	(n, m, xx) = map(int, input().split())
	a = list(map(int, sys.stdin.readline().strip().split()))
	selected = []
	x = 0
	a = list(enumerate(a))
	a.sort(key=lambda x: x[1], reverse=True)
	r = []
	x = 0
	while x < n and a[x][1] >= m:
		r += [a[x]]
		x += 1
	if len(r) < xx:
		while len(r) < xx:
			r += [a[x]]
			x += 1
	r.sort(key=lambda x: x[0])
	print(len(r), *[el[0] + 1 for el in r])


t = int(input())
for tstcases in range(t):
	(n, m, x) = map(int, input().split())
	l1 = []
	l2 = []
	count = 0
	A = list(map(int, input().split()))
	for i in range(len(A)):
		if A[i] >= m:
			l1.append(i + 1)
			count += 1
		else:
			l2.append(A[i])
	l2.sort(reverse=True)
	if len(l1) == x:
		print(count, *l1)
	else:
		for j in range(x - len(l1)):
			count += 1
			l1.append(A.index(l2[j]) + 1)
		l1.sort()
		print(count, *l1)


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = {k: v + 1 for (v, k) in enumerate(arr)}
	arr.sort(reverse=True)
	ans = []
	for i in arr:
		if i >= m:
			ans.append(res.get(i))
			x -= 1
		elif x > 0:
			ans.append(res.get(i))
			x -= 1
		else:
			break
	ans.sort()
	print(len(ans), *ans)


T = int(input())
for x in range(T):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = a.copy()
	l.sort(reverse=True)
	ans = []
	nans = []
	for i in range(n):
		if l[i] >= m:
			ans.append(a.index(l[i]) + 1)
		else:
			nans.append(a.index(l[i]) + 1)
	if len(ans) != x:
		for i in range(x - len(ans)):
			ans.append(nans[i])
	ans.sort()
	print(len(ans), *ans, end=' ')
	print()


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	c = []
	for j in range(n):
		if a[j] >= m:
			b.append(j + 1)
		else:
			c.append([a[j], j + 1])
	if len(b) < x:
		c.sort(reverse=True)
		x -= len(b)
		for z in range(x):
			b.append(c[z][1])
	b.sort()
	print(len(b), *b)


tests = int(input())
for i in range(tests):
	(n, m, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	dict1 = {}
	players = 0
	for j in range(n):
		dict1[arr[j]] = j
	ans = []
	sorted_arr = sorted(list(dict1.keys()), reverse=True)
	for j in sorted_arr:
		if players < x or j >= m:
			players += 1
			ans.append(dict1[j] + 1)
	ans.sort()
	print(players, *ans)


for _ in range(int(input())):
	(N, M, X) = map(int, input().split())
	A = list(map(int, input().split()))
	d = {}
	for i in range(N):
		d[A[i]] = i + 1
	totalPlayers = 0
	A.sort()
	A.reverse()
	l = []
	for i in range(N):
		if A[i] >= M:
			l.append(d[A[i]])
			totalPlayers += 1
	if len(l) < X:
		for i in range(len(l), N):
			if totalPlayers == X:
				break
			l.append(d[A[i]])
			totalPlayers += 1
	l.sort()
	print(len(l), end=' ')
	for x in l:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	(n, m, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	an = a.copy()
	an.sort(reverse=True)
	p = []
	q = []
	for i in range(n):
		if an[i] >= m:
			p.append(a.index(an[i]) + 1)
		else:
			q.append(a.index(an[i]) + 1)
	if len(p) != x:
		for i in range(x - len(p)):
			p.append(q[i])
	p.sort()
	print(len(p), *p)


def soln(n, m, x, arr):
	inds = {arr[i]: i + 1 for i in range(n)}
	arr.sort()
	res = []
	while arr and arr[-1] >= m:
		res.append(inds[arr.pop()])
	while arr and len(res) < x:
		res.append(inds[arr.pop()])
	return [len(res)] + sorted(res)
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(*soln(n, m, x, arr))


for _ in range(int(input())):
	(n, mark, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = {}
	for i in range(n):
		b[a[i]] = i + 1
	a.sort()
	c = []
	for i in range(n):
		if a[-1] < mark:
			c = a[n - x:]
			break
		if a[i] >= mark:
			if n - i < x:
				c = a[n - x:]
			else:
				c = a[i:]
			break
	for i in range(len(c)):
		c[i] = b[c[i]]
	c.sort()
	print(len(c), *c)


from sys import stdin
ip = stdin.readline
from operator import itemgetter
for _ in range(int(ip())):
	(n, m, x) = map(int, ip().split())
	li = list(map(int, ip().split()))
	ad = [(i + 1, li[i]) for i in range(n)]
	ad = sorted(ad, key=itemgetter(1))
	ad = ad[::-1]
	ans = []
	for i in ad:
		if i[1] >= m:
			ans.append(i[0])
		elif len(ans) < x:
			ans.append(i[0])
	ans.sort()
	print(len(ans), *ans, sep=' ')


class Node:

	def __init__(self, value, id):
		self.value = value
		self.id = id
		self.left = None
		self.right = None

class BinarySeachTree:

	def __init__(self):
		self.root = None

	def insert(self, value, id):
		new_node = Node(value, id)
		if not self.root:
			self.root = new_node
		else:
			current_node = self.root
			while True:
				if value < current_node.value:
					if current_node.left:
						current_node = current_node.left
					else:
						current_node.left = new_node
						break
				elif current_node.right:
					current_node = current_node.right
				else:
					current_node.right = new_node
					break

	def remove(self, value):
		if not self.root:
			return 'No nodes exist in tree.'
		current_node = self.root
		parent_node = None
		while current_node:
			if value < current_node.value:
				parent_node = current_node
				current_node = current_node.left
			elif value > current_node.value:
				parent_node = current_node
				current_node = current_node.right
			elif value == current_node.value:
				if not current_node.right:
					if not parent_node:
						self.root = current_node.left
					elif current_node.value < parent_node.value:
						parent_node.left = current_node.left
					elif current_node.value > parent_node.value:
						parent_node.right = current_node.left
				elif current_node.right and (not current_node.right.left):
					if not parent_node:
						current_node.right.left = self.root.left
						self.root = current_node.right
					elif current_node.value < parent_node.value:
						current_node.right.left = current_node.left
						parent_node.left = current_node.right
					elif current_node.value > parent_node.value:
						current_node.right.left = current_node.left
						parent_node.right = current_node.right
				elif current_node.right and current_node.right.left:
					replace = current_node.right.left
					replace_parent = current_node.right
					while replace.left:
						replace_parent = replace
						replace = replace.left
					replace_parent.left = replace.right
					replace.left = current_node.left
					replace.right = current_node.right
					if not parent_node:
						self.root = replace
					elif replace.value < parent_node.value:
						parent_node.left = replace
					elif replace.value > parent_node.value:
						parent_node.right = replace
				return 'Removed ' + str(value)
		return 'Node ' + str(value) + ' Not Found'

	def extract_max(self):
		current = self.root
		while current.right:
			current = current.right
		self.remove(current.value)
		return current

	def print(self, current=None):
		if not current:
			current = self.root
		if current.left:
			self.print(current=current.left)
		print(current.value, current.id, end=' ')
		if current.right:
			self.print(current=current.right)
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	d = list(map(int, input().split()))
	k = 0
	a = []
	bst = BinarySeachTree()
	for i in range(len(d)):
		bst.insert(d[i], i)
	while k < len(d):
		max = bst.extract_max()
		if max.value >= m or len(a) < x:
			a.append(max.id + 1)
			k += 1
		else:
			break
	a.sort()
	print(k, end=' ')
	for j in a:
		print(j, end=' ')
	print()


def player_list(N, M, X, tr):
	pl_id = list()
	re = list()
	fre_id = dict()
	mi = min(tr)
	if mi >= M:
		return [i + 1 for i in range(N)]
	for i in range(N):
		fre_id[tr[i]] = i + 1
	tr = sorted(tr, reverse=True)
	c = 0
	for i in range(N):
		if tr[i] >= M:
			pl_id.append(fre_id[tr[i]])
			c += 1
		else:
			re.append(fre_id[tr[i]])
	if c < X:
		for i in range(X - c):
			pl_id.append(re[i])
	return sorted(pl_id)
T = int(input())
for _ in range(T):
	(N, M, X) = list(map(int, input().split()))
	tr = list(map(int, input().split()))
	idq = player_list(N, M, X, tr)
	print(len(idq), *idq)


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	l = list(map(int, input().split()))
	f = list(filter(lambda z: z >= m, l))
	if len(f) < x:
		a = sorted(l)[n - x:]
		res = str(x)
		for i in list(filter(lambda y: y in a, l)):
			res += ' ' + str(l.index(i) + 1)
	else:
		res = str(len(f))
		for j in f:
			res += ' ' + str(l.index(j) + 1)
	print(res)


testCases = int(input())
for testCase in range(testCases):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {k: v + 1 for (v, k) in enumerate(a)}
	a.sort(reverse=True)
	ans = []
	for i in a:
		if i >= m:
			ans.append(d.get(i))
			x -= 1
		elif x > 0:
			ans.append(d.get(i))
			x -= 1
		else:
			break
	ans.sort()
	print(len(ans), *ans)


testCases = int(input())
for testCase in range(testCases):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {k: v + 1 for (v, k) in enumerate(a)}
	q = []
	nq = []
	for i in a:
		if i >= m:
			q.append(i)
		else:
			nq.append(i)
	if len(q) < x:
		l = len(q)
		for i in range(x - l):
			maxi = max(nq)
			q.append(maxi)
			nq.remove(maxi)
		ans = [d.get(i) for i in q]
		ans.sort()
		print(len(q), *ans)
	else:
		ans = [d.get(i) for i in q]
		ans.sort()
		print(len(q), *ans)


t = int(input())
while t != 0:
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	qualified = []
	ids = []
	n = list1[0]
	m = list1[1]
	x = list1[2]
	p = 0
	dic = {}
	for k in range(1, n + 1):
		a = list2[k - 1]
		dic[a] = k
	dic1 = sorted(dic.keys(), reverse=True)
	for k in dic1:
		if k >= m or x > 0:
			qualified.append(k)
			p += 1
			x -= 1
	for k in qualified:
		for (g, h) in dic.items():
			if g == k:
				ids.append(h)
	ids.sort()
	ids.insert(0, p)
	for k in range(p + 1):
		print(ids[k], end=' ')
	print('\n')
	t -= 1


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	arr = list(map(int, input().lstrip().split()))
	li = []
	count = 0
	for i in range(n):
		if arr[i] >= m:
			li.append(i + 1)
			arr.pop(i)
			arr.insert(i, 0)
			count += 1
	if count < x:
		q = max(arr)
		i = 0
		while count != x:
			if i == n:
				i = 0
			elif arr[i] == q and count < x:
				li.append(i + 1)
				arr.pop(i)
				arr.insert(i, 0)
				count += 1
				i += 1
				q = max(arr)
			else:
				i += 1
	li.sort()
	li.insert(0, len(li))
	print(*li, sep=' ')


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	s = list(map(int, input().split()))
	dic = []
	for i in range(n):
		if s[i] >= m:
			dic.append(i + 1)
	if len(dic) < x:
		se = list(enumerate(s))
		se.sort(key=lambda x: x[1], reverse=True)
		rs = x - len(dic)
		for (i, j) in se:
			if rs != 0 and j < m:
				dic.append(i + 1)
				rs -= 1
	dic.sort()
	print(len(dic), *dic)


from math import gcd, sqrt, ceil, floor, log10, log2
from heapq import heapify, heappop, heappush, nsmallest, nlargest
from collections import Counter, deque, OrderedDict, defaultdict
from itertools import combinations, permutations, zip_longest
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
import sys
import time
import string
import operator
RECURSION_LIMIT = int(10000000.0)
INT_MAX = float('inf')
INT_MIN = float('-inf')
MOD = int(1000000000.0) + 7
NEWLINE = '\n'
SPACE = ' '
sys.setrecursionlimit(RECURSION_LIMIT)
inp = lambda fn: fn(input())
inp_vars = lambda fn, delim, convert_to=list: convert_to(map(fn, input().split(delim)))

def inp_graph(n, adj, gtype=0):
	pass

def solve(*args, **kwargs):
	(n, m, x) = args[0]
	arr = args[1]
	mp = {p: val for (p, val) in enumerate(arr, 1) if val >= m}
	if len(mp) >= x:
		return [len(mp)] + sorted(mp.keys())
	x -= len(mp)
	rem = sorted(((p, val) for (p, val) in enumerate(arr, 1) if p not in mp), key=lambda x: x[1])
	return [x + len(mp)] + sorted(list(mp.keys()) + [p for (p, _) in rem[-x:]])

def main(*args, **kwargs):
	for _ in range(int(input())):
		arg2 = inp_vars(int, SPACE)
		arg3 = inp_vars(int, SPACE)
		res = solve(*(arg2, arg3))
		if type(res) in {list, tuple, set}:
			print(*res, sep=' ')
		else:
			print(res)
main()


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = []
	for i in a:
		if i >= m:
			s.append(a.index(i) + 1)
	l = len(s)
	if l >= x:
		s.insert(0, l)
		print(*s)
	else:
		y = []
		for i in a:
			y.append(i)
		t = x - l
		a.sort(reverse=True)
		for i in range(t):
			for j in a:
				if j < m:
					s.append(y.index(j) + 1)
					m = j
					break
		s.sort()
		s.insert(0, len(s))
		print(*s)


t = int(input())
for _ in range(t):
	(n, m, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	ans = []
	for i in range(n):
		if arr[i] >= m:
			ans.append(i + 1)
			arr[i] = -1
	while len(ans) < x:
		ind = 0
		jnd = 0
		while ind < n:
			if arr[ind] > arr[jnd]:
				jnd = ind
			ind += 1
		ans.append(jnd + 1)
		arr[jnd] = -1
	res = []
	res.append(len(ans))
	ans.sort()
	for i in ans:
		res.append(i)
	print(*res)


import collections as clts
import math
import heapq

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

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

def take_input(type='int'):
	if type == 'int':
		return int(input())
	elif type == 'str':
		return input()
	elif type == 'list-int':
		return list(map(int, input().split()))
	elif type == 'list-float':
		return list(map(float, input().split()))
	else:
		return None
for _ in range(int(input())):
	(N, M, X) = take_input('list-int')
	A = take_input('list-int')
	quals = []
	idMap = clts.defaultdict(clts.deque)
	for i in range(N):
		if A[i] >= M:
			quals.append(i + 1)
			A[i] = 0
		idMap[A[i]].append(i + 1)
	if len(quals) < X:
		j = len(quals)
		A = sorted(A, reverse=True)
		i = 0
		while j < X:
			quals.append(idMap[A[i]].popleft())
			i += 1
			j += 1
	quals = sorted(quals)
	quals = list(map(str, quals))
	print(len(quals), ' '.join(quals))


for _ in range(int(input())):
	(n, m, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = {a[i]: i + 1 for i in range(n)}
	c = 0
	s = set()
	ds = sorted(d)
	while ds:
		if ds[-1] >= m:
			ele = ds.pop()
			s.add(d[ele])
			c += 1
		else:
			break
	if c < x:
		while c - x:
			ele = ds.pop()
			s.add(d[ele])
			c += 1
	print(len(s), *sorted(s))


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	b = list(map(int, input().split()))
	a = sorted(b)
	a.reverse()
	i = x
	while i < n and a[i] >= m:
		i += 1
	c = a[i - 1]
	print(i, end=' ')
	for j in range(n):
		if b[j] >= c:
			print(j + 1, end=' ')
	print()


def merge(listt, num):
	for i in range(len(listt)):
		if listt[i] > num:
			new_list = listt[:i] + [num] + listt[i:]
			break
	else:
		new_list = listt + [num]
	return new_list
t = int(input())
for i in range(t):
	x = input()
	x = x.split()
	a = input()
	a = a.split()
	n = int(x[0])
	m = int(x[1])
	X = int(x[2])
	listt = []
	listt2 = []
	for j in range(n):
		if int(a[j]) >= m:
			listt.append(int(a[j]))
		else:
			listt2.append(int(a[j]))
	if len(listt) < X:
		for i in range(len(listt), X):
			listt = merge(listt, max(listt2))
			listt2.remove(max(listt2))
	print(len(listt), end=' ')
	listt2 = []
	for u in listt:
		listt2 = merge(listt2, int(a.index(str(u))))
	for u in listt2:
		print(u + 1, end=' ')
	print()


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	l = list(map(int, input().split()))
	d = {}
	p = []
	for i in range(n):
		d[l[i]] = i + 1
	l.sort(reverse=True)
	for i in range(n):
		if l[i] >= m:
			p.append(d[l[i]])
			x -= 1
		elif x > 0:
			p.append(d[l[i]])
			x -= 1
		else:
			break
	p.sort()
	print(len(p), *p)


t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	gg = []
	for i in range(len(a)):
		gg.append([a[i], i + 1])
	gg.sort(key=lambda x: x[0])
	gg = gg[::-1]
	ans = []
	c = 0
	for i in range(len(gg)):
		c += 1
		if gg[i][0] >= m:
			ans.append(gg[i][1])
		elif c <= x:
			ans.append(gg[i][1])
		elif c == x:
			break
	ans.sort()
	ans.insert(0, len(ans))
	for i in range(len(ans)):
		if i == len(ans) - 1:
			print(ans[i])
		else:
			print(ans[i], end=' ')


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	res = []
	for i in range(n):
		if a[i] >= m:
			res.append([a[i], i + 1])
	if len(res) < x:
		res.extend(sorted(zip(a, range(1, n + 1)), reverse=True)[len(res):x])
	ans = str(len(res)) + ' '
	res = list(zip(*res))[1]
	ans += ' '.join(list(map(str, sorted(list(res)))))
	print(ans)


from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = []
	heap = []
	for (i, j) in enumerate(arr):
		heap.append((-1 * j, i + 1))
	heapify(heap)
	while len(heap):
		(a, b) = heappop(heap)
		if a * -1 >= m or len(res) < x:
			res.append(b)
	res.sort()
	print(len(res), *res)


def solve_case():
	(n, m, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	with_ids = [(x, i + 1) for (i, x) in enumerate(a)]
	answer = []
	for (v, i) in sorted(with_ids, reverse=True):
		if len(answer) < k or v >= m:
			answer.append(i)
	print(len(answer), *sorted(answer))
cases = int(input())
for _ in range(cases):
	solve_case()


q = int(input())
while q > 0:
	q -= 1
	(x, y, z) = list(map(int, input().split()))
	result2 = list(map(int, input().split()))
	result = []
	l = list(result2)
	result3 = []
	count = 0
	l.sort(reverse=True)
	for i in l:
		if i >= y:
			count += 1
			result.append(i)
		else:
			break
	while count < z:
		result.append(l[count])
		count += 1
	for i in result:
		result3.append(result2.index(i) + 1)
	result3.sort()
	print(count, end=' ')
	for i in result3:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	players = [(x, i + 1) for (i, x) in enumerate(a)]
	ans = []
	for (v, i) in sorted(players, reverse=True):
		if len(ans) < x or v >= m:
			ans.append(i)
	print(len(ans), *sorted(ans))


import sys
t = int(input())
while t:
	(n, m, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.insert(0, -1)
	final = []
	i = 0
	for i in range(len(a)):
		if a[i] >= m:
			final.append(i)
	result = len(final)
	if result < x:
		mapping = {}
		check = set(final[:])
		for k in range(1, len(a)):
			if k in check:
				continue
			else:
				mapping[k] = a[k]
		mapping = {k: v for (k, v) in sorted(mapping.items(), key=lambda item: item[1])}
		b = list(mapping.keys()).copy()
		final.extend(b[result - x:])
	final.sort()
	final.insert(0, len(final))
	for item in final:
		print(item, end=' ')
	print()
	t -= 1


t = int(input())
for _ in range(t):
	(n, m, x) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	arr = [0 for i in range(n)]
	res = 0
	d = {}
	for i in range(n):
		if ar[i] >= m:
			res += 1
			arr[i] = ar[i]
		else:
			d[ar[i]] = i
	if res < x:
		for i in sorted(d, reverse=True):
			arr[d[i]] = ar[d[i]]
			res += 1
			if res == x:
				break
	print(res, end=' ')
	for i in range(n):
		if arr[i] > 0:
			print(i + 1, end=' ')
	print()


T = int(input())
for i in range(T):
	(N, M, X) = map(int, input().split())
	A = list(map(int, input().split()))
	l = sorted(A, reverse=True)
	ans = []
	x = 0
	for j in l:
		if j >= M:
			ans.append(A.index(j) + 1)
			X = X - 1
		elif X > 0:
			ans.append(A.index(j) + 1)
			X -= 1
		else:
			break
	ans = sorted(ans)
	print(len(ans), end=' ')
	for k in ans:
		print(k, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	arr = [int(item) for item in input().split()]
	count = 0
	for j in range(n - 1, -1, -1):
		if arr[j] >= m:
			count += 1
			arr[j] = -1
	while x > count:
		pmax = 0
		ind = 0
		for i in range(n):
			if arr[i] > pmax:
				ind = i
				pmax = arr[i]
		arr[ind] = -1
		count += 1
	print(count, end=' ')
	j = 0
	for i in range(n):
		if arr[i] == -1:
			j += 1
			if count > j:
				print(i + 1, end=' ')
			else:
				print(i + 1)


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	arr = sorted(a, reverse=True)
	ans = []
	cx = 0
	for i in arr:
		if i >= m:
			ans.append(a.index(i) + 1)
			x -= 1
		elif x > 0:
			ans.append(a.index(i) + 1)
			x -= 1
		else:
			break
	ans.sort()
	print(len(ans), end=' ')
	for i in ans:
		print(i, end=' ')
	print()


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = sorted(l)
	c = 0
	ans = []
	elem = []
	for i in l:
		if i >= m:
			c += 1
			ans.append(l.index(i) + 1)
			elem.append(i)
	if len(ans) == n:
		ans.sort()
		print(c, ' ', ' '.join((str(i) for i in ans)))
	elif len(ans) < n:
		if len(ans) == 0:
			w = []
			u = s[::-1]
			for i in range(x):
				w.append(l.index(u[i]) + 1)
			w.sort()
			print(len(w), ' ', ' '.join((str(i) for i in w)))
		else:
			z = []
			pos = []
			for i in s:
				if i not in elem:
					z.append(i)
				if i in elem:
					pos.append(l.index(i) + 1)
			sorted_z = sorted(z)[::-1]
			if len(ans) == x:
				y = sorted(pos)
				print(len(y), ' ', ' '.join((str(i) for i in y)))
			elif len(ans) < x:
				s = s[::-1]
				y = []
				for i in range(x):
					y.append(l.index(s[i]) + 1)
				y.sort()
				print(len(y), ' ', ' '.join((str(i) for i in y)))
			elif len(ans) > x:
				w = []
				for i in range(len(elem)):
					w.append(l.index(elem[i]) + 1)
				w.sort()
				print(len(w), ' ', ' '.join((str(i) for i in w)))


from collections import Counter
import operator
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	ans = []
	for i in range(len(a)):
		if a[i] >= m:
			ans.append(i + 1)
			x -= 1
		else:
			b.append([a[i], i + 1])
	if x > 0:
		b.sort()
		j = len(b) - 1
		while x > 0:
			ans.append(b[j][1])
			x -= 1
			j -= 1
	ans.sort()
	print(len(ans), end=' ')
	for i in ans:
		print(i, end=' ')
	print('')


from bisect import *
for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	for i in range(len(a)):
		b.append((-a[i], i + 1))
	b.sort()
	l = bisect(b, (-m, float('inf')))
	la = max(l, x)
	ans = []
	for i in range(la):
		ans.append(b[i][1])
	ans.sort()
	print(len(ans), *ans)


try:
	t = int(input())
	for _ in range(t):
		(p, l, k) = list(map(int, input().split()))
		arr = list(map(int, input().split()))
		iarr = [[arr[i], i + 1] for i in range(p)]
		iarr.sort(reverse=True)
		ans = []
		for i in iarr:
			if i[0] >= l:
				ans.append(i[1])
		d = len(ans)
		if d < k:
			ans.extend([iarr[i][1] for i in range(d, k)])
		ans.sort()
		ans.insert(0, len(ans))
		print(' '.join((str(i) for i in ans)))
except:
	pass


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	li = list(map(int, input().split()))
	dict = {}
	for i in range(n):
		if li[i] in dict:
			continue
		else:
			dict[li[i]] = i + 1
	li.sort()
	final = li[n - x:]
	for i in range(n - x):
		if li[n - x - 1 - i] >= m:
			final.insert(0, li[n - x - 1 - i])
		else:
			break
	temp = []
	print(len(final), end=' ')
	for j in final:
		temp.append(dict[j])
		dict[j] += 1
	temp.sort()
	print(*temp)


t = int(input())
for i in range(t):
	(n, m, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = []
	ans = []
	for i in range(len(a)):
		if a[i] >= m:
			ans.append(i + 1)
			x -= 1
		else:
			b.append([a[i], i + 1])
	if x > 0:
		b.sort()
		j = len(b) - 1
		while x > 0:
			ans.append(b[j][1])
			x -= 1
			j -= 1
	ans.sort()
	print(len(ans), end=' ')
	for i in ans:
		print(i, end=' ')
	print('')


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {a[i]: i for i in range(n)}
	a.sort(reverse=True)
	c = 0
	i = 0
	ans = []
	while c < x or (i < n and a[i] >= m):
		ans.append(d[a[i]] + 1)
		i += 1
		c += 1
	ans.sort()
	print(c, *ans)


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	A = list(map(int, input().split()))[:n]
	b = []
	for i in range(n):
		if A[i] >= m:
			b.append(i + 1)
			A[i] = 0
	while len(b) < x:
		b.append(A.index(max(A)) + 1)
		A[A.index(max(A))] = 0
	b.sort()
	p = []
	p.append(len(b))
	for j in range(len(b)):
		p.append(b[j])
	for x in p:
		print(x, end=' ')
	print(end='\n')


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ids = []
	non = []
	for i in range(n):
		if a[i] >= m:
			ids.append(i + 1)
		else:
			non.append(a[i])
	rem = x - len(ids)
	non.sort(reverse=True)
	for i in range(rem):
		ids.append(a.index(non[i]) + 1)
	ids.sort(reverse=True)
	ids.append(len(ids))
	ids.reverse()
	print(*ids, sep=' ')


test_cases = int(input())
for i in range(test_cases):
	(N, M, X) = map(int, input().split())
	arr = list(map(int, input().split()))
	dictt = {}
	for j in range(1, N + 1):
		dictt[arr[j - 1]] = j
	arr.sort(reverse=True)
	new_arr = []
	k = arr[X - 1]
	r = min(k, M)
	for a in range(N):
		if arr[a] >= r:
			new_arr.append(dictt.get(arr[a]))
	new_arr.sort()
	print(len(new_arr), end=' ')
	for ele in new_arr:
		print(ele, end=' ')
	print('\n')


t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = []
	us = []
	for i in range(len(l)):
		if l[i] >= m:
			s.append(i + 1)
		else:
			us.append(l[i])
	while len(s) < x:
		maxVal = max(us)
		p = l.index(maxVal)
		s.append(p + 1)
		q = us.index(maxVal)
		us.pop(q)
	s.sort()
	print(len(s), end=' ')
	for i in s:
		print(i, end=' ')
	print()