JAVA
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
for (int k = 0; k < a; k++) {
int t = scanner.nextInt();
int[] dp1 = new int[t + 1];
int[] dp2 = new int[t + 1];
int[] w = new int[t + 1];
for (int i = 1; i <= t; i++) {
w[i] = scanner.nextInt();
dp1[i] = 1;
dp2[i] = 1;
}
for (int i = 1; i <= t; i++) {
int j = i;
while (j-- >= 1) {
if (w[i] > w[j])
dp1[i] = Math.max(dp1[j] + 1, dp1[i]);
if (w[i] < w[j])
dp2[i] = Math.max(dp2[j] + 1, dp2[i]);
}
}
System.out.println(Math.max(Arrays.stream(dp1).max().getAsInt(), Arrays.stream(dp2).max().getAsInt()));
}
}
}