Conveyor#4642

Conveyor

1 second
64 megabytes
Very hard

To transport materials from workshop A to workshop B, a conveyor belt is used. Materials are packed in identical containers and placed on the belt sequentially as they are produced in workshop A. Each container has an urgency level for processing in workshop B. To sort the containers by urgency, a buffer is used at the end of the conveyor, just before entering workshop B.

The buffer operates in steps, and at each step, one of the following operations can be performed:

Write a program called PIPELINE that, given a sequence of containers, determines whether it is possible to sort them by urgency using this buffer system.

Input

The first line contains the number of tests . Each of the following lines describes a test and contains an integer (1 \leq K \leq 10\,000)—the number of containers in the sequence, followed by real numbers denoting the urgency levels of the containers as they arrive from workshop A (lower numbers correspond to higher urgency).

Output

For each test, output a single line: output 1 if it is possible to sort the containers by urgency using the described buffer, or 0 otherwise.

Examples

Example 1

Loading
Loading