import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
/**
 * ??¶?´??????¶???????????????
 * @author B7078
 *
 */
class Exception{
	public static int ex(ArrayList<Integer> parse){
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	}
}
/**
 * ???????????????
 * @author B7078
 *
 */

public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util class Exception{
	public static int ex(ArrayList<Integer> parse){
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	}
} Exception public static int ex(ArrayList<Integer> parse){
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	} ex {
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	} int result = 1; result 1 if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		} parse.get(0)<1 || parse.get(0) > 4 parse.get(0)<1 parse.get(0) parse.get parse 0 1 parse.get(0) > 4 parse.get(0) parse.get parse 0 4 {
			result = 0;
		} result = 0 result 0 if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		} parse.get(1)<1 || parse.get(1) > 3 parse.get(1)<1 parse.get(1) parse.get parse 1 1 parse.get(1) > 3 parse.get(1) parse.get parse 1 3 {
			result = 0;
		} result = 0 result 0 if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		} parse.get(2)<1 || parse.get(2) > 10 parse.get(2)<1 parse.get(2) parse.get parse 2 1 parse.get(2) > 10 parse.get(2) parse.get parse 2 10 {
			result = 0;
		} result = 0 result 0 if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		} parse.get(3)<-9 || parse.get(3) > 9 parse.get(3)<-9 parse.get(3) parse.get parse 3 -9 9 parse.get(3) > 9 parse.get(3) parse.get parse 3 9 {
			result = 0;
		} result = 0 result 0 return result; result ArrayList<Integer> parse parse public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		} Main public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		} main {
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		} Exception ex1 = new Exception(); ex1 new Exception() int b b f f r r v; v int temp; temp int n; n int count = 0; count 0 String str; str ArrayList<String> st = new ArrayList<String>(); st new ArrayList<String>() ArrayList<Integer> parse = new ArrayList<Integer>(); parse new ArrayList<Integer>() int house[][][] = new int[4][3][10]; house new int[4][3][10] 4 3 10 Scanner scan = new Scanner(System.in); scan new Scanner(System.in) n = scan.nextInt() n scan.nextInt() scan.nextInt scan for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			} int a = 0; int a = 0; a 0 a < n a n ++a ++a a { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			} { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			} for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			} int t = 0; int t = 0; t 0 t < 4 t 4 t++ t++ t { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			} { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			} st.add(scan.next()) st.add st scan.next() scan.next scan for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			} int p = count; int p = count; p count p < st.size() p st.size() st.size st ++p ++p p {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			} {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			} str = st.get(p) str st.get(p) st.get st p temp = Integer.parseInt(str) temp Integer.parseInt(str) Integer.parseInt Integer str parse.add(temp) parse.add parse temp if(ex1.ex(parse) == 0){
				System.exit(0);
			} ex1.ex(parse) == 0 ex1.ex(parse) ex1.ex ex1 parse 0 {
				System.exit(0);
			} System.exit(0) System.exit System 0 count += 4 count 4 for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		} b = 1; b = 1 b 1 b<5 b 5 ++b ++b b {
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		} {
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		} for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			} f = 1; f = 1 f 1 f<4 f 4 ++f ++f f {
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			} {
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			} for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				} r = 1; r = 1 r 1 r<11 r 11 ++r ++r r {
					System.out.print(" "+house[b-1][f-1][r-1]);
				} {
					System.out.print(" "+house[b-1][f-1][r-1]);
				} System.out.print(" "+house[b-1][f-1][r-1]) System.out.print System.out System System.out " "+house[b-1][f-1][r-1] " " house[b-1][f-1][r-1] house[b-1][f-1] house[b-1] house b-1 b 1 f-1 f 1 r-1 r 1 System.out.println("") System.out.println System.out System System.out "" if(b<4)System.out.println("####################"); b<4 b 4 System.out.println("####################") System.out.println System.out System System.out "####################" String[] args args public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		} public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		} Main
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
/**
 * ??¶?´??????¶???????????????
 * @author B7078
 *
 */
class Exception{
	public static int ex(ArrayList<Integer> parse){
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	}
}
/**
 * ???????????????
 * @author B7078
 *
 */

public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		}