s = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())

for i in range(n):

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

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

for b in range(4):

    for f in range(3):

        print((" " + " ".join(map(str, s[b][f]))))

    if b != 3:

        print(("#"*20))
n = int(input())

ans = ""



room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):

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

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

    

for i in range(4):

    for j in range(3):

        for k in range(10):

            ans += " %d" % (room[i][j][k])

        print(ans)

        ans = ""

    if i != 3:

        print("#"*20)

    
s = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    s[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print((" " + " ".join(map(str, s[b][f]))))
    if b != 3:
        print(("#" * 20))

n = int(input())
ans = ""
room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    room[b - 1][f - 1][r - 1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            ans += " %d" % (room[i][j][k])
        print(ans)
        ans = ""
    if i != 3:
        print("#" * 20)

-s = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] +ans = "" +room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] -    s[b - 1][f - 1][r - 1] += v -for b in range(4): -    for f in range(3): -        print((" " + " ".join(map(str, s[b][f])))) -    if b != 3: -        print(("#" * 20)) +    room[b - 1][f - 1][r - 1] += v +for i in range(4): +    for j in range(3): +        for k in range(10): +            ans += " %d" % (room[i][j][k]) +        print(ans) +        ans = "" +    if i != 3: +        print("#" * 20)