Hydraulic Arm

No attempts yetTime limit1sMemory limit256 MB

Problem

A chicken farm ships boxes of eggs to the market. The boxes have different heights, so the loading order matters. The boxes are loaded standing up, sorted from the shortest box to the tallest box.

A hydraulic arm moving boxes between the left belt, the upper shelf, and the right belt

The farm has one hydraulic arm, and the arm performs exactly one of these three actions at a time.

  1. Take the box that has reached the arm on the left belt and put it at the leftmost position of the upper shelf.
  2. Take the leftmost box of the upper shelf and put it at the leftmost position of the right belt.
  3. Take the box that has reached the arm on the left belt and put it at the leftmost position of the right belt.

The shelf is loaded and unloaded only at its leftmost position, so the box placed on the shelf last is the first one to leave it. To keep the line fast, the arm never touches a box that already sits on the right belt.

The boxes on the left belt reach the arm in the order a1,a2,,aNa_1, a_2, \dots, a_N. The arm picks up a1a_1 first and aNa_N last. Each moved box goes to the leftmost position of the right belt, so a box placed earlier stays further to the right. The goal is to move every box to the right belt and end with the tallest box at the far left and the shortest box at the far right. That means the boxes must be placed on the right belt in increasing order of height.

Given the order in which the boxes reach the arm, write a program that decides whether the goal is reachable.

Input

The first line contains the number of test cases TT (1T201 \le T \le 20).

The first line of each test case contains the number of boxes NN (1N100001 \le N \le 10\,000). The second line contains the heights a1,a2,,aNa_1, a_2, \dots, a_N (1aiN1 \le a_i \le N) in the order the arm picks the boxes up. No two boxes have the same height.

Output

For each test case, print the answer on its own line. Print yes if some sequence of actions reaches the goal, and no if none does. Print both words in lowercase.