BinCoin
There are employees in the BinCoin company numbered from to . The subordination structure in this company is a rooted tree. In other words:
There is one CEO in the company — the main boss.
Each other employee has exactly one direct superior.
There are no cycles in the subordination structure.
Moreover, due to the inexplicable love of the CEO of BinCoin for all the binary stuff, the subordination structure in the company is a binary rooted tree. That means each employee is directly superior to exactly zero or two other employees.
In the CEO’s opinion, working in this company is almost as dangerous as in mines. So, employees should sign the waiver of claims sometimes. This process happens in the following way. Initially, CEO takes the journal, then recursively the following procedure is performed:
If an employee that holds the journal does not have any subordinates, they sign the waiver in the journal and give it back to their superior. The procedure stops if that was the CEO, who has no superior.
Otherwise
they choose one of two of their direct subordinates uniformly at random and give the journal to one of them;
when they get the journal back, they sign it;
and then they give it to another direct subordinate;
when they get it back again, they give it back to their superior. The procedure stops if that was the CEO, who has no superior.
All random choices are independent.
One day, the CEO realized that they could not remember the subordination tree. Fortunately, they have the journal with records. Each record is a sequence of employees in the order they’ve signed in a journal.
Help CEO restore the subordination tree.
Input
The first line contains two integers and — the number of employees and the number of records in the journal.
Each of the next lines contains a permutation of integers from to — the order of employees in the corresponding record.
It is guaranteed that the input was obtained as described in the statement with a real random choice.
Output
Print integers . If is a CEO, then should be . Otherwise, should be the index of the direct superior of -th employee.
Your output should correspond to a binary rooted tree. If there are several trees satisfying the input, you can output any one of them.