Under construction

Still being built. Things may change

Queue skipping (Easy)

Time limit2sMemory limit1024 MB

Summary
Given the order in which people move to the front of a queue, find the person who is last in line after all moves.
Level

Easy2 of 10

Topics
Array, Simulation
Solved
No attempts yet

Statement

Recently there was a rumor that on Monday the meat store will actually have some meat. It is Monday, half past one in the morning. The entire town is already waiting for the store to open. More precisely, there are nn people waiting in a line. The people are numbered 1 through nn in line order, with person 1 being the one currently closest to the door of the store.

During the next few hours, at some moments one of the people will use a trick to skip to the beginning of the queue. Examples of such tricks include:

  • Look over there, isn't that [famous TV show host]?
  • Please let me through, I'm with a small child!
  • I stood here before, I just went to the bathroom.
  • Hey, look at that guy trying to skip the queue, I'll go and throw him out!

You are given the sequence of people skipping to the front of the queue. After all those events, the meat store will open. People will enter the store one at a time. Inside, they will learn that the meat didn't arrive (again!), so they will go home empty-handed.

Find out who will waste the most time waiting for nothing. In other words, find out who will be the last person in the queue after all the skipping to the front is over.

Input

The first line of the input contains an integer tt, the number of test cases. Each test case is preceded by a blank line.

Each test case starts with a line containing two positive integers nn and ee: the number of people and the number of events. The rest of the test case consists of ee lines, each containing a single positive integer: the number of a person who just moved to the front of the queue.

You may assume that t=100t = 100 and 1≤n,e≤1001 \le n, e \le 100.

Output

For each test case, output a single line with a single positive integer: the number of the last person in the queue when the meat store opens.

Hint

In the first test case, the queue changes as follows:

  • at the beginning: (1,2,3)
  • person 3 skips to the front: (3,1,2)
  • person 1 skips to the front: (1,3,2)
  • person 3 skips to the front again: (3,1,2)
  • person 2 skips to the front: (2,3,1)
  • thus, the last person at the end is person 1.

In the second test case, person 1 skipping to the front of the queue doesn't change the queue at all. The last person in the queue is still person 7.

Examples1

  1. Example 1

    Input
    2
    
    3 4
    3
    1
    3
    2
    
    7 1
    1
    
    Expected output
    1
    7