// Arup Guha
// 8/30/2017
// Solution to 2017 UCF Locals Problem: Maximum Non-Overlapping Increasing Subsequences

import java.util.*;

public class mnois {

	public static int n;
	public static int[] seq;
	public static int[][] lis;
	public static int[][] memo;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			n = stdin.nextInt();
			seq = new int[n];
			for (int i=0; i<n; i++) seq[i] = stdin.nextInt();

			// Will pre-comp. lis[i][j] will store length of lis for seq[i..j].
			lis = new int[n][n];
			int max = 0;

			// i is the starting point of the prefix.
			for (int i=0; i<n; i++) {

				// We can always just take this element.
				lis[i][i] = 1;

				// Find the LIS length of seq[i..j]
				for (int j=i+1; j<n; j++) {

					// Run usual DP trying each previous slot as the one to build off of before slot j.
					lis[i][j] = 1;
					for (int k=i; k<j; k++)
						if (seq[k] < seq[j])
							lis[i][j] = Math.max(lis[i][j], lis[i][k]+1);

					max = Math.max(max, lis[i][j]);
				}
			}

			// Store the largest upto here.
			for (int i=0; i<n; i++)
				for (int j=i+1; j<n; j++)
					lis[i][j] = Math.max(lis[i][j-1], lis[i][j]);

			memo = new int[n+1][n+1];
			for (int i=0; i<n+1; i++) Arrays.fill(memo[i], -1);

			// Try each value of k.
			for (int k=1; k<=n; k++) {
				System.out.print(solve(n-1,k));
				if (k < n) System.out.print(" ");
			}
			System.out.println();
		}
	}

	public static int solve(int n, int k) {

		// Base cases.
		if (lis[0][n] < k) return 0;
		if (memo[n][k] != -1) return memo[n][k];

		// Just one LIS.
		int res = lis[0][n];

		// Try each possible ending LIS.
		for (int i=1; i<=n; i++) {
			if (lis[i][n] < k) break;
			res = Math.max(res, lis[i][n]+solve(i-1,k));
		}

		// Store and return.
		memo[n][k] = res;
		return res;
	}
}