#include<iostream>
using namespace std;
int main()
{
int y;
cin >> y;
for (int ff = 0; ff < y; ff++)
{
int da[2019], da1[2019], n, i = 0, j, l, m;
cin >> n;
for (i = 0; i < n; i++)cin >> da[i];
m = 0;
for (i = 0; i < n; i++) {
l = 0;
for (j = 0; j < i; j++)
{
if (da1[j] > l && da[j] < da[i]) l = da1[j];
}
da1[i] = l + 1;
if (da1[i] > m) m = da1[i];
}
cout << m << endl;
}
return 0;
}