import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

class OfficialHouse {
    // ********************************
    // ?????£?????????
    // ********************************
    int buildingNumber;
    int floorNumber = 3;
    int roomNumber  = 10;
    int[][] residentCount;
    
    // ********************************
    // ?????????????????????
    // ********************************
    OfficialHouse(int bN) {
        // ?£???????????±????
        buildingNumber = bN;
        
        // ??\?±??????????????????????????????????
        residentCount = new int[floorNumber][roomNumber];
        
        // ??????????????\?±??????°??????????????????
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        }
    }
    
    // *******************************
    // ????????????
    // *******************************
    // ??\?±?????????????
    public void managementResident(int fN, int rN, int rC) {
        residentCount[fN-1][rN-1] += rC;
        
        // ??\?±???????0?????????????????´??????0??§??¢??????
        if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        }
        
        // ??\?±???????10?????\??????????????´??????9????????????
        if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        }
    }
    
    // ??\?±?????????¨???
    public void showResidentCount() {
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.lang.Math; Math java.lang public class Main {
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
} Main public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    } main {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    } try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        } Exception e {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        } System.out.println(e) System.out.println System.out System System.out e e.getStackTrace() e.getStackTrace e System.exit(-1) System.exit System -1 1 {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in)); stdReader new BufferedReader(new InputStreamReader(System.in)) String line; line int count = 0; count 0 int n = 0; n 0 OfficialHouse oH1 = new OfficialHouse(1); oH1 new OfficialHouse(1) OfficialHouse oH2 = new OfficialHouse(2); oH2 new OfficialHouse(2) OfficialHouse oH3 = new OfficialHouse(3); oH3 new OfficialHouse(3) OfficialHouse oH4 = new OfficialHouse(4); oH4 new OfficialHouse(4) while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            } (line = stdReader.readLine()) != null (line = stdReader.readLine()) line stdReader.readLine() stdReader.readLine stdReader null {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            } if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                } count == 0 count 0 {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                } n = Integer.parseInt(line) n Integer.parseInt(line) Integer.parseInt Integer line count++ count continue; String[] inData = line.split(" ", 0); inData line.split(" ", 0) line.split line " " 0 int b = Integer.parseInt(inData[0]); b Integer.parseInt(inData[0]) Integer.parseInt Integer inData[0] inData 0 int f = Integer.parseInt(inData[1]); f Integer.parseInt(inData[1]) Integer.parseInt Integer inData[1] inData 1 int r = Integer.parseInt(inData[2]); r Integer.parseInt(inData[2]) Integer.parseInt Integer inData[2] inData 2 int v = Integer.parseInt(inData[3]); v Integer.parseInt(inData[3]) Integer.parseInt Integer inData[3] inData 3 switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                } b case 1: 1 case 1: oH1.managementResident(f, r, v) oH1.managementResident oH1 f r v break; case 2: 2 case 2: oH2.managementResident(f, r, v) oH2.managementResident oH2 f r v break; case 3: 3 case 3: oH3.managementResident(f, r, v) oH3.managementResident oH3 f r v break; case 4: 4 case 4: oH4.managementResident(f, r, v) oH4.managementResident oH4 f r v break; if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                } count == n count n {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                } oH1.showResidentCount() oH1.showResidentCount oH1 System.out.println("####################") System.out.println System.out System System.out "####################" oH2.showResidentCount() oH2.showResidentCount oH2 System.out.println("####################") System.out.println System.out System System.out "####################" oH3.showResidentCount() oH3.showResidentCount oH3 System.out.println("####################") System.out.println System.out System System.out "####################" oH4.showResidentCount() oH4.showResidentCount oH4 count = 0 count 0 continue; count++ count stdReader.close() stdReader.close stdReader String[] args args class OfficialHouse {
    // ********************************
    // ?????£?????????
    // ********************************
    int buildingNumber;
    int floorNumber = 3;
    int roomNumber  = 10;
    int[][] residentCount;
    
    // ********************************
    // ?????????????????????
    // ********************************
    OfficialHouse(int bN) {
        // ?£???????????±????
        buildingNumber = bN;
        
        // ??\?±??????????????????????????????????
        residentCount = new int[floorNumber][roomNumber];
        
        // ??????????????\?±??????°??????????????????
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        }
    }
    
    // *******************************
    // ????????????
    // *******************************
    // ??\?±?????????????
    public void managementResident(int fN, int rN, int rC) {
        residentCount[fN-1][rN-1] += rC;
        
        // ??\?±???????0?????????????????´??????0??§??¢??????
        if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        }
        
        // ??\?±???????10?????\??????????????´??????9????????????
        if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        }
    }
    
    // ??\?±?????????¨???
    public void showResidentCount() {
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        }
    }
} OfficialHouse // ********************************
    // ?????£?????????
    // ********************************
    int buildingNumber; buildingNumber int floorNumber = 3; floorNumber 3 int roomNumber  = 10; roomNumber 10 int[][] residentCount; residentCount // ********************************
    // ?????????????????????
    // ********************************
    OfficialHouse(int bN) {
        // ?£???????????±????
        buildingNumber = bN;
        
        // ??\?±??????????????????????????????????
        residentCount = new int[floorNumber][roomNumber];
        
        // ??????????????\?±??????°??????????????????
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        }
    } OfficialHouse {
        // ?£???????????±????
        buildingNumber = bN;
        
        // ??\?±??????????????????????????????????
        residentCount = new int[floorNumber][roomNumber];
        
        // ??????????????\?±??????°??????????????????
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        }
    } buildingNumber = bN buildingNumber bN residentCount = new int[floorNumber][roomNumber] residentCount new int[floorNumber][roomNumber] floorNumber roomNumber for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        } int f = 0; int f = 0; f 0 f < floorNumber f floorNumber f++ f++ f {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        } {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        } for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            } int r = 0; int r = 0; r 0 r < roomNumber r roomNumber r++ r++ r {
                residentCount[f][r] = 0;
            } {
                residentCount[f][r] = 0;
            } residentCount[f][r] = 0 residentCount[f][r] residentCount[f] residentCount f r 0 int bN bN // *******************************
    // ????????????
    // *******************************
    // ??\?±?????????????
    public void managementResident(int fN, int rN, int rC) {
        residentCount[fN-1][rN-1] += rC;
        
        // ??\?±???????0?????????????????´??????0??§??¢??????
        if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        }
        
        // ??\?±???????10?????\??????????????´??????9????????????
        if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        }
    } managementResident {
        residentCount[fN-1][rN-1] += rC;
        
        // ??\?±???????0?????????????????´??????0??§??¢??????
        if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        }
        
        // ??\?±???????10?????\??????????????´??????9????????????
        if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        }
    } residentCount[fN-1][rN-1] += rC residentCount[fN-1][rN-1] residentCount[fN-1] residentCount fN-1 fN 1 rN-1 rN 1 rC if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        } residentCount[fN-1][rN-1] < 0 residentCount[fN-1][rN-1] residentCount[fN-1] residentCount fN-1 fN 1 rN-1 rN 1 0 {
            residentCount[fN-1][rN] = 0;
        } residentCount[fN-1][rN] = 0 residentCount[fN-1][rN] residentCount[fN-1] residentCount fN-1 fN 1 rN 0 if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        } residentCount[fN-1][rN-1] > 9 residentCount[fN-1][rN-1] residentCount[fN-1] residentCount fN-1 fN 1 rN-1 rN 1 9 {
            residentCount[fN-1][rN] = 9;
        } residentCount[fN-1][rN] = 9 residentCount[fN-1][rN] residentCount[fN-1] residentCount fN-1 fN 1 rN 9 int fN fN int rN rN int rC rC // ??\?±?????????¨???
    public void showResidentCount() {
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        }
    } showResidentCount {
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        }
    } for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        } int f = 0; int f = 0; f 0 f < floorNumber f floorNumber f++ f++ f {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        } {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        } for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            } int r = 0; int r = 0; r 0 r < roomNumber r roomNumber r++ r++ r {
                System.out.print(" " + residentCount[f][r]);
                
            } {
                System.out.print(" " + residentCount[f][r]);
                
            } System.out.print(" " + residentCount[f][r]) System.out.print System.out System System.out " " + residentCount[f][r] " " residentCount[f][r] residentCount[f] residentCount f r System.out.println() System.out.println System.out System System.out public class Main {
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int count = 0;
            int n = 0;
            
            // ????????????????????????????????????
            OfficialHouse oH1 = new OfficialHouse(1);
            OfficialHouse oH2 = new OfficialHouse(2);
            OfficialHouse oH3 = new OfficialHouse(3);
            OfficialHouse oH4 = new OfficialHouse(4);
            
            while((line = stdReader.readLine()) != null) {
                // ****************************************
                // ???????????????????????°
                // ****************************************
                if(count == 0) {
                    n = Integer.parseInt(line);
                    
                    count++;
                    continue;
                }
                // ****************************************
                // ???????????\??????????????????????¨?
                // ****************************************
                String[] inData = line.split(" ", 0);
                // ?£???????
                int b = Integer.parseInt(inData[0]);
                // ???
                int f = Integer.parseInt(inData[1]);
                // ??¨?±???????
                int r = Integer.parseInt(inData[2]);
                // ?????°
                int v = Integer.parseInt(inData[3]);
                
                // ?£?????????§??????
                switch(b) {
                    case 1:
                        oH1.managementResident(f, r, v);
                        break;
                    case 2:
                        oH2.managementResident(f, r, v);
                        break;
                    case 3:
                        oH3.managementResident(f, r, v);
                        break;
                    case 4:
                        oH4.managementResident(f, r, v);
                        break;
                }
                
                if(count == n) {
                    oH1.showResidentCount();
                    System.out.println("####################");
                    oH2.showResidentCount();
                    System.out.println("####################");
                    oH3.showResidentCount();
                    System.out.println("####################");
                    oH4.showResidentCount();
                    
                    count = 0;
                    continue;
                }
                
                count++;
            
            }
            stdReader.close();
        } catch(Exception e) {
            System.out.println(e);
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

class OfficialHouse {
    // ********************************
    // ?????£?????????
    // ********************************
    int buildingNumber;
    int floorNumber = 3;
    int roomNumber  = 10;
    int[][] residentCount;
    
    // ********************************
    // ?????????????????????
    // ********************************
    OfficialHouse(int bN) {
        // ?£???????????±????
        buildingNumber = bN;
        
        // ??\?±??????????????????????????????????
        residentCount = new int[floorNumber][roomNumber];
        
        // ??????????????\?±??????°??????????????????
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                residentCount[f][r] = 0;
            }
        }
    }
    
    // *******************************
    // ????????????
    // *******************************
    // ??\?±?????????????
    public void managementResident(int fN, int rN, int rC) {
        residentCount[fN-1][rN-1] += rC;
        
        // ??\?±???????0?????????????????´??????0??§??¢??????
        if(residentCount[fN-1][rN-1] < 0) {
            residentCount[fN-1][rN] = 0;
        }
        
        // ??\?±???????10?????\??????????????´??????9????????????
        if(residentCount[fN-1][rN-1] > 9) {
            residentCount[fN-1][rN] = 9;
        }
    }
    
    // ??\?±?????????¨???
    public void showResidentCount() {
        for(int f = 0; f < floorNumber; f++) {
            for(int r = 0; r < roomNumber; r++) {
                System.out.print(" " + residentCount[f][r]);
                
            }
            System.out.println();
        }
    }
}