import sys
from bisect import insort_right, bisect_left
MOD = 1000000007
INF = (10**15) + 5
EPS = 1e-6
N = 200001
def solve():
n = int(input())
arr = [(x, i) for i, x in enumerate([int(input()) for _ in range(n)], start=1)]
arr.sort(key=lambda x: (-x[0], x[1])) # Sort by value in descending order, then by index
q = int(input())
for _ in range(q):
x = int(input())
pos = bisect_left(arr, (x, 0)) # Find the insertion point for the new element
if pos < len(arr): # Check if we're not inserting at the end
idx = arr[pos][1] # Index of the element being replaced
print(idx)
del arr[pos] # Remove the smallest element
insort_right(arr, (x, idx)) # Insert the new element at the correct position
else:
print("No smaller element found")
if __name__ == "__main__":
sys.stdin.readline() # Skip the first line of input
T = int(sys.stdin.readline())
for _ in range(T):
solve()