|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|2 초||1024 MB||176||116||22||44.898%|
Recently there was a rumor that on Monday the meat store will actually have some meat. It’s Monday, half past one in the morning. The entire town is already waiting for the store to open. More precisely, there are n people waiting in a line. The people are numbered 1 through n 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 some trick in order to skip to the beginning of the queue. Examples of such tricks include:
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.
The first line of the input file contains an integer t specifying 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 n and e: the number of people and the number of events. The rest of the test case consists of e 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 = 100 and 1 ≤ n, e ≤ 105.
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 opened.
2 3 4 3 1 3 2 7 1 1
In the first example test case, the queue changed as follows:
In the second example test case, person 1 skipping to the front of the queue doesn’t change the queue at all. In particular, the last person in the queue is still person 7.