Rails#1776

Rails

2 seconds
128 megabytes
Very easy

There is a famous railway station in PopPush City. The country where this city is located is incredibly hilly. The station was built in the last century. Unfortunately, funds were extremely limited at that time, so it was possible to build only a single railway track. Moreover, it turned out the station could only be a dead-end one (see picture), and due to lack of available space it could have only one track.

prb1776

The local tradition is that every train arriving from direction A continues in the direction B, with its coaches reordered in some way. Suppose that every train coming from direction A has (1 \leq n \leq 1000) coaches numbered in increasing order 1, 2, \ldots, n. The chief responsible for coach reorganization must know whether it is possible to marshal the coaches so that in direction B their order will be a_1, a_2, \ldots, a_n. Help him by writing a program that determines whether the required coach rearrangement is possible. You can assume that single coaches can be disconnected from the train before entering the station and can move until they are all on the track in direction B. At any time, any number of coaches can be in the station. However, once a coach has entered the station, it cannot return to direction A, and if it has left to direction B, it cannot return back to the station.

Input

The input consists of several blocks. Each block except the last describes one train and possibly several requirements for its reorganization. The first line of each block contains an integer . Each of the next lines contains a permutation of 1, 2, \ldots, n. The last line of a block contains just .

The last block consists of a single line containing .

Output

For each input line containing a permutation, print Yes if the required rearrangement is possible, otherwise print No. After printing answers for all the rearrangements in each block, print an empty line. Print nothing for the last terminal-zero block.

Examples

\begin{example}\exmp{51 2 3 4 55 4 1 2 3066 5 4 3 2 100}{YesNo

Yes

}\end{example}

Example 1

Loading
Loading