import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    private final static String SEPARATOR = "####################";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    }
} import java.io.InputStreamReader; InputStreamReader java.io import java.io.LineNumberReader; LineNumberReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
    private final static String SPACE = " ";
    private final static String SEPARATOR = "####################";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    }
} Main private final static String SPACE = " "; SPACE " " private final static String SEPARATOR = "####################"; SEPARATOR "####################" public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } main {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } catch (Exception e) {
            System.exit(-1);
        } Exception e {
            System.exit(-1);
        } System.exit(-1) System.exit System -1 1 {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in)); stdReader new LineNumberReader(
                    new InputStreamReader(System.in)) String sStr; sStr int n = 0; n 0 ArrayList<Room> allRooms = new ArrayList<Room>(); allRooms new ArrayList<Room>() int[] blocks = { 1, 2, 3, 4 }; blocks { 1, 2, 3, 4 } 1 2 3 4 int[] floors = { 1, 2, 3 }; floors { 1, 2, 3 } 1 2 3 int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; rooms { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } 1 2 3 4 5 6 7 8 9 10 for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            } int block blocks {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            } {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            } for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                } int floor floors {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                } {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                } for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    } int room rooms {
                        allRooms.add(new Room(block, floor, room));
                    } {
                        allRooms.add(new Room(block, floor, room));
                    } allRooms.add(new Room(block, floor, room)) allRooms.add allRooms new Room(block, floor, room) while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            } (sStr = stdReader.readLine()) != null (sStr = stdReader.readLine()) sStr stdReader.readLine() stdReader.readLine stdReader null {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            } if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                } stdReader.getLineNumber() == 1 stdReader.getLineNumber() stdReader.getLineNumber stdReader 1 {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                } String[] inputs = sStr.split(" "); inputs sStr.split(" ") sStr.split sStr " " n = Integer.valueOf(inputs[0]) n Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                } stdReader.getLineNumber() > 1 stdReader.getLineNumber() stdReader.getLineNumber stdReader 1 {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                } String[] inputs = sStr.split(SPACE); inputs sStr.split(SPACE) sStr.split sStr SPACE int b = Integer.parseInt(inputs[0]); b Integer.parseInt(inputs[0]) Integer.parseInt Integer inputs[0] inputs 0 int f = Integer.parseInt(inputs[1]); f Integer.parseInt(inputs[1]) Integer.parseInt Integer inputs[1] inputs 1 int r = Integer.parseInt(inputs[2]); r Integer.parseInt(inputs[2]) Integer.parseInt Integer inputs[2] inputs 2 int v = Integer.parseInt(inputs[3]); v Integer.parseInt(inputs[3]) Integer.parseInt Integer inputs[3] inputs 3 Room target = new Room(b, f, r); target new Room(b, f, r) for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    } Room room allRooms {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    } {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    } if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        } target.equals(room) target.equals target room {
                            room.updateNumOfRoommate(v);
                        } room.updateNumOfRoommate(v) room.updateNumOfRoommate room v if (stdReader.getLineNumber() > n)
                        break; stdReader.getLineNumber() > n stdReader.getLineNumber() stdReader.getLineNumber stdReader n break; int count = 0; count 0 for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            } Room r allRooms {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            } {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            } count ++ count System.out.print(SPACE + r.getNumOfRoommate()) System.out.print System.out System System.out SPACE + r.getNumOfRoommate() SPACE r.getNumOfRoommate() r.getNumOfRoommate r if (count % 10 == 0)   System.out.println(); count % 10 == 0 count % 10 count 10 0 System.out.println() System.out.println System.out System System.out if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR); count % 30 == 0 && count !=120 count % 30 == 0 count % 30 count 30 0 count !=120 count 120 System.out.println(SEPARATOR) System.out.println System.out System System.out SEPARATOR stdReader.close() stdReader.close stdReader String[] args args public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    } Room private int numOfRoommate=0; numOfRoommate 0 private int block; block private int roomNo; roomNo private int floor; floor /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        } updateNumOfRoommate {
            this.numOfRoommate = this.numOfRoommate + v;
        } this.numOfRoommate = this.numOfRoommate + v this.numOfRoommate this this.numOfRoommate this.numOfRoommate + v this.numOfRoommate this this.numOfRoommate v int v v @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        } toString {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        } return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]"; "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]" floor ", floor=" roomNo ", roomNo=" "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]" "Room [block=" block ", roomNo=" roomNo ", floor=" floor "]" @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        } hashCode {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        } final int prime = 31; prime 31 int result = 1; result 1 result = prime * result + block result prime * result + block prime * result prime result block result = prime * result + floor result prime * result + floor prime * result prime result floor result = prime * result + roomNo result prime * result + roomNo prime * result prime result roomNo return result; result @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        } equals {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        } if (this == obj)
                return true; this == obj this obj return true; true if (obj == null)
                return false; obj == null obj null return false; false if (getClass() != obj.getClass())
                return false; getClass() != obj.getClass() getClass() getClass obj.getClass() obj.getClass obj return false; false Room other = (Room) obj; other (Room) obj if (block != other.block)
                return false; block != other.block block other.block other other.block return false; false if (floor != other.floor)
                return false; floor != other.floor floor other.floor other other.floor return false; false if (roomNo != other.roomNo)
                return false; roomNo != other.roomNo roomNo other.roomNo other other.roomNo return false; false return true; true Object obj obj Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        } Room {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        } this.block = block this.block this this.block block this.floor = floor this.floor this this.floor floor this.roomNo = roomNo this.roomNo this this.roomNo roomNo int block block int floor floor int roomNo roomNo public int getNumOfRoommate() {
            return numOfRoommate;
        } getNumOfRoommate {
            return numOfRoommate;
        } return numOfRoommate; numOfRoommate public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        } setNumOfRoommate {
            this.numOfRoommate = numOfRoommate;
        } this.numOfRoommate = numOfRoommate this.numOfRoommate this this.numOfRoommate numOfRoommate int numOfRoommate numOfRoommate public int getBlock() {
            return block;
        } getBlock {
            return block;
        } return block; block public void setBlock(int block) {
            this.block = block;
        } setBlock {
            this.block = block;
        } this.block = block this.block this this.block block int block block public int getRoomNo() {
            return roomNo;
        } getRoomNo {
            return roomNo;
        } return roomNo; roomNo public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        } setRoomNo {
            this.roomNo = roomNo;
        } this.roomNo = roomNo this.roomNo this this.roomNo roomNo int roomNo roomNo public int getFloor() {
            return floor;
        } getFloor {
            return floor;
        } return floor; floor public void setFloor(int floor) {
            this.floor = floor;
        } setFloor {
            this.floor = floor;
        } this.floor = floor this.floor this this.floor floor int floor floor public class Main {
    private final static String SPACE = " ";
    private final static String SEPARATOR = "####################";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    }
} public class Main {
    private final static String SPACE = " ";
    private final static String SEPARATOR = "####################";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    }
} Main
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    private final static String SPACE = " ";
    private final static String SEPARATOR = "####################";
    
    public static void main(String[] args) {
        try {
            LineNumberReader stdReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            int n = 0;

            
            // ??¬?????????????????§???????????????.
            ArrayList<Room> allRooms = new ArrayList<Room>();
            int[] blocks = { 1, 2, 3, 4 };
            int[] floors = { 1, 2, 3 };
            int[] rooms = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int block : blocks) {
                for (int floor : floors) {
                    for (int room : rooms) {
                        allRooms.add(new Room(block, floor, room));
                    }
                }
            }

            while ((sStr = stdReader.readLine()) != null) {
                
                // ????????????????????????
                if (stdReader.getLineNumber() == 1) {
                    String[] inputs = sStr.split(" ");
                    n = Integer.valueOf(inputs[0]);
                }
                
                // 2????????\??????????????????
                if (stdReader.getLineNumber() > 1) {
                    String[] inputs = sStr.split(SPACE);
                    int b = Integer.parseInt(inputs[0]);
                    int f = Integer.parseInt(inputs[1]);
                    int r = Integer.parseInt(inputs[2]);
                    int v = Integer.parseInt(inputs[3]);
                    
                    // ??´??°????±??????¬?????????????????§????????????????????¨???.
                    Room target = new Room(b, f, r);
                    
                    for (Room room: allRooms) {
                        if (target.equals(room)) {
                            room.updateNumOfRoommate(v);
                        }
                    }
                    
                    if (stdReader.getLineNumber() > n)
                        break;
                }
            }


            // ??¨?????????????????????????????????????????????????????????
            int count = 0;
            for (Room r : allRooms) {
                count ++;
                System.out.print(SPACE + r.getNumOfRoommate());
                if (count % 10 == 0)   System.out.println();
                if (count % 30 == 0 && count !=120)   System.out.println(SEPARATOR);
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static class Room {
        private int numOfRoommate=0;
        private int block;
        private int roomNo;
        private int floor;

        /**
         * 
         * @param v ?¢??????°?????\???.
         */
        public void updateNumOfRoommate(int v) {
            this.numOfRoommate = this.numOfRoommate + v;
        }

        @Override
        public String toString() {
            return "Room [block=" + block + ", roomNo=" + roomNo + ", floor="
                    + floor + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + block;
            result = prime * result + floor;
            result = prime * result + roomNo;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Room other = (Room) obj;
            if (block != other.block)
                return false;
            if (floor != other.floor)
                return false;
            if (roomNo != other.roomNo)
                return false;
            return true;
        }

        Room(int block, int floor, int roomNo) {
            this.block = block;
            this.floor = floor;
            this.roomNo = roomNo;
        }
        
        public int getNumOfRoommate() {
            return numOfRoommate;
        }
        public void setNumOfRoommate(int numOfRoommate) {
            this.numOfRoommate = numOfRoommate;
        }
        public int getBlock() {
            return block;
        }
        public void setBlock(int block) {
            this.block = block;
        }
        public int getRoomNo() {
            return roomNo;
        }
        public void setRoomNo(int roomNo) {
            this.roomNo = roomNo;
        }
        public int getFloor() {
            return floor;
        }
        public void setFloor(int floor) {
            this.floor = floor;
        }
    }
}