Problem: You are given an integer array of length .
You can perform the following operation any number of times (possibly zero): take any element of the array , which is at least , delete it, and instead insert the digits that element consisted of in the same position, in order they appear in that element.
For example:
- if we apply this operation to the -rd element of the array , then the array becomes .
- if we apply this operation to the -nd element of the array , then the array becomes .
Your task is to determine whether it is possible to make sorted in non-descending order using the aforementioned operation any number of times (possibly zero). In other words, you have to determine if it is possible to transform the array in such a way that , where is the current length of the array .
Input Format: The first line contains a single integer () — the number of test cases.
Each test case consists of two lines:
- the first line contains a single integer ().
- the second line contains integers ().
Output Format: For each test case, print YES if it is possible to make sorted in non-decreasing order using the aforementioned operation; otherwise, print NO.
You can print each letter in any case. For example, yes, Yes, YeS will all be recognized as a positive answer.
Note: In the first example, you can split the first element, then the array becomes .
In the second example, there is no way to get a sorted array.
In the third example, the array is already sorted.