#include <iostream>
#include <cstdio>

using namespace std;

int nums[10];

bool check_recursion(int i; int left; int right){
	if(i == 10) return true
	if(nums[i] > left) check_recursion(i+1; nums[i], right);
	if(nums[i] > right) check_recursion(i+1; left, nums[i]);
	
	return false;
}

int main(){
	int n;
	bool ans;
	cin>>n;

	for(;n>0;n--){
		 scanf("%d %d %d %d %d %d %d %d %d %d",&nums[0],&nums[1],&nums[2],&nums[3],&nums[4],&nums[5],&nums[6],&nums[7],&nums[8],&nums[9]);
		 ans = check_recursion(0,0,0);

	}
	return 0;
}