import java.util.*;
public class Main {
static LinkedHashMap<Character,Integer> tm = new LinkedHashMap<>();;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int weight = 10;
int[] w = {2,2,6,5,4};
int[] v = {6,3,5,4,6};
int[][] F = new int[v.length+1][weight+1];
for (int i = 1; i <= v.length; i++) {
for (int j = 0; j <= weight; j++) {
if(j >= w[i-1]){
F[i][j] = Math.max(F[i-1][j-w[i-1]]+v[i-1],F[i-1][j]);
}else{
F[i][j] = F[i-1][j];
}
}
}
for (int i = 0; i <= v.length; i++) {
for (int j = 0; j < weight+1; j++) {
System.out.print(F[i][j]+" ");
}
System.out.println("\n");
}
}
}