#include #include #include #include #include using namespace std; const int inf = 0x7fffffff; const int Maxn = 100010; int n, ans; int a[Maxn], b[Maxn], bl; int last[Maxn], f[Maxn]; int _max(int x, int y) { return x > y ? x : y; } int main() { int i, j, k, T; scanf("%d", &T); while(T--){ scanf("%d", &n); for(i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i]; sort(b+1, b+n+1); bl = unique(b+1, b+n+1) - (b+1); for(i = 1; i <= bl; i++) last[i] = 0; for(i = 1; i <= n; i++){ int x = lower_bound(b+1, b+bl+1, a[i]) - b; f[i] = _max(f[i-1], f[last[x]]+1); last[x] = i; } printf("%d\n", f[n]); } return 0; }