#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int bTop = 0, cTop = 0;
        for (int j = 0; j < 10; j++) {
            int input;
            cin >> input;
            if (bTop >= cTop) {
                if (input > bTop) {
                    bTop = input;
                } else if (input > cTop) {
                    cTop = input;
                } else {
                    cout << "NO" << endl;
                    break;
                }
            } else {
                if (input > cTop) {
                    cTop = input;
                } else if (input > bTop) {
                    bTop = input;
                } else {
                    cout << "NO" << endl;
                    break;
                }
            }
            if (j == 9) {
                cout << "YES" << endl;
            }
        }
    }
}