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):
import sys


def main():
    n = int(sys.stdin.readline())
    notices = []
    for i in range(n):
        notices.append(tuple(map(int, sys.stdin.readline().split())))
    buildings = [[[0] * 10 for i in range(3)] for j in range(4)]
    for b, f, r, v in notices:
        buildings[b-1][f-1][r-1] += v
    separator = '
    for index, building in enumerate(buildings):
        for floor in building:
            print(' ' + ' '.join(map(str, floor)))
        if index != len(buildings)-1:
            print(separator)
    return


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[[[0 for _ in range(10)]for _ in range(3)]for _ 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 bb in range(4):
    for ff in range(3):
        print(*[""]+a[bb][ff])
    if bb==3:
        break
    else:
        print("

Solution (Python):
n=int(input())
start=[[[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=[int(i) for i in input().split()]
    start[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(start[i][j][k],end="")
        print()
    if i<=2:
        for m in range(20):
            print("
        print()

Solution (Python):

bil_date = []
flag = 0
for i in range(4):
    bil_date.append([[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]])
all_date_amo = int(input())
for i in range(all_date_amo):
    date = [int(indate) for indate in input().split()]
    bil_date[date[0]-1][date[1]-1][date[2]-1] = bil_date[date[0]-1][date[1]-1][date[2]-1] + date[3]
    if bil_date[date[0]-1][date[1]-1][date[2]-1] < 0:
        bil_date[date[0]-1][date[1]-1][date[2]-1] = 0
    if bil_date[date[0]-1][date[1]-1][date[2]-1] > 9:
        bil_date[date[0]-1][date[1]-1][date[2]-1] = 9
        
for bil in bil_date:
    for flo in bil:
        for room in flo:
            print(' {}'.format(room),end='')
        print('')
    if flag == 3:
        pass
    else:
        for i in range(20):
            print('
        print('')
    flag = flag + 1

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):
num = input()
L = []
house = []
for i in range(int(num)):
    k = input().split()
    k[0] = int(k[0])
    k[1] = int(k[1])
    k[2] = int(k[2])
    k[3] = int(k[3])
    L.append(k)

for i in range(3):
    a = ["","0","0","0","0","0","0","0","0","0","0"]
    b = ["","0","0","0","0","0","0","0","0","0","0"]
    c = ["","0","0","0","0","0","0","0","0","0","0"]
    d = ["
    house.append([a,b,c,d])

a = ["","0","0","0","0","0","0","0","0","0","0"]
b = ["","0","0","0","0","0","0","0","0","0","0"]
c = ["","0","0","0","0","0","0","0","0","0","0"]
house.append([a,b,c])

for i in L:
    house[i[0]-1][i[1]-1][i[2]] = str(int(house[i[0]-1][i[1]-1][i[2]])+i[3])

for i in house:
    for j in i:
        k = " ".join(j)
        print(k)

Solution (Python):


def showBuilding(buildings):
    for i, tou in enumerate(buildings):
        for wow in tou:
            for room in wow:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('


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

Solution (Python):


def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('

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

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

    showBuilding(mansion)

Solution (Python):


def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('

if __name__ == '__main__':
    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(int(input())):
        b, f, r, v = map(int, input().split())
        mansion[b-1][f-1][r-1] += v

    showBuilding(mansion)

Solution (Python):


def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('

if __name__ == '__main__':
    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(int(input())):
        b, f, r, v = map(int, input().split())
        mansion[b-1][f-1][r-1] += v

    showBuilding(mansion)

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


a = [["


for value in values:
    b, f, r, v = map(int, value)
    a[4 * b + f - 5][r - 1] += v


for i in range(15):
    row_output = ""
    for j in range(10):
        if i > 0 and i % 4 == 3:
            row_output += "
        else:
            row_output += " " + str(a[i][j])
    print(row_output)

Solution (Python):
array = [[10*[0] for _ in [0]*3] for _ in [0]*4]
n = int(input())
for _ in range(n):
    a,b,c,d = map(int,input().split())
    array[a-1][b-1][c-1] += d
for i in range(4):
    for j in range(3): print('',*array[i][j])
    if i<3: print('

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

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

Solution (Python):
university = [[[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())
    university[b - 1][f - 1][r - 1] += v
c1 = c2 = 0
for building  in university:
    c2 = 0
    for floor in building:
        for room in floor:
            print(' {}'.format(room), end = '')
        if c2 != 2:
            print('')
        c2 += 1
    if c1 != 3:
        print('\n
    c1 += 1
print('')

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

n = int(input())

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

for i, d in enumerate(a):
    for c in d: print("", *c)
    if i != len(a) - 1:
        print("

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


def printstate(billdings):
    """
    for billnum, billding in enumerate(billdings):
        for flooor in billding:
            for room in flooor:
                print(" {}".format(room), end="")
            print()
        print("
    """
    for i in range(len(billdings)):
        for j in range(len(billdings[0])):
            for k in range(len(billdings[0][0])):
                print(" "+str(billdings[i][j][k]), end="")
            print()
        if i != len(billdings)-1:
            print("


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

printstate(billdings)

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):
_1_1=[]
_1_2=[]
_1_3=[]
_2_1=[]
_2_2=[]
_2_3=[]
_3_1=[]
_3_2=[]
_3_3=[]
_4_1=[]
_4_2=[]
_4_3=[]
for i in range(10):
    _1_1.append(0)
    _1_2.append(0)
    _1_3.append(0)
    _2_1.append(0)
    _2_2.append(0)
    _2_3.append(0)
    _3_1.append(0)
    _3_2.append(0)
    _3_3.append(0)
    _4_1.append(0)
    _4_2.append(0)
    _4_3.append(0)
N=int(input())
s=[input() for i in range(N)]
bfrv=[]
for i in s:
    bfrv.append(i.split())
for i in bfrv:
    if int(i[0])==1 and int(i[1])==1:
        _1_1[int(i[2])-1]+=int(i[3])
    elif int(i[0])==1 and int(i[1])==2:
        _1_2[int(i[2])-1]+=int(i[3])
    elif int(i[0])==1 and int(i[1])==3:
        _1_3[int(i[2])-1]+=int(i[3])
    elif int(i[0])==2 and int(i[1])==1:
        _2_1[int(i[2])-1]+=int(i[3])
    elif int(i[0])==2 and int(i[1])==2:
        _2_2[int(i[2])-1]+=int(i[3])
    elif int(i[0])==2 and int(i[1])==3:
        _2_3[int(i[2])-1]+=int(i[3])
    elif int(i[0])==3 and int(i[1])==1:
        _3_1[int(i[2])-1]+=int(i[3])
    elif int(i[0])==3 and int(i[1])==2:
        _3_2[int(i[2])-1]+=int(i[3])
    elif int(i[0])==3 and int(i[1])==3:
        _3_3[int(i[2])-1]+=int(i[3])
    elif int(i[0])==4 and int(i[1])==1:
        _4_1[int(i[2])-1]+=int(i[3])
    elif int(i[0])==4 and int(i[1])==2:
        _4_2[int(i[2])-1]+=int(i[3])
    elif int(i[0])==4 and int(i[1])==3:
        _4_3[int(i[2])-1]+=int(i[3])
print("",*_1_1)
print("",*_1_2)
print("",*_1_3)
print("
print("",*_2_1)
print("",*_2_2)
print("",*_2_3)
print("
print("",*_3_1)
print("",*_3_2)
print("",*_3_3)
print("
print("",*_4_1)
print("",*_4_2)
print("",*_4_3)

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

for i in range(4):
  for j in range(3):
    print(' '+' '.join(map(str, cnt[i][j])))

  if i != 3:
    print('

Solution (Python):
_, *lines = open(0).readlines()
H = [[[0]*10 for i in range(3)] for j in range(4)]
for line in lines:
    b, f, r, v = map(int, line.split())
    H[b-1][f-1][r-1] += v
for i, h in enumerate(H):
    if i:
        print("
    for r in h:
        print("",*r)

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

Solution (Python):
from sys import stdin

rooms = [[[0] * 10 for _ in range(3)] for _ in range(4)]
stdin.readline().rstrip()
while True:
    try:
        b, f, r, v = [int(x) for x in stdin.readline().rstrip().split()]
        rooms[b-1][f-1][r-1] += v
    except:
        break

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

Solution (Python):
residents = [[[0] * 11 for i in range(4)] for j in range(5)]
N = int(input())
for _i in range(N):
    b, f, r, v = map(int, input().split())
    residents[b][f][r] += v
for i in range(1, 5):
    for j in range(1, 4):
        print(' ' + ' '.join(map(str, residents[i][j][1:])))
    if not i == 4:
        print(''.join(['

Solution (Python):
A = []
for _ in range(12):
	A.append([0]*10)

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

for i in range(12):        
	print(' ', end='')
	print(' '.join(map(str, A[i])))
	if i in [2, 5, 8]:
		print('

Solution (Python):
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())

building = [[0] * sharpNum for i in range(height)]

for data in range(dataNum):
    actBuilding = 1
    actRoom = 0
    actFloor = 0
    b,f,r,v = map(int, input().split())
    for floor in range(height):
        actRoom = 0
        if floor%4 == 3:
            actFloor = 0
            actBuilding = actBuilding + 1
            for room in range(sharpNum):
                building[floor][room] = "
        else:
            actFloor = actFloor + 1
            
            for room in range(sharpNum):
                if room%2 == 0:
                    building[floor][room] = " "
                else:
                    actRoom = actRoom + 1 
                    if actBuilding == b and actFloor== f and actRoom == r:
                        building[floor][room] = building[floor][room] + v

for floor in range(height):      
    for i in range(len(building[0])):
        print(building[floor][i],end="")
    print("")

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

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

Solution (Python):
n = int(input())
li = ["
for _ in range(n):
    b, f, r, v = map(int, input().split())
    h = 4*b-(4-f)-1
    li[h] = li[h].replace(li[h], ''.join([str(int(list(li[h])[r-1])+v) if i == r-1 else list(li[h])[i] for i in range(10)]))
li = [' '+' '.join(li[i]) if (i+1)%4!=0 else li[i] for i in range(len(li))]
print('\n'.join(li))

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 i in range(4):
    if x != 0:
        print("
    x += 1
 
    for a in range(3):
        for b in range(10):
            print(" %d"%(count[i][a][b]),end = "")
        print()

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

for i in range(int(input())):
	n=list(map(int,input().split()))
	room[n[0]-1][n[1]-1][n[2]-1]+=n[3]
n=0
for i in room:
	for j in i:
		print(' '+' '.join(list(map(str,j))))
		if n==2 or n==5or n==8:
			print('
		n+=1

Solution (Python):
num = {
    1:{1:[0]*10,2:[0]*10,3:[0]*10},
    2:{1:[0]*10,2:[0]*10,3:[0]*10},
    3:{1:[0]*10,2:[0]*10,3:[0]*10},
    4:{1:[0]*10,2:[0]*10,3:[0]*10}
}

n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    num[b][f][r-1] += v
for b in num:
    for f in num[b]:
        for r in num[b][f]:
            print(' '+str(r), end='')
        print()
    if b==4: break
    print('

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

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

n = int(input())

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

    i += 1

for i,elem_i in enumerate(table):           
    for j,elem_j in enumerate(elem_i):      
        for k, elem_k in enumerate(elem_j): 
            print (" " + str(elem_k), end='')
        print ("")
    if i != 3:
        print ("

Solution (Python):
table = [0] * 4*3*10

n = int(input())

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

for i in range(120):
    if i != 0 and i % 30 == 0:
        print("
    print(" %d" % table[i], end="")
    if i%10 == 9:
        print()

Solution (Python):
n = int(input())
a = []

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

Solution (Python):

num = int(input())

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

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

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

Solution (Python):
n = int(input())
A = [[0]*10 for i in range(12)] 

for _ in range(n):
    b, f, r, v = map(int, input().split())
    A[(b-1)*3 + (f-1)][r-1] += v
for i, v in enumerate(A, 1):
    print(' ' + ' '.join([str(p) for p in v]))
    if i == 3 or i == 6 or i == 9:
        print('

Solution (Python):
buildings =  [[[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())

    buildings[b-1][f-1][r-1] += v
sep = 1
for b in buildings:
    for f in b:
        print(" ",end="")
        print(*f)
    if sep != len(buildings):
        print("
        sep +=1

Solution (Python):
buildings =  [[[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())

    buildings[b-1][f-1][r-1] += v
sep_count = len(buildings) - 1
for b in buildings:
    for f in b:
        print(" ",end="")
        print(*f)
    if sep_count != 0:
        print("
        sep_count -= 1

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())
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())
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())
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())
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):

A=[[[0 for k in range(10)]for j in range(3)]for i in range(4)]
format(A)
n=int(input())
for m in range(n):
  b,f,r,v=map(int,input().split())
  S=A[b-1][f-1][r-1]+v
  A[b-1][f-1][r-1]=S
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):
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())


b_list=[]
f_list=[]
r_list=[]
v_list=[]
while n > 0:
  b, f, r, v = map(int, input().split())
  b_list.append(b)
  f_list.append(f)
  r_list.append(r)
  v_list.append(v)
  n = n-1

for (blist,flist,rlist,vlist) in zip(b_list,f_list,r_list,v_list):
  count[blist-1][flist-1][rlist-1] = count[blist-1][flist-1][rlist-1] + vlist

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

Solution (Python):



from sys import stdin

n = int(stdin.readline().rstrip())

NUMBER_OF_BUILDING = 4
FLOORS_PER_BUILDING = 3
ROOMS_PER_FLOOR = 10

official_house = [
    [
        [
            0 for _ in range(ROOMS_PER_FLOOR)
            ] for _ in range(FLOORS_PER_BUILDING)
        ] for _ in range(NUMBER_OF_BUILDING)
    ]

for cnt in range(n):
    b, f, r, v = (int(n) for n in stdin.readline().rstrip().split())
    official_house[b - 1][f - 1][r - 1] += v

for no, building in enumerate(official_house):
    if no != 0:
        print("

    for floor in building:
        print(" " + " ".join(map(str, floor)))

Solution (Python):
inf = int(input())
i = 0
table = []
buil = [[[0]*10 for i in range(3)]for i in range(4)]

while(i < inf):
    b,f,r,v = map(int,input().split())
    b -=1
    f -=1
    r -=1
    buil[b][f][r] += v
    if buil[b][f][r] > 9: buil[b][f][r] = 9
    elif buil[b][f][r] < 0: buil[b][f][r] = 0
    i += 1

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

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

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

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

x = 0

for i in range(4):
  if x!=0:
    print('
  x += 1
  
  for b in range(3):
    for f in range(10):
      print(' %d'%(num[i][b][f]), end ='')
    print()

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

for i in range(4):
  for j in range(3):
    for k in range(10):
      if k!=9:
        print("",bill[i][j][k],end="")
      else:
        print("",bill[i][j][k])
  if i!=3:
     print("

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  [b, f, r, v] = list(map(int,input().split()))
  key = f'{b} {f} {r}'
  if key in d:
    d[key] += v
  else:
    d[key] = v
    
for b in range(1,5):
  for f in range(1,4):
    for r in range(1,11):
      key = f'{b} {f} {r}'
      if key in d:
        print(" "+str(d[key]),end="")
      else:
        print(" "+str(0),end="")
      if r == 10:
        print()
      if r == 10 and f == 3 and b != 4:
        print('

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

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

Solution (Python):
def az17():
    a = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
    n = input()
    for i in range(n):
        xs = map(int,raw_input().split())
        a[xs[0]-1][xs[1]-1][xs[2]-1] = a[xs[0]-1][xs[1]-1][xs[2]-1] + xs[3]
    for b in range(0,4):
        for f in range(0,3):
            print "",
            for r in range(0,10):
                print a[b][f][r],
            print
        if not b == 3:
            print "

az17()

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

D = []
for i in range(0,4):
    bb = []
    for k in range(0,3):
        b = [0,0,0,0,0,0,0,0,0,0]
        bb.append(b)
    D.append(bb)

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

for b in range(0,4):
    for f in range(0,3):
        s = ''
        for r in range(0,10):
            v = str(D[b][f][r])
            s = s + ' ' + v
        print s
    if b < 3:
        print "

Solution (Python):
n = int(input())
count = 0
room = [int(0) for i in range(4) for j in range(3) for k in range(10)]
while count < n:
    x = list(map(lambda k: int(k), input().split(" ")))
    room[(x[0]-1)*30+(x[1]-1)*10+(x[2]-1)] += x[3]
    count += 1
for i in range(4):
    if i != 0:
        print("
    for j in range(3):
        for k in range(10):
            print(" %d" % room[30*i+10*j+k], end="")
        print("")

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

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

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

Solution (Python):
data = []
for i in xrange(4):
	tou = []
	data.append(tou)
	for j in xrange(3):
		kai = [0 for k in xrange(10)]
		tou.append(kai)
n = int(raw_input())
for i in xrange(n):
	b,f,r,v = map(int, raw_input().split(" "))
	data[b-1][f-1][r-1] = max(0, data[b-1][f-1][r-1] + v)
for tou in data:
	if not tou is data[0]:
		print "
	for kai in tou:
		print " " + " ".join(map(str, kai))

Solution (Python):
n = input()
floor = []
for i in range(n):
    floor.append(map(int,raw_input().split()))

bill = [ [ [ 0 for c in range(10)] for b in range(3)] for a in range(4)]

for a in floor:
    bill[a[0]-1][a[1]-1][a[2]-1] = (bill[a[0]-1][a[1]-1][a[2]-1]) + (a[3])
flg = 0
for a in bill:
    if flg == 1:
        print "
    for b in a:
        print " " + " ".join(map(str,b))
        flg = 1

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

nums = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]

for idx in range(n):

    b, f, r, v  = tuple([int(x) for x in raw_input().split(" ")])
    nums[b-1][f-1][r-1] += v

for i_b in range(4):
    if i_b != 0: print "
    for i_f in range(3):
        print " " + " ".join([str(x) for x in nums[i_b][i_f]])

Solution (Python):
import sys
 
BUILDINGS = tuple(x for x in range(4))
FLOORS = tuple(x for x in range(3))
ROOMS = tuple(x for x in range(10))
 
occupant = [[[0 for r in ROOMS] for f in FLOORS] for b in BUILDINGS]
 
n = input() 
 
for line in sys.stdin:
    b, f, r, v = map(int, line.split())
    occupant[b - 1][f - 1][r - 1] += v
     
for b in BUILDINGS:
    if b:
        print('
    for f in FLOORS:
        print("", *occupant[b][f])

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

count = int(input())

for c in range(count):
    (b, f, r, v) = [int(x) for x in input().split()]
    data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    print('