Problem:
Official House You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b , f , r and v which represent that v persons entered to room r of f th floor at building b . If v is negative, it means that −v persons left. Assume that initially no person lives in the building. Input In the first line, the number of notices n is given. In the following n lines, a set of four integers b , f , r and v which represents i th notice is given in a line. Output For each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print "####################" (20 '#') between buildings. Constraints  No incorrect building, floor and room numbers are given.  0 ≤ the number of tenants during the management ≤ 9  Sample Input 3
1 1 3 8
3 2 2 7
4 3 8 1 Sample Output 0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0

Solution (Python):
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()

Solution (Python):
BIG_NUM = 2000000000

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

N = int(input())

for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print("
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()

Solution (Python):
n = int(input())

A = [[[0 for i in range(10)]for i in range(3)] for i in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    build = A[b-1]
    build[f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print("", ' '.join(map(str, A[i][j])))
    if i != 3:
        print("

Solution (Python):
n=int(input())
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for kk in range(n):
	b,f,r,v=map(int,input().split())
	count[b-1][f-1][r-1]+=v
for cc in range(4):
	for aa in range(3):
		for bb in range(10):
				print(' '+str(count[cc][aa][bb]),end='')
		print()
	if cc!=3:
		print('

Solution (Python):
n = int(input())
a = list()
for i in range(120):
    a.append(0)
for i in range(n):
    b, f, r, v = map(int, input().split())
    a[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
    if i >= 1:
        print("
    for j in range(3):
        for k in range(10):
            print(' ', end = '')
            print(a[i * 30 + j * 10 + k], end = '')
        print()

Solution (Python):
n = int(input())
a = list()
for i in range(120):
    a.append(0)
for i in range(n):
    b, f, r, v = map(int, input().split())
    a[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
    if i >= 1:
        print("
    for j in range(3):
        for k in range(10):
            print(' ', end = '')
            print(a[i * 30 + j * 10 + k], end = '')
        print()

Solution (Python):
num = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]

n = int(input())
for i in range(n):
  b, f, r, v = map(int, input().split())
  num[b-1][f-1][r-1] += v
  
for b in range(4):
  for f in range(3):
    print(" " + " ".join(map(str, num[b][f])))
  if b < 3:
    print("

Solution (Python):
n = input()
n = int(n)
l = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
  b,f,r,v = input().split()
  b = int(b)
  f = int(f)
  r = int(r)
  v = int(v)
  l[b-1][f-1][r-1]+=v
for i in range(4):
  for j in range(3):
    for k in range(10):
      print("",l[i][j][k],end="")
    print()
  if i == 3:
    break
  print("

Solution (Python):
n=input()
n=int(n)
l=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
    b,f,r,v=input().split()
    b=int(b)
    f=int(f)
    r=int(r)
    v=int(v)
    l[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",l[i][j][k],end="")
        print()
    if i==3:
        break
    print("

Solution (Python):
L = [[[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=map(int,input().split())
    L[b-1][f-1][r-1]+=v
for k in range(4):
    for j in range(3):
        for i in range(10):
            print(" "+str(L[k][j][i]),end="")
        print("")
    if k==3:
        break
    print("

Solution (Python):
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    b, f, r, v = map(int,input().split())
    house[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("

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

n = int(input())

for _ in range(n):
    b, f, r, v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v

sep = ''

for building in buildings:
    if sep:
        print(sep)

    for floor in building:
        print(" "+" ".join([str(x) for x in floor]))

    sep = '

Solution (Python):
table = [[[0]*10 for i in range (3)] for k in range (4)]

N = int(input())

for _ in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add

for i in range(4):
    if i != 0:
        print("

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()

Solution (Python):
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for i in range(n):
   b, f, r, v = map(int, input().split())
   rooms[b-1][f-1][r-1] += v

for i in range(4):
   for j in range(-3, 0):
       print("", *rooms[i][j])
   if i != 3:
       print("

Solution (Python):
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["

Solution (Python):
num=[[[0 for a in range(10)]for a in range(3)]for a in range(4)]

n = int(input())

for a in range(n):
    b,f,r,v = [int(x) for x in input ().split()]
    num[b-1][f-1][r-1] += v

for i in range(4):
    for f in num[i]:
        print(""," ".join([str(x) for x in f]))
    
    if i != 3:
        print("

Solution (Python):
n = int(input())
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)] 

for i in range(n):
  b, f, r, v = map(int,input().split())
  rooms[b-1][f-1][r-1] += v
for b in range(4):
  for f in rooms[b]:
    print('',*f)    
  if b != 3:
    print('

Solution (Python):
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["

Solution (Python):
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(-3, 0):
        print("", *rooms[i][j])
    if i != 3:
        print("

Solution (Python):
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]
 
N = int(input())
 
for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add
 
 
x = 0
 
for i in range(4):
    if x != 0:
        print("
    x += 1
 
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()

Solution (Python):
n = int(input())
kousya =[[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]]]

for i in range(n):
    b,f,r,v = map(int,input().split())
    kousya[b-1][f-1][r-1] = kousya[b-1][f-1][r-1] + v
    if kousya[b-1][f-1][r-1] < 0:
        kousya[b-1][f-1][r-1] = 0

for a in range(4):
    for b in range(3):
        for c in range(10):
            print(" " + str(kousya[a][b][c]),end="")
        print()
    if a < 3:
        print("

Solution (Python):
if __name__ == "__main__":
    building_num = 4
    floor_num = 3
    room_num = 10
    info = [
        [[0] * room_num for floor in range(floor_num)] 
        for building
        in range(building_num)
    ]

    notices_num = int(input())
    for i in range(notices_num):
        b, f, r, n = map(lambda x: int(x), input().split())
        info[b - 1][f - 1][r - 1] += n

    for building in range(building_num):
        for floor in range(floor_num):
            print("".join([f" {elem}" for elem in info[building][floor]]))
        if building != building_num - 1:  
            print("

Solution (Python):
list = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
N=int(input())
for x in range(N):
    a,b,c,d=map(int,input().split())
    list[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {list[i][j][k]}',end="")
        print()
    if int(i)<3: print("

Solution (Python):
n = int(input())
Data = []
buildings =[[ [0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(n):
    b, f, r, v = map(int, input().split())
    Data.append([b,f,r,v])
    buildings[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' '+str(buildings[i][j][k]),end = '')
            
            
        print('')
    if i != 3:
        print('

Solution (Python):
n = int(input())
building_list = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
for _ in range(n):
    b, f, r, v = map(int,input().split())
    building_list[b-1][f-1][r-1] += v

for _b in range(4):
    for _f in range(3):
        for _r in range(10):
            print(' ', end='')
            print(building_list[_b][_f][_r], end='')
        print('')
    if _b != 3:
        print('

Solution (Python):
A=[[[0]*10 for i in range(3)] for j in range(4)]

i=1

numbers=[]
info=[]
u=""   
number_str=input("")
number=int(number_str)

while i <=number:
    x=input()
    numbers=x.split()
    numbers=list(map(int,numbers))
    info.append(numbers)
    i=i+1

for j in info:
    A[j[0]-1][j[1]-1][j[2]-1]=A[j[0]-1][j[1]-1][j[2]-1]+j[3]


for h in range(0,4):
    for i in range(0,3):
        for j in range(0,10):
            u=u+" "+str(A[h][i][j])
        print(u)    
        u=""
    
    if h<3 : 
        print("

Solution (Python):
house = [[[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 = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v

for b in range(4):
    if b:
        print("
    for f in range(3):
        for r in range(10):
            print(" {}".format(house[b][f][r]), end='')
        print()

Solution (Python):
build=[[[0 for k in range(10)] for i in range(3)]for j in range(4)]

n=int(input())

for i in range(n):
    [b,f,r,v]=map(int,input().split())
    build[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' %d' % (build[i][j][k]), end='')
        print()
    if i < 3:
        print('

Solution (Python):
ppl = [[],[],[],[]]
for i in range(4):
    for j in range(3):
        tmp = []
        for k in range(10):
            tmp.append(0)
        ppl[i].append(tmp)
n = int(input())
for i in range(n):
    vals = list(map(int,input().split()))
    ppl[vals[0]-1][vals[1]-1][vals[2]-1] += vals[3]
for i in range(4):
    for j in range(3):
        for k in range(10):
            print (" ", end="")
            print (ppl[i][j][k], end="")
        print ()
    if i != 3:
        for j in range(20):
            print ("
        print ()

Solution (Python):


n = int(input())
rid1 = [[0] * 10 for i in range(3)]
rid2 = [[0] * 10 for i in range(3)]
rid3 = [[0] * 10 for i in range(3)]
rid4 = [[0] * 10 for i in range(3)]
Ridge = [rid1, rid2, rid3, rid4]
for i in range(n):
    b, f, r, v = input().split()
    b = int(b);  f = int(f);  r = int(r);  v = int(v)
    Ridge[b-1][f-1][r-1] += v










for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d" %Ridge[i][j][k], end="")
        print()
    if i != 3:
        print("

Solution (Python):
def main():
	n = int(input())
	d = {}
	for _ in range(n):
		b, f, r, v = map(int, input().split())
		d[(b,f,r)] = d.get((b,f,r),0) + v
	for i in range(1, 5):
		for j in range(1, 4):
			for k in range(1, 11):
				print(' ', d.get((i,j,k), 0), sep='', end='')
			print()
		if i < 4:
			print('

main()

Solution (Python):
room = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(4):
    for j in range(3):
        for k in range(10):
            room[i][j].append(0)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    room[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" "+" ".join(map(str, room[i][j])))
    if i != 3: print("

Solution (Python):
house=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for h in range(n):
 b,f,r,v=map(int,input().split())
 house[b-1][f-1][r-1]=house[b-1][f-1][r-1]+v

for a in range(4):
    for b in range(3):
        for c in range(10):
            print(' ',house[a][b][c],sep='',end='')
        print('',sep='')
    
    if a == 3:
        n=0
    else:
        for d in range(20):
            print('
        print('',sep='')

Solution (Python):
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    a,b,c,d=map(int,input().split())
    house[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("

Solution (Python):
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["

Solution (Python):
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()

Solution (Python):
apartment=[[[0]*10 for i in range(3)] for j in range(4)]
n = int(input())

for loop in range(n):
    b,f,r,v = map(int,input().split())
    apartment[b-1][f-1][r-1] += v

x = 0

for i in range(4):
    if x != 0:
        print("
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(apartment[i][a][b]),end = "")
        print()

Solution (Python):
table= [[ [ 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 = map(int,input().split())
    table[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' ',end='')
            print(table[i][j][k],end='')
        print()
    if i < 3:
        print('

Solution (Python):
n = int(input())
A1 = [[0 for i in range(10)] for j in range(3)]
A2 = [[0 for i in range(10)] for j in range(3)]
A3 = [[0 for i in range(10)] for j in range(3)]
A4 = [[0 for i in range(10)] for j in range(3)]
for i in range(n):
  b, f, r, v = map(int,input().split())
  if b == 1:
    A1[f-1][r-1] = A1[f-1][r-1] + v
  if b == 2:
    A2[f-1][r-1] = A2[f-1][r-1] + v
  if b == 3:
    A3[f-1][r-1] = A3[f-1][r-1] + v
  if b == 4:
    A4[f-1][r-1] = A4[f-1][r-1] + v

for i in range(3):
  print('',' '.join(map(str, A1[i])))
print('
for i in range(3):
  print('',' '.join(map(str, A2[i])))
print('
for i in range(3):
  print('',' '.join(map(str, A3[i])))
print('
for i in range(3):
  print('',' '.join(map(str, A4[i])))

Solution (Python):
room1=[[0 for i in range(10)]for j in range(3)]
room2=[[0 for i in range(10)]for j in range(3)]
room3=[[0 for i in range(10)]for j in range(3)]
room4=[[0 for i in range(10)]for j in range(3)]

n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    if b==1:
        room1[f-1][r-1]+=v
    elif b==2:
        room2[f-1][r-1]+=v
    elif b==3:
        room3[f-1][r-1]+=v
    elif b==4:
        room4[f-1][r-1]+=v

for i in range(3):
    print(" ",end='')
    print(*room1[i])
print("
for i in range(3):
    print(" ",end='')
    print(*room2[i])
print("
for i in range(3):
    print(" ",end='')
    print(*room3[i])
print("
for i in range(3):
    print(" ",end='')
    print(*room4[i])

Solution (Python):
d = {}
n = int(input())
for i in range(n):
    *bfr, v = map(int, input().split())
    d[tuple(bfr)] = d.get(tuple(bfr), 0) + v


for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print(f' {d.get((b, f, r), 0)}', end='')
        print()
    if b != 4:
        print('

Solution (Python):
a = int(input())
case = 0

list1 = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

for i in range(a):
    x = input()
    c = x.split()
    list1[int(c[0])-1][int(c[1])-1][int(c[2])-1] += int(c[3])

aa ="{:2}"*10
q = "
for b in range(4):
    for f in range(3):
        print(aa.format(*list1[b][f]))
    if b != 3:
        print(q)

Solution (Python):
room = [[[0] * 10 for floor in range(3)] for building in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int,input().split())
    room[b-1][f-1][r-1] += v

for j in range(4):
    if j != 0:
        print('
    for k in range(3):
        print('',' '.join(map(str,room[j][k])))

Solution (Python):
tbl = [[[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 =map(int,input().split())
	tbl[b-1][f-1][r-1]+=v



for k in range(4):
	for j in range(3):
		for i in range(10):
			print(f' {tbl[k][j][i]}',end="")
		print()
	if k<3:	
		print("

Solution (Python):
n = int(input())
a = [0]*120
for i in range(n):
    b, f, r, v = map(int, input().split())
    t = (b - 1) * 30 + (f - 1) * 10 + r - 1
    a[t] += v
for i in range(120):
    print(' %d'  % a[i], end="")
    if i % 10 == 9:
        print("")
    if i % 30 == 29 and i < 100:
        for c in range(20):
            print("
        print("")

Solution (Python):
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    a,b,c,d=map(int,input().split())
    house[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("

Solution (Python):
n=int(input())
M={}
l=0
for i in range(4):
    for j in range(3):
        for k in range(10):
            M[(i+1,j+1,k+1)]=0
 
while l<n:
    L=input().split( )
    b=int(L[0])
    f=int(L[1])
    r=int(L[2])
    v=int(L[3])
    M[(b,f,r)]=M[(b,f,r)]+v
    l+=1
 
 
for i in range(4):
    for j in range(3):
        for k in range(10):
            print (f" {M[(i+1,j+1,k+1)]}",end="")
        print()
    if i<3:
        print("

Solution (Python):

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



N = int(input())

for loop in range(N):

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

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

    

for i in range(0,4):
    for j in range(0,3):
        for k in range(0,10):
            print(" %d"%room[i][j][k],end = "")
        print("")
    if i < 3:
        print("

Solution (Python):
data = [[[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()))
    data[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" " + " ".join(map(str,data[i][j])))
    if i < 3:
        print("

Solution (Python):
n = int(input())

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

for _ in range(n):
    b, f, r, v = list(map(int, input().split()))
    data[b-1][f-1][r-1] += v

for b, build in enumerate(data):
    for floor in build:
        for i, man in enumerate(floor):
            if i == 9:
                print(" {}".format(man))
            else:
                print(" {}".format(man), end="")
    if b != 3:
        print("

Solution (Python):
n=int(input())
M={}
l=0
for i in range(4):
    for j in range(3):
        for k in range(10):
            M[(i+1,j+1,k+1)]=0

while l<n:
    L=input().split( )
    b=int(L[0])
    f=int(L[1])
    r=int(L[2])
    v=int(L[3])
    M[(b,f,r)]=M[(b,f,r)]+v
    l+=1


for i in range(4):
    for j in range(3):
        for k in range(10):
            print (f" {M[(i+1,j+1,k+1)]}",end="")
        print()
    if i<3:
        print("

Solution (Python):

LENGTH_1 = 10
LENGTH_2 = 3
LENGTH_3 = 4

list_3d = [[[0 for i in range(LENGTH_1)] for j in range(LENGTH_2)] for k in range(LENGTH_3)]



n = int(input())

for _ in range(n):

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

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



for k in range(LENGTH_3):
    for j in range(LENGTH_2):
        for i in range(LENGTH_1):
            print(f" {list_3d[k][j][i]}", end="")
        print()

    if k != LENGTH_3 - 1:
        print("

Solution (Python):
a=[[[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=map(int, input().split())
  a[b-1][f-1][r-1]+=v
for i in range(4):
  for j in range(3):
    for  k in range(10):
      print("",a[i][j][k],end="")
    print()
  if i != 3:
    print("

Solution (Python):
list = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())

for i in range(n):
    data = input().split()
    list[int(data[0])-1][int(data[1])-1][int(data[2])-1] += int(data[3])

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(f" {list[b][f][r]}", end="")
        print()
    if b < 3:
        print("

Solution (Python):
data = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    data[b - 1][f - 1][r - 1] += v
for index, tower in enumerate(data):
    for floor in tower:
        print(' ' + ' '.join(map(str, floor)))
    if index != 3:
        print('

Solution (Python):
info = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    x = list(map(int, input().split()))
    b = x[0]
    f = x[1]
    r = x[2]
    v = x[3]
    info[b-1][f-1][r-1] = info[b-1][f-1][r-1] + v

a = 1
for i in info:
    for j in i:
        print(" ", end="")
        print(*j)
    if 4 > a:
        print("
    a = a + 1

Solution (Python):
n=int(input())
 
field=[[0 for i in range(20)]for j in range(15)]
 
for i in range(n):
   
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
     
for y in range(15):
   
    for x in range(20):
       
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
     
    print()

Solution (Python):
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
   b,f,r,v=map(int, input().split())
   tou[b-1][f-1][r-1]+=v
 
for i in range(4):
   for j in range(3):
       print(' ', end='')
       print(*tou[i][j])
   if i!=3: print('

Solution (Python):
n=int(input())

field=[[0 for i in range(20)]for j in range(15)]

for i in range(n):
  
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
    
for y in range(15):
  
    for x in range(20):
      
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    
    print()

Solution (Python):
n=int(input())
tou=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
   b,f,r,v=map(int, input().split())
   tou[b-1][f-1][r-1]+=v

for i in range(4):
   for j in range(3):
       print(' ', end='')
       print(*tou[i][j])
   if i!=3: print('

Solution (Python):
n = int(input())
record=[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    record[b-1][f-1][r-1]+=v
for b in range(4):
    for f in record[b]: print(" "+" ".join([str(x) for x in f]))
    if b != 3:
        print("".join(["

Solution (Python):
rooms = [[[0] * 10 for _ in range(3)] for _ in range(4)]

N = int(input())
for _ in range(N):
    b, f, r, v = map(int, input().split())
    rooms[b - 1][f - 1][r - 1] += v

for i, b in enumerate(rooms):
    for f in b:
        print(' ' + ' '.join([str(i) for i in f]))
    if i < len(rooms) - 1:
        print('

Solution (Python):

count = [[[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 = map(int, input().split())
    count[b-1][f-1][r-1] +=  v

for k in range(4):
    if not(ｋ == 0):
        print("
    for j in range(3):
        for i in range(10):
            print(" %d"%(count[k][j][i]), end="")
        print()

Solution (Python):
houses = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]  

n = int(input())

for i in range(n) :
  b,f,r,v = map(int,input().split())
  houses [b - 1][f - 1][r - 1] += v       

for b in range(4):                       
  for f in  houses[b] :                  
    print('',*f)                          
  if b != 3 :                              
    print('

Solution (Python):
n = int(input())
home = [[0 for i in range(20)] for j in range(15)]  
for i in range(n) :
 b, f, r, v = map(int, input().split())
 h = (b - 1) * 4 + f - 1
 w = r * 2 - 1
 s = v
 home[h][w] += s
for y in range(15) :
 for x in range(20) :
   if(y % 4 == 3) :
     home[y][x] = "
   elif(x % 2 == 0) :
     home[y][x] = " "
   print(home[y][x], end = "")
 print()

Solution (Python):
rooms=[ [[0]*10 for i in range(3)] for k in range(4) ]
rooms
      
N=int(input())
for n in range(N):
  b,f,r,v=map(int,input().split())
  rooms[b-1][f-1][r-1] += v

x=0
for i in range(4):
  if x!=0:
    print("
  for a in range(3):
    for b in range(10):
      print(" {:d}".format(rooms[i][a][b]),end="")
    print()
  x=x+1

Solution (Python):
ROOM = [[[0]*10 for i in range(3)] for j in range(4)]

N = int(input())
hensu = []
for x in range(N):
    room = [int(e) for e in input().split()]
    ROOM[room[0]-1][room[1]-1][room[2]-1] += room[3]
    
for y in range(len(ROOM)):
    for z in range(len(ROOM[y])):
        print(" " + " ".join(map(str, ROOM[y][z])))
    if y==3:
        break
    else:
        print("

Solution (Python):





class math:
    
    pi = 3.14159265358979323846264338

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()


class output:
    
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()













A = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
B = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
C = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
D = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]

N = int(input())

for i in range(N):
    inlist = [int(w) for w in input().split()]
    if inlist[0] == 1:
        A[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 2:
        B[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 3:
        C[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 4:
        D[inlist[1]-1][inlist[2]-1] += inlist[3]

for i, array in enumerate([A, B, C, D]):
    for j in array:
        output.list(j)
    if i != 3:
        print("

Solution (Python):
count = [[[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 = map(int,input().split())
    count[b-1][f-1][r-1] += v




for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",end=" ")
            print("%d"%(count[i][j][k]),end="")
        else:
            print()
    else:
        if i < 3:
            print("

Solution (Python):
inCount = int(input())
publicBuilds = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(inCount):
    b, f, r, v = map(int, input().split())
    publicBuilds[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, publicBuilds[b][f])))
        if f > 1 and b < 3:
            print("

Solution (Python):
houses = [[[0 for r in range(10)]for f in range(3)]for b in range(4)]
num = int(input())
for i in range(num):
    b,f,r,v = [int(x) for x in input().split()]
    
    houses[b-1][f-1][r-1] += v


    
for i in range(len(houses)):
    if(i!=0):
        print("
    for j in range(len(houses[i])):
        print(" ",end="")
        print(" ".join(map(str,houses[i][j])))

Solution (Python):
if __name__ == '__main__':
	n = int(input())
	floor = [[[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 = map(int,input().split())
		floor[b-1][f-1][r-1] = floor[b-1][f-1][r-1] + v

	for i in range(4):
		for j in range(3):
			for k in range(10):
				print(" %d" % floor[i][j][k],end="")
			print()
		if i != 3:
			print("

Solution (Python):
a = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
  b, f, r, v = map(int, input().split())
  a[b-1][f-1][r-1] += v
for i in range(4):
  for j in range(3):
    for k in range(10):
      print("", a[i][j][k], end = "")
    print()
  if i != 3:
    print("

Solution (Python):

b_num = 4
f_num = 3
r_num = 10
building = [[[0 for i in range(r_num)] for j in range(f_num)] for k in range(b_num)]


n = int(input())
for _ in range(n):
    b,f,r,v = map(int, input().split())
    building[b-1][f-1][r-1] += v


for b_tmp in range(b_num):
    for f_tmp in range(f_num):
        for r_tmp in range(r_num):
            print(' '+str(building[b_tmp][f_tmp][r_tmp]), end='')
        print('')
    if b_tmp < b_num-1:
        print('