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):
members = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

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

for b in range(4):
    if b > 0:
        print("
    for f in range(3):
        print(" " + " ".join(map(str, members[b][f])))

Solution (Python):
x=[[[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=list(map(int,input().split()))
	x[a[0]-1][a[1]-1][a[2]-1]+=a[3]

for i in range(4):
	for j in range(3):
		print(' '+' '.join(map(str,x[i][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):
    table=list(map(int, input().split()))
    tou=table[0]
    kai=table[1]
    ban=table[2]
    nin=table[3]
    if count[tou-1][kai-1][ban-1]<10:
        count[tou-1][kai-1][ban-1]+=nin
for k in range(4):
    for j in range(3):
        for i in range(10):
            print("",count[k][j][i], end="")
        print()
    if k<3:
        for l in range(20):
            print("
        print()

Solution (Python):

house = [[[0 for heya in range(10)] for kai in range(3)] for mune in range(4)] 

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

for mune in range(4):    
    for kai in range(3):
        for heya in range(10):
            print(f' {house[mune][kai][heya]}',end='')
        print()
    if mune < 3:
        print('

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

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

Solution (Python):
A = list([0] * 10 for x in range(3))
B = list([0] * 10 for x in range(3))
C = list([0] * 10 for x in range(3))
D = list([0] * 10 for x in range(3))

official_house = [A, B, C, D]

n = int(input())

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

for i, b in enumerate(official_house):
    for f in b:
        print("", " ".join(map(str, f)))
    if i != len(official_house) - 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
x = 0
for k in range(4):
    if x != 0:
        print("
    x += 1
    for j in range(3):
        for i in range(10):
            print("",count[k][j][i],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 = int(input())
bill = []
for _ in range(4):
    bill.append([[0]*10 for _ in range(3)])


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

for i, b in enumerate(bill):
    for x in b:
        print("", *x)
    if i < 3:
        print("

Solution (Python):
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def SI(): return list(input().split())

def main(N,bfrv):
    ans = [[[0]*10 for _ in range(3)] for _ in range(4)]
    for x in bfrv:
        b,f,r,v = x[0],x[1],x[2],x[3]
        ans[b-1][f-1][r-1] += v
    for i,x in enumerate(ans):
        if i:
            print('
        for y in x:
            print(' ',end='')
            print(*y)
    
N = I()
bfrv = [LI() for _ in range(N)]
main(N,bfrv)

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

Solution (Python):
n = int(input())
build, floors, rooms = (4, 3, 10)

buildings = [[[0 for i in range(rooms)] for j in range(floors)] for k in range(build)]


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

for i in range(4):

    for o in buildings[i]:
        print("", *o, sep=" ")

    if i < 3:
        print("

Solution (Python):
n = int(input())
build, floors, rooms = (4, 3, 10)

buildings = [[[0 for i in range(rooms)] for j in range(floors)] for k in range(build)]


for k in range(n):
    b, f, r, v = map(int, input().split())

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


for n in buildings[0]:
    print("", *n, sep=" ")
print("
for o in buildings[1]:
    print("", *o, sep=" ")
print("
for p in buildings[2]:
    print("", *p, sep=" ")
print("
for q in buildings[3]:
    print("", *q, sep=" ")

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

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

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

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(resident[i][j][k]), end="")
        print()
    if i < 3:
        print("

Solution (Python):
build = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
sep = '
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    build[b-1][f-1][r-1] += v
cnt = 0
for F in build:
    for f in F:
        print(' ', end='')
        f = map(str, f)
        print(' '.join(f))
        cnt += 1
    if cnt <= 10:
        print(sep)

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

board = [[[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())
    board[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        print("", *board[i][j])
    if i < 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())
info = [list(map(int, input().split())) for i in range(n)]
ans = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
count = 0
for i in info:
  ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] += i[3]
  if ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] > 9:
    ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 9
  elif ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] < 0:
        ans[(i[0] - 1)][(i[1] - 1)][(i[2] - 1)] = 0
for j in ans:
  count += 1
  for k in j:
    out = ""
    for l in k:
      out += " " + str(l)
    print(out)
  if count < 4: 
    print("

Solution (Python):
block_1_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_1_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_1_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_2_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_3_floor_3=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_1=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_2=[0,0,0,0,0,0,0,0,0,0]
block_4_floor_3=[0,0,0,0,0,0,0,0,0,0]
for i in range(int(input())):
  b,f,r,v=map(int,input().split())
  if b==1:
    if f==1:
      block_1_floor_1[r-1]+=v
    elif f==2:
      block_1_floor_2[r-1]+=v
    else:
      block_1_floor_3[r-1]+=v
  elif b==2:
    if f==1:
      block_2_floor_1[r-1]+=v
    elif f==2:
      block_2_floor_2[r-1]+=v
    else:
      block_2_floor_3[r-1]+=v
  elif b==3:
    if f==1:
      block_3_floor_1[r-1]+=v
    elif f==2:
      block_3_floor_2[r-1]+=v
    else:
      block_3_floor_3[r-1]+=v
  else:
    if f==1:
      block_4_floor_1[r-1]+=v
    elif f==2:
      block_4_floor_2[r-1]+=v
    else:
      block_4_floor_3[r-1]+=v
print(""," ".join(list(map(str,block_1_floor_1))))
print(""," ".join(list(map(str,block_1_floor_2))))
print(""," ".join(list(map(str,block_1_floor_3))))
print("
print(""," ".join(list(map(str,block_2_floor_1))))
print(""," ".join(list(map(str,block_2_floor_2))))
print(""," ".join(list(map(str,block_2_floor_3))))
print("
print(""," ".join(list(map(str,block_3_floor_1))))
print(""," ".join(list(map(str,block_3_floor_2))))
print(""," ".join(list(map(str,block_3_floor_3))))
print("
print(""," ".join(list(map(str,block_4_floor_1))))
print(""," ".join(list(map(str,block_4_floor_2))))
print(""," ".join(list(map(str,block_4_floor_3))))

Solution (Python):
t1 = [[0 for i in range(10)] for j in range(3)]
t2 = [[0 for i in range(10)] for j in range(3)]
t3 = [[0 for i in range(10)] for j in range(3)]
t4 = [[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:
        t1[f - 1][r - 1] += v
    elif b == 2:
        t2[f - 1][r - 1] += v
    elif b == 3:
        t3[f - 1][r - 1] += v
    else:
        t4[f - 1][r - 1] += v

for i in range(3):
    for j in range(10):
        print("", t1[i][j], end = "")
    print()
print("
for i in range(3):
    for j in range(10):
        print("", t2[i][j], end = "")
    print()
print("
for i in range(3):
    for j in range(10):
        print("", t3[i][j], end = "")
    print()
print("
for i in range(3):
    for j in range(10):
        print("", t4[i][j], end = "")
    print()

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


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

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

Solution (Python):


n = int(input())
data_list = list()
for i in range(n):
    data = list(map(int,input().split()))
    data_list.append(data)

apart = [[0,0,0,0,0,0,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 data in data_list:
    apart[((data[0]-1)*4)+(data[1]-1)][data[2]-1] = apart[((data[0]-1)*4)+(data[1]-1)][data[2]-1] + data[3]

for ridge in apart:
    if str(ridge[0]).isdigit():
        ridge = [str(i) for i in ridge]
        print('',' '.join(ridge))
    else:
        print(ridge)

Solution (Python):
ans1 = []
ans2 = []
ans3 = []
for i in range(4):
    ans1 = []
    ans2 = []
    for j in range(3):
        ans1 = []
        for k in range(10):
            ans1.append(0)
        ans2.append(ans1)
    ans3.append(ans2)

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

for i in range(4):
    for j in range(3):
        print(" ", end="")
        for k in range(9):
            print(ans3[i][j][k], end=" ")
        print(ans3[i][j][9])
    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
fst = 1
for k in count:
    if fst == 1:
        fst = 0
    else:
        print("
    for j in k:
        for i in j:
            print(" " + str(i),end = '')
        print()

Solution (Python):
houses = [
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10],
    [[0]*10,[0]*10,[0]*10]
]
n = int(input())
for a in range(n):
    b,f,r,v = [int(i) for i in input().split()]
    houses[b-1][f-1][r-1] += v

for i,house in enumerate(houses):
    for floor in house:
        print(" "+ " ".join(map(str, floor)))
    if i != len(houses)-1:
        print("

Solution (Python):
a= [[[0]*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())
    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,0,0,0,0,0,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]]

n = int(input())
value = [input() for i in range(n)]

for x in value:
    tower,flore,memo,num = x.split()
    tower = int(tower)
    flore = int(flore)
    memo = int(memo)
    num = int(num)
    if tower == 1:
        a[flore -1][memo -1] += num
    elif tower == 2:
        b[flore -1][memo -1] += num
    elif tower == 3:
        c[flore -1][memo -1] += num
    elif tower == 4:
        d[flore -1][memo -1] += num

for i in a: 
    print(" "+" ".join(map(str,i)))
print("
for i in b:
    print(" "+" ".join(map(str,i)))
print("
for i in c:
    print(" "+" ".join(map(str,i)))
print("
for i in d:
    print(" "+" ".join(map(str,i)))

Solution (Python):
count = int(input())
members = list()
buildings = [[[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,],[0,0,0,0,0,0,0,0,0,0,]],
             [[0,0,0,0,0,0,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(count):
    e = list(map(int,input().split()))
    members.append(e)

for i in range(count):
    buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] += members[i][3]
    
    if buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] > 9:
        buildings[members[i][0]-1][members[i][1]-1][members[i][2]-1] = 9
    
for t in range(4):
    if t >= 1:
        print("
    for f in range(3):
        for s in range(10):
            if s <= 8:
                print(" "+str(buildings[t][f][s]),end="")
            else:
                print(" "+str(buildings[t][f][s]))

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

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

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

person = [[[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())
    person[b - 1][f - 1][r - 1] += v

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

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

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

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

for b in range(4):
    for f in range(3):
        print(' '+ ' '.join(map(str,table[b][f])))
    if b < 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):
    sc = input().split()
    a[int(sc[0]) - 1][int(sc[1]) - 1][int(sc[2]) - 1] += int(sc[3])
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(a[i][j][k]), end = '')
        print('')
    if i != 3:
        print('

Solution (Python):
n = int(input())
L = []
for i in range(n):
    b,f,r,v = map(int, input().split())
    L.append([b,f,r,v])

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] ],

      [ [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0] ],

      [ [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0] ],

      [ [0,0,0,0,0,0,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 j in range(len(L)):
    A[L[j][0]-1][L[j][1]-1][L[j][2]-1] += L[j][3]
for a in range(3):
    for b in range(3):
        print('',*A[a][b])
    print('
for b in range(3):
    print('',*A[3][b])

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 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("

Solution (Python):
n=int(input())
floor=[0 for i in range(10)]
bill=[[0 for i in range(10)] for j in range(3)]
kosha=[[[0 for i in range(10)] for j in range(3)]for k in range(4)]
flag=0

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

for bill in kosha:
    if flag==1: 
        print("
    for floor in bill:
        print(" ",end="")
        print(*floor,)
    flag=1

Solution (Python):
import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

tower = [[[0] * 10 for i in range(3)] for j in range(4)]

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

for i, h in enumerate(tower):
    if i:
        print("
    for r in h:
        print("", *r)

Solution (Python):
def main(inputs):
    outputs = ''
    table = [[[0]*10 for i in range(3)] for i in range(4)]
    for input in inputs:
        b, f, r, v = map(int, input.split())
        table[b-1][f-1][r-1] += v
    for i in range(len(table)):
        if i != 0:
            outputs += '
        for j in range(len(table[i])):
            for r in range(len(table[i][j])):
                outputs += ' {}'.format(str(table[i][j][r]))
            outputs += '\n'
    return outputs


if __name__ == "__main__":
    n = int(input())
    inputs = [input() for i in range(n)]
    print(main(inputs), end='')

Solution (Python):
n = int(input())
info = []
t1 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t2 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t3 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t4 = [[0,0,0,0,0,0,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):
  info.append(list(input().split()))
  info[i] = [int(n) for n in info[i]]

for j in range(len(info)):
  if info[j][0] == 1:
    if info[j][1] == 1:
      t1[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t1[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t1[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 2:
    if info[j][1] == 1:
      t2[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t2[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t2[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 3:
    if info[j][1] == 1:
      t3[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t3[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t3[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 4:
    if info[j][1] == 1:
      t4[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t4[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t4[2][info[j][2]-1] += info[j][3]
  
for k in range(0,3):
  [print(" %d"%i, end="")for i in t1[k]]
  print()
print("
for k in range(0,3):
  [print(" %d"%i, end="")for i in t2[k]]
  print()
print("
for k in range(0,3):
  [print(" %d"%i, end="")for i in t3[k]]
  print()
print("
for k in range(0,3):
  [print(" %d"%i, end="")for i in t4[k]]
  print()

Solution (Python):


counter = [[[0] * 10 for i in range(4)] for k in range(5)]


n = int(input())
for _ in range(n):
    b, f, r, v = list(map(int, input().split()))
    b -= 1
    f -= 1
    r -= 1
    counter[b][f][r] += 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(" {}".format(counter[i][a][b]), end="")
        print()

Solution (Python):
rooms = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
         ]
n = int(input())
for i in range(n):
    b, f, r, v = map(lambda x: int(x), input().split(" "))
    B, F, R = b - 1, f - 1, r - 1
    new = rooms[B][F][R] + v
    rooms[B][F][R] = new < 0 if 0 else new
for i in range(4):
    if 0 < i:
        print("
    for j in range(3):
        print(" " + " ".join(map(lambda x: str(x), rooms[i][j])))

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

n=int(input())

for c in range(n):
    house,floor,room,add=map(int, input().split())
    table[house-1][floor-1][room-1] += add

for d in range(4):
    if d != 0:
        print("
    for e in range(3):
        for f in range(10):
            print(" %d" %(table[d][e][f]), end="")
        print()

Solution (Python):

import sys

n= int(input())


data=[]


for i in range(12):
    tmp=[]
    for j in range(10):
        tmp.append(0)
    data.append(tmp)

for i in range(n):
    tmp = input().split()
    b,f,r,v = list(map(lambda a: int(a), tmp))
    data[(b-1)*3+f-1][r-1]+=v




for i in range(4):
    for j in range(3):
        tmp=""
        for k in range(10):
            tmp+=" "
            tmp+=str(data[i*3+j][k])


        print(tmp)
    if(i!=3):
        print("

Solution (Python):
table = [[[0]*10 for i in range(0, 3)]for j in range(0, 4)]
n = int(input())
for k in range(n):
    h, f, r, v = map(int, input().split())
    table[h-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"%(table[i][a][b]), end="")
        print()

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
d = {}

for i in range(4):
  for j in range(3):
    d.setdefault(i, []).append(j)
    if type(d[i][j]) == int:
      d[i][j] = []
    for k in range(10):
      d[i][j].append(0)

for i in range(len(s)):
  d[int(s[i].split()[0])-1][int(s[i].split()[1])-1][int(s[i].split()[2])-1] += int(s[i].split()[3])

for k,v in d.items():
	if k > 0:
		print('
	for i in v:
		print(' '+' '.join(map(str,i)), end='')
		print()

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

for k in range(4) :
    for j in range(3) :
        line = ""
        for i in range(10) :
            line += " " + str(resid[k][j][i])
        print(line)
    if k == 3 and j == 2 :
        break
    print("

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

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

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

Solution (Python):

ROOMS=10
FLOORS=3
BUILDINGS=4
rooms = [[[0 for i in range(ROOMS)] for j in range(FLOORS)] for k in range(BUILDINGS)]


n = int(input())


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

for i in range(BUILDINGS):
    for j in range(FLOORS):
        for k in range(ROOMS):
            print(" {0}".format(rooms[i][j][k]), end="")
        print()
    if i<BUILDINGS-1:
        print('

Solution (Python):
from collections import defaultdict
n = int(input())
info = defaultdict(int)

def drawbuilding(n):
    for room_num in range(1,4):
        for floor_num in range(1,11):
            print(' '+str(info[f'{[n,room_num,floor_num]}']),end='')
        print()

for _ in range(n):
    tmp = list(map(int,input().split()))
    info[f'{tmp[:3]}'] += tmp[3]
    if info[f'{tmp[:3]}'] < 0:
        info[f'{tmp[:3]}'] = 0

for i in range(1,5):
    drawbuilding(i)
    if i < 4:
        print('

Solution (Python):
t_num = 4
f_num = 3
r_num = 10
m_dict = dict()
for i in range(t_num):
    m_dict.setdefault(i+1,list())
    for j in range(f_num):
        m_dict[i+1].append([0]*r_num)
n = input()

for i in range(int(n)):
    a = input()
    IOinfo = a.split()
    b,f,r,v = IOinfo
    tou = int(b)
    flo = int(f)
    rnm = int(r)
    vis = int(v)
    m_dict[tou][flo-1][rnm-1] = m_dict[tou][flo-1][rnm-1] + vis
else:
    for t in range(t_num):
        for f in range(f_num):
            out_c = ''
            for r in range(r_num):
                v = m_dict[t+1][f][r]
                out_c = '{} {}'.format(out_c,v)
            else:
                print(out_c)
        else:
            if t < t_num-1:
                out_m = '
                print(out_m)

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(" %d" %count[i][j][k], end="")
        print()
    if i < 3:
        print("

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

house = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
        
         [[0, 0, 0, 0, 0, 0, 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 = [int(x) for x in input().split()]
    if house[b-1][f-1][r-1] == 0:
        house[b-1][f-1][r-1] = v
    else:
        house[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(house[b][f][r], end='')
        print()
    if b != 3: 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):
s = [[[0]*10 for i in range (3)] for j in range (4)]
n = int(input())
k = 0
for i in range(n):
    t = list(map(int,input().split()))
    s[t[0]-1][t[1]-1][t[2]-1] = s[t[0]-1][t[1]-1][t[2]-1] + t[3]
for u in s:
    if k == 1:
        print("
    else:
        k = 1
    for v in u:
        for w in v:
            print(" " + str(w),end ="")
        print()

Solution (Python):
n = int(input())
info_l = list(list(map(int, input().split())) for _ in range(n))

rooms = [[[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10],
        [[0]*10, [0]*10, [0]*10]]

for info in info_l:
    b = info[0]
    f = info[1]
    r = info[2]
    v = info[3]
    rooms[b-1][f-1][r-1] += v

cnt = 0
for room in rooms:
    cnt += 1
    for i in room:
        print(' ' + ' '.join(map(str, i)))
    if cnt != 4:
        print('

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

for i, b in enumerate(builds):
    for _b in b:
        print(" ", end="")
        print(*_b)

    if i < 3:
        print("

Solution (Python):
x = int(input())
bs = [list(map(int, input().split())) for i in range(x)]
box = [[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]],
       [[0,0,0,0,0,0,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 b in bs:
    box[b[0]-1][b[1]-1][b[2]-1] += b[3]
for i, b in enumerate(box):
    for bb in b:
        print(" ",end="")
        print(" ".join(map(str,bb)))
    if(i != 3):
        print("

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

for i in range(len(rooms)):
    for j in range(len(rooms[0])):
        for k in range(len(rooms[0][0])):
            print(f' {rooms[i][j][k]}', end='')
        if j!= len(rooms[0])-1:print()
    print()
    if i!=len(rooms)-1:
        print('