Skip to content

1799

A_Recent_Actions

Explanation

Explanation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def solve():
    n, m = list(map(int, input().split()))
    posts = list(map(int, input().split()))
    tracked_data = [-1] * n

    last = n - 1
    used_posts = set()
    for moment, post in enumerate(posts, 1):
        if post not in used_posts:
            if last >= 0:
                tracked_data[last] = moment
                last -= 1
                used_posts.add(post)
    print(*tracked_data)


for _ in range(int(input())):
    solve()