# coding: utf-8



def showBuilding(buildings):

    for i, tou in enumerate(buildings):

        for wow in tou:

            for room in wow:

                print(' ' + str(room), end='')

            print()

        if i != 3:

            print('####################')





if __name__ == '__main__':

    

    buildings = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

    

    for _ in range(int(input())):

    

        b, f, r, v = map(int, input().split())

    

        if buildings[b - 1][f - 1][r - 1] + v >= 9:

            buildings[b - 1][f - 1][r - 1] = 9

        elif buildings[b - 1][f - 1][r - 1] + v < 0:

            buildings[b - 1][f - 1][r - 1] = 0

        else:

            buildings[b - 1][f - 1][r - 1] += v

    

    showBuilding(buildings)

# coding: utf-8



def showBuilding(mansion):

    for i, building in enumerate(mansion):

        for line in building:

            for room in line:

                print(' ' + str(room), end='')

            print()

        if i != 3:

            print('####################')



def calcMoving(mansion, moving_status):

    b, f, r, v = moving_status

    live_in_person = mansion[b-1][f-1][r-1]

    

    if live_in_person + v >= 9:

        live_in_person = 9

    elif live_in_person + v < 0:

        live_in_person = 0

    else:

        live_in_person += v

    

    mansion[b-1][f-1][r-1] = live_in_person



if __name__ == '__main__':

    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

    

    for _ in range(int(input())):

        calcMoving(mansion, map(int, input().split()))



    showBuilding(mansion)



# coding: utf-8
def showBuilding(buildings):
    for i, tou in enumerate(buildings):
        for wow in tou:
            for room in wow:
                print(" " + str(room), end="")
            print()
        if i != 3:
            print("####################")


if __name__ == "__main__":
    buildings = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    for _ in range(int(input())):
        b, f, r, v = map(int, input().split())
        if buildings[b - 1][f - 1][r - 1] + v >= 9:
            buildings[b - 1][f - 1][r - 1] = 9
        elif buildings[b - 1][f - 1][r - 1] + v < 0:
            buildings[b - 1][f - 1][r - 1] = 0
        else:
            buildings[b - 1][f - 1][r - 1] += v
    showBuilding(buildings)

# coding: utf-8
def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(" " + str(room), end="")
            print()
        if i != 3:
            print("####################")


def calcMoving(mansion, moving_status):
    b, f, r, v = moving_status
    live_in_person = mansion[b - 1][f - 1][r - 1]
    if live_in_person + v >= 9:
        live_in_person = 9
    elif live_in_person + v < 0:
        live_in_person = 0
    else:
        live_in_person += v
    mansion[b - 1][f - 1][r - 1] = live_in_person


if __name__ == "__main__":
    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    for _ in range(int(input())):
        calcMoving(mansion, map(int, input().split()))
    showBuilding(mansion)

-def showBuilding(buildings): -    for i, tou in enumerate(buildings): -        for wow in tou: -            for room in wow: +def showBuilding(mansion): +    for i, building in enumerate(mansion): +        for line in building: +            for room in line: +def calcMoving(mansion, moving_status): +    b, f, r, v = moving_status +    live_in_person = mansion[b - 1][f - 1][r - 1] +    if live_in_person + v >= 9: +        live_in_person = 9 +    elif live_in_person + v < 0: +        live_in_person = 0 +    else: +        live_in_person += v +    mansion[b - 1][f - 1][r - 1] = live_in_person + + -    buildings = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)] +    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)] -        b, f, r, v = map(int, input().split()) -        if buildings[b - 1][f - 1][r - 1] + v >= 9: -            buildings[b - 1][f - 1][r - 1] = 9 -        elif buildings[b - 1][f - 1][r - 1] + v < 0: -            buildings[b - 1][f - 1][r - 1] = 0 -        else: -            buildings[b - 1][f - 1][r - 1] += v -    showBuilding(buildings) +        calcMoving(mansion, map(int, input().split())) +    showBuilding(mansion)