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())
rooms = [[int(x) for x in input().split(' ')] for i in range(n)]

rooms_people = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
for i in range(n):
    rooms_people[rooms[i][0]-1][rooms[i][1]-1][rooms[i][2]-1] += rooms[i][3]

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

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

Solution (Python):
a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 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):print('',*a[i][j])
 if i<3:print('

Solution (Python):
field = [[0 for i in range(10)]for i in range (15)]
num = int(input())
for i in range (num):
	b,f,r,v = map(int,input().split())
	field[((b-1)*4)+f-1][(r-1)] += v
for i in range(15):
	if( i % 4 == 3 ):
 		field[i] = ['
for i in range(15):
	field[i] = map(str,field[i])
for i in range(15):
		if not( i % 4 == 3 ):
			print(' '+' '.join(field[i]))
		else:
			print(''.join(field[i]))

Solution (Python):
field = [[0 for i in range(10)]for i in range(15)]
nums = int(input())
for i in range(nums):
	b,f,r,v = map(int,input().split())
	field[(b-1)*4+f-1][r-1] += v
for i in range(15):
	if (i % 4 == 3):
		print('
	else:
		print(' '+' '.join(map(str,field[i])))

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=int(input())
ichi=[0,0,0,0,0,0,0,0,0,0,0,0]
ni=[0,0,0,0,0,0,0,0,0,0,0,0]
san=[0,0,0,0,0,0,0,0,0,0,0,0]
yon=[0,0,0,0,0,0,0,0,0,0,0,0]
go=[0,0,0,0,0,0,0,0,0,0,0,0]
roku=[0,0,0,0,0,0,0,0,0,0,0,0]
nana=[0,0,0,0,0,0,0,0,0,0,0,0]
hachi=[0,0,0,0,0,0,0,0,0,0,0,0]
kyu=[0,0,0,0,0,0,0,0,0,0,0,0]
zyu=[0,0,0,0,0,0,0,0,0,0,0,0]
zyu_ichi=[0,0,0,0,0,0,0,0,0,0,0,0]
zyu_ni=[0,0,0,0,0,0,0,0,0,0,0,0]

while n>0:
    l=input().split()
    b=int(l[0])
    f=int(l[1])
    r=int(l[2])
    v=int(l[3])

    num=3*(b-1)+f

    if num==1:
        ichi[r-1]+=v
    elif num==2:
        ni[r-1]+=v
    elif num==3:
        san[r-1]+=v
    elif num==4:
        yon[r-1]+=v
    elif num==5:
        go[r-1]+=v
    elif num==6:
        roku[r-1]+=v
    elif num==7:
        nana[r-1]+=v
    elif num==8:
        hachi[r-1]+=v
    elif num==9:
        kyu[r-1]+=v
    elif num==10:
        zyu[r-1]+=v
    elif num==11:
        zyu_ichi[r-1]+=v
    else:
        zyu_ni[r-1]+=v
    n=n-1
m=1
A=" "+str(ichi[0])
B=" "+str(ni[0])
C=" "+str(san[0])
D=" "+str(yon[0])
E=" "+str(go[0])
F=" "+str(roku[0])
G=" "+str(nana[0])
H=" "+str(hachi[0])
I=" "+str(kyu[0])
J=" "+str(zyu[0])
K=" "+str(zyu_ichi[0])
L=" "+str(zyu_ni[0])
while m<10:
    A=A+" "+str(ichi[m])
    B=B+" "+str(ni[m])
    C=C+" "+str(san[m])
    D=D+" "+str(yon[m])
    E=E+" "+str(go[m])
    F=F+" "+str(roku[m])
    G=G+" "+str(nana[m])
    H=H+" "+str(hachi[m])
    I=I+" "+str(kyu[m])
    J=J+" "+str(zyu[m])
    K=K+" "+str(zyu_ichi[m])
    L=L+" "+str(zyu_ni[m])
    m=m+1
print(A)
print(B)
print(C)
print("
print(D)
print(E)
print(F)
print("
print(G)
print(H)
print(I)
print("
print(J)
print(K)
print(L)

Solution (Python):
n = int(input())
apart = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for joho in range(n):
    x = [int(i) for i in input().split()]
    apart[x[0]-1][x[1]-1][x[2]-1] += x[3]

for tou in range(4):
    for stair in range(3):
        for room in range(10):
            print(" ",apart[tou][stair][room],sep="",end="")
        print("")
    if tou != 3:
        print("

Solution (Python):
n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
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 e in range(10):
            print(' '+str(a[i][j][e]),end='')
        print()
    if i!=3:
        print('

Solution (Python):
import sys
 
x = []
i = 0
for line in sys.stdin:
    if i==0:
        lx = int(line)
    else:
        x.append([int(i) for i in line.split()])
    i = 1
 
rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]
for e in x:
    i,j,k,l = e
    rooms[i-1][j-1][k-1] += l
 
for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i<len(rb)-1: print '

Solution (Python):

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

for i, tou in enumerate(doms):
    for floor in tou:
        
        for room in floor:
            print(" {}".format(room), end="")
        print()
    if i < 3:
        print("

Solution (Python):

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

for i, tou in enumerate(doms):
    for floor in tou:
        
        for room in floor:
            print(" {}".format(room), end="")
        print("")
    if i < 3:
        print("

Solution (Python):
nums = [[[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 = [int(_) for _ in input().split()]
    nums[b - 1][f - 1][r - 1] += v

is_first = True
for building in nums:
    if not is_first:
        print("
    is_first = False 
    for floor in building:
        for room in floor:
            print(" " + str(room), end = "")
        print()

Solution (Python):
N = int(input())
n = [input().split() for _ in range(N)]

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

def change_room(info):
    info = [int(i) for i in info]
    info_dic = {"all_info": all_info,
                "buil": info[0]-1,
                "loc" : info[1]-1,
                "room": info[2]-1,
                "num" : info[3]}

    exec("all_info[buil][loc][room] += num", info_dic)

for i in n:
    change_room(i)

for num, i in enumerate(all_info):
    for j in i:
        j = [str(i) for i in j]
        print(" " + (" ".join(j)))
    if num < 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 i, building in enumerate(house, 1):
    for floor in building:
        for room in floor:
            print(' {0}'.format(room), end='')
        print()
    if i != 4:
        print('

Solution (Python):


def numinput():
    
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    data = []
    for i in range(4):
        floor = []
        for j in range(3):
            list = []
            for k in range(10):
                list.append(0)
            floor.append(list)
        data.append(floor)
    
    
    n = int(input())
    for i in range(n):
        info = numinput()
        
        
        
        
        data[info[0] - 1][info[1] - 1][info[2] - 1] += info[3]

    
    for i in range(4):
        for j in range(3):
            _str_ = ""
            for k in range(10):
                _str_ += " " + str(data[i][j][k])
            print(_str_)
        if i < 3: print("

if __name__ == "__main__":
    main()

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())
floar = [[[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())
    floar[b-1][f-1][r-1] += v
for i in range(4):
    if(i != 0):
        print('
    for j in range(3):
        print(' ',end="")
        print(*floar[i][j])

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 i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(house[i][j][k]), end='')
        print()
    if i != 4 - 1:
        print("

Solution (Python):
import sys

r_len = 10
f_len = 3
b_len = 4

rooms = [[[0 for x in range(r_len)] for y in range(f_len)] for z in range(b_len)]

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

for i in range(b_len):
	for j in range(f_len):
		for k in range(r_len):
			v = rooms[i][j][k]
			sys.stdout.write(' ' + str(v))
		print()
	if i != b_len - 1:
		print('

Solution (Python):
bfr = [[[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())
    bfr[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(map(str, bfr[b][f])))
    if b != 3:
        print('

Solution (Python):
n = int(input())
lis = {}
X =""
for a in range(1,5):
    for b in range(1,4):
        for c in range(1,11):
            fn = lambda A,B,C,D : lis.setdefault(f"{str(A)} {str(B)} {str(C)}",int(D))
            fn(a,b,c,0)
for x in range(n):
    b, f, r, v = map(int, input().split())
    lis[f"{str(b)} {str(f)} {str(r)}"] += v
for a in range(1,5):
    for b in range(1,4):
        for c in range(1,11):
            X += " " + str(lis[f"{str(a)} {str(b)} {str(c)}"])
        print(X)
        X = ""
    if a == 4:
        break
    print("

Solution (Python):
n=int(input())
S=[]
for i in range(1200):
    S.append(0)

for i in range(n):
    k=input().split()
    b=int(k[0])
    f=int(k[1])
    r=int(k[2])
    v=int(k[3]) 
    S[(b-1)*30+(f-1)*10+r-1]+=v
for i in range(4):
    for j in range(3):
        msg=""
        for t in range(10):
            msg+=" "+str(S[i*30+j*10+t])
        print(msg)
    if i<3:
        print("

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

Solution (Python):

import sys

c = int(input())

a = []
for line in sys.stdin :
    a.append(line)
    c -= 1
    if c == 0 :
        break

for i in range(0, len(a)) :
    a[i] = a[i].strip().split(" ")
    for j in range(0, len(a[i])) :
        a[i][j] = int(a[i][j])

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 a :
    kousya[i[0]-1][i[1]-1][i[2]-1] += i[3]

touc = 0
for tou in kousya :
    for kai in tou :
        for heya in kai :
            print(" " + str(heya), end="")
        print()
    if touc != len(kousya)-1 :
        print("
    touc += 1

Solution (Python):


n = int(input())
houses = 4
floors = 3
rooms = 10

official = [[[0 for k in range(rooms)] for j in range(floors)] for i in range(houses)]


for a in range(n):
    info = [int(x) for x in input().rstrip().split()]
    b = info[0] - 1
    f = info[1] - 1
    r = info[2] - 1
    v = info[3]
    currentFloor = official[b][f]
    
    currentFloor[r] += v



for i in range(houses):
    for j in range(floors):
        for k in range(rooms):
            print(' ' + str(official[i][j][k]), end = '')
        print()
    if i < houses - 1:
        print('

Solution (Python):
a = [[[0 for i in range(10)]for i in range(3)]for i in range(4)]
border = '
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 k in a[i]:
        for l in k:
                print(' {}'.format(l), end ='')
        print()
    if i != 3:
        print(border)

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

Solution (Python):
def main():

    rooms = [[0 for i in range(10)] for j in range(12)]
    x = int(input())
    for _ in range(x):
        b, f, r, v = tuple(map(int, input().split()))
        rooms[(b-1)*3+(f-1)][r-1] += v

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

if __name__ == '__main__':
    main()

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

    for b in range(4):
        for f in range(3):
            print(" " + " ".join(map(str, k[b][f])))
        if b != 3:
            print("

main()

Solution (Python):
import sys

x = []
i = 0
for line in sys.stdin:
    if i==0:
        lx = int(line)
    else:
        x.append([int(i) for i in line.split()])
    i = 1

rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]
for e in x:
    i,j,k,l = e
    rooms[i-1][j-1][k-1] += l

for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i<len(rb)-1: print '

Solution (Python):
rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]

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

for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i < len(rb)-1:
        print '

Solution (Python):
def perl():
        for i in range(4):
                for j in range(3):
                        print "",
                        for k in range (10):
                                print l[i][j][k],
                        print
                if i != 3:
                        print "

n=int(raw_input())
l=[[[0 for k in range(10)]for j in range(3)]for i in range(4)]
for N in range(n):
        e=map(int,raw_input().split())
        b=e[0]-1
        f=e[1]-1
        r=e[2]-1
        l[b][f][r]+=e[3]
perl()

Solution (Python):
from __future__ import division, print_function
from sys import stdin
houses = [[[0] * 10 for _ in range(3)] for _ in range(4)]
separator = '
for _ in range(int(stdin.readline())):
    b, f, r, v = (int(s) for s in stdin.readline().split())
    houses[b-1][f-1][r-1] += v
for i, house in enumerate(houses):
    for floor in house:
        print('', *floor)
    if i < 3:
        print(separator)

Solution (Python):




A=[[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]]
B=[[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]]
C=[[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]]
D=[[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]]
l=[]
N=int(raw_input())
for i in range(N):
    (b,f,r,v)=map(int, raw_input().split())
    if b==1: A[f-1][r-1]+=v
    elif b==2: B[f-1][r-1]+=v
    elif b==3: C[f-1][r-1]+=v
    elif b==4: D[f-1][r-1]+=v

for j in A:
    print ' '+' '.join(map(str, j))
print '
for k in B:
    print ' '+' '.join(map(str, k))
print '
for l in C:
    print ' '+' '.join(map(str, l))
print '
for m in D:
    print ' '+' '.join(map(str, m))

Solution (Python):
a = [] 
for i in xrange(0,4):
    b = []
    for j in xrange(0,3):
        b.append([0]*10)
    a.append(b)
n = int(raw_input())
for i in xrange(0,n):
    b,f,r,v = map(int,raw_input().split())
    a[b-1][f-1][r-1] += v
for i,arr in enumerate(a):
    for j in arr:
        print " "+" ".join(map(str,j))
    if i != len(a)-1:
        print "

Solution (Python):
def main():
    for i in xrange(n):
        b, f, r, v = map(int, raw_input().split())
        x[b-1][f-1][r-1] += v
    for b in range(4):
        for f in range(3):
            print(' ' + ' '.join(map(str,x[b][f])))
        if b != 3:
            print('

n = input()
x = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
main()

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

for b in range(4):
    for f in range(3):
        print(" "+" ".join(map(str, bilding[b][f])))
    if b != 3:
        print("

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

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

Solution (Python):
a = [[[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().strip().split())
    a[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(''.join(' {}'.format(a[b][f][r]) for r in range(10)))
    if b < 3:
        print('

Solution (Python):
check = [[[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())
    check[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {check[i][j][k]}", end="")
        print()
    if i<3:
        print("

Solution (Python):
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

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):
        for k in range(10):
             print(" {}".format(room[i][j][k]),end="")
        print()
    if i!=3:
        print("

Solution (Python):


all_info = [[[0 for x in range(10)] for y in range(3)] for z in range(4)]
ct = int(input())

for i in range(ct):
    building,floor,room_num,people = (int(x) for x in input().split())
    all_info[building-1][floor-1][room_num-1] += people

for i,build in enumerate(all_info):
    for flo in build:
        temp = " " + " ".join(map(str,flo))
        print(temp)
    if i != len(all_info) - 1:
        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] = 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):
S=[]
H=[]
C=[]
D=[]
count=0
for i in range(0,30):
    S.append(0)
    H.append(0)
    C.append(0)
    D.append(0)

n=(int)(input())

for h in range(n):
    b,f,r,v=map(int,input().split())
    if b==1:
        if f==1:
            S[r-1]=S[r-1]+v
        if f==2:
            S[9+r]=S[9+r]+v
        if f==3:
            S[19+r]=S[19+r]+v
    elif b==2:
        if f==1:
            H[r-1]=H[r-1]+v
        if f==2:
            H[9+r]=H[9+r]+v
        if f==3:
            H[19+r]=H[19+r]+v
    elif b==3:
        if f==1:
            C[r-1]=C[r-1]+v
        if f==2:
            C[9+r]=C[9+r]+v
        if f==3:
            C[19+r]=C[19+r]+v
    elif b==4:
        if f==1:
            D[r-1]=D[r-1]+v
        if f==2:
            D[9+r]=D[9+r]+v
        if f==3:
            D[19+r]=D[19+r]+v

for j in range(len(S)):
    if j==10 or j==20:
        print("")
    print(" {0}".format(S[j]),end="")
print("")
print("
for j in range(len(H)):
    if j==10 or j==20:
        print("")
    print(" {0}".format(H[j]),end="")
print("")
print("
for j in range(len(C)):
    if j==10 or j==20:
        print("")
    print(" {0}".format(C[j]),end="")
print("")
print("
for j in range(len(D)):
    if j==10 or j==20:
        print("")
    print(" {0}".format(D[j]),end="")
print("")

Solution (Python):
my_a = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_b = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_c = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_d = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
buildings = [my_a, my_b, my_c, my_d]

n=int(input())


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



for j in range(4):
    for k in range(3):
        for l in range(10):
            print(" ",end="")
            print(buildings[j][k][l], end="")
            
        print()
    if j < 3:
        for m in range(20):
            print("
        print()

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

my_a = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_b = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_c = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_d = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
bs = [my_a, my_b, my_c, my_d]

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

for i in range(len(bs)):
    for j in range(len(bs[0])):
        print(" ", end="")
        tmp_str = [str(i) for i in bs[i][j]]
        print(" ".join(tmp_str))
    if i != len(bs)-1:
        print("

Solution (Python):
n = int(input())
record = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for _ 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("

Solution (Python):
from copy import deepcopy
n = int(input())
b1 = [[0]*10,[0]*10,[0]*10]
b2 = deepcopy(b1)
b3 = deepcopy(b1)
b4 = deepcopy(b1)
answer = [b1,b2,b3,b4]
for i in range(n):
	b,f,r,v = map(int,input().split())
	answer[b-1][f-1][r-1] += v
counter = 0
for k in answer:
	for kk in k:
		kk = list(map(str,kk))
		print(" "," ".join(kk),sep="")
	counter += 1
	if counter != 4:
		print("

Solution (Python):
def decrement(*args):
  return [elm-1 for elm in args]

B,F,R = 4,3,10

a = [[[0 for _ in range(R)]for _ in range(F)]for _ in range(B)]

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

for x in a[0]:
  print('',end=' ')
  print(*x)
print("
for x in a[1]:
  print('',end=' ')
  print(*x)
print("
for x in a[2]:
  print('',end=' ')
  print(*x)
print("
for x in a[3]:
  print('',end=' ')
  print(*x)

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):
    a, b, c, d = map(int,input().split())
    count[a - 1][b - 1][c - 1] += d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(count[i][j][k]) , end="")
        print()
    if i < 3:
        print("

Solution (Python):
lst=[['',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],['
ls1=lst[0]
ls2=lst[1]
ls3=lst[2]
ls4=lst[3]
ls5=lst[4]
ls6=lst[5]
ls7=lst[6]
ls8=lst[7]
ls9=lst[8]
ls10=lst[9]
ls11=lst[10]
ls12=lst[11]
ls13=lst[12]
ls14=lst[13]
ls15=lst[14]
n=int(input())
for i in range(n):
    b,f,r,v=(int(x) for x in input().split())
    if b==1:
        if f==1:
            ls1[r]+=v
        elif f==2:
            ls2[r]+=v
        else:
            ls3[r]+=v
    elif b==2:
        if f==1:
            ls5[r]+=v
        elif f==2:
            ls6[r]+=v
        else:
            ls7[r]+=v
    elif b==3:
        if f==1:
            ls9[r]+=v
        elif f==2:
            ls10[r]+=v
        else:
            ls11[r]+=v
    else:
        if f==1:
            ls13[r]+=v
        elif f==2:
            ls14[r]+=v
        else:
            ls15[r]+=v
for l in lst:
    print(*l)

Solution (Python):
A = [[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]]
B = [[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]]
C = [[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]]
D = [[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]]

x = int(input())
for i in range(x):
  b,f,r,v = map(int, input().split())
  if b == 1:
    A[f-1][r-1] += v
  elif b == 2:
    B[f-1][r-1] += v
  elif b == 3:
    C[f-1][r-1] += v
  else:
    D[f-1][r-1] += v

for i in range(3):
  text = " "
  temp = " ".join(map(str, A[i]))
  text += temp
  print(text)
print("
for i in range(3):
  text = " "
  temp = " ".join(map(str, B[i]))
  text += temp
  print(text)
print("
for i in range(3):
  text = " "
  temp = " ".join(map(str, C[i]))
  text += temp
  print(text)
print("
for i in range(3):
  text = " "
  temp = " ".join(map(str, D[i]))
  text += temp
  print(text)

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())
X = [[[0] * 10 for f in range(3)] for b in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    X[b-1][f-1][r-1] += v
    
count = 0
for b in X:
    for f in b:
        print(' ', end='')
        print(*f)
    if count == 3:
        break
    print('
    count += 1

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

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

i = 0
while 1:
  for floor in buildings[i]:
    residents =""
    for room in floor:
      residents += " " + str(room)
    print(residents)
  i += 1
  if i == 4:
    break 
  else:
    print(space)

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(" "+str(a[i][j][k]),end="")
        print()
    if (i!=3):
        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(" "+str(a[i][j][k]),end="")
        print()
    if (i!=3):
        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(" "+str(a[i][j][k]),end="")
        print()
    if (i!=3):
        print("

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

Solution (Python):
a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 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):print('',*a[i][j])
 if i<3:print('

Solution (Python):
n = int(input())
table = [[[0] * 10 for _ in range(3)] for __ in range(4)]

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

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

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

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

for n,Ai in enumerate(A):
    for ai in Ai:
        for i in ai:
            print("",i,end="")
        print()
    if n==3:
        break
    print("

Solution (Python):
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

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):
        for k in range(10):
            print(" {}".format(room[i][j][k]), end="")
        print()
    if i!=3:
        print("

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