#include <cstdio>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int a, b = 0, c = 0;
    bool f = true;
    for (int i = 0; i < 10; ++i) {
      scanf("%d", &a);
      if (b < a) b = a;
      else if (c < a) c = a;
      else {
        puts("NO");
        f = false;
        break;
      }
    }
    if (f) puts("YES");
  }
}
