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):
data = [
        [[0 for k in range(10)] for j in range(3)] for i in range(4)
        ]

count = int(input())

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

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

    if b == 3:
        break
    for x in range(20):
        print('
    print()

Solution (Python):
floor = [
        [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],

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

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

        [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
        ]
s = '

n = int(input())
for c in range(n):
    (b,f,r,v) = [int(x) for x in input().split()]
    if 1 > b > 5 and 1 > f > 4 and 1 > r > 10:
        break
    floor[b-1][f-1][r-1] += v

for z in range(4):
    for i in range(len(floor[z])):
        for v in floor[z][i]:
            print(end=' ')
            print(v, end='')
        print()
    if not z == 3:
        print(s)

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

for c in range(int(input())):
    (b,f,r,v) = [int(x) for x in input().split()]
    if 1 > b > 5 or 1 > f > 4 or 1 > r > 10:
        break
    floor[b-1][f-1][r-1] += v

for x in range(3 * 4):
    if x % 3 == 0 and not x == 0:
        print('
    print('',' '.join(str(y) for y in floor[int(x / 3)][x % 3]))

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

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

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

for x in range(3 * 4):
    if x % 3 == 0 and not x == 0:
        print('
    print('',' '.join(str(y) for y in floor[int(x / 3)][x % 3]))

Solution (Python):
import sys

n = input()
x = {}

for i in range(1,5):
    for j in range(1,4):
        for k in range(1,11):
            x[(i,j,k)] = 0

for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    x[(b,f,r)] += v

for i in range(1,5):
    for j in range(1,4):
        for k in range(1,11):
            sys.stdout.write(' ')
            sys.stdout.write(str(x[(i,j,k)]))
        print
    if(i != 4):
        for l in range(20):
            sys.stdout.write('
        print
exit(0)

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

n = int(input())
for nc in range(n):
  (b, f, r, v) = [int(i) for i 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(' {0}'.format(data[b][f][r]), end='')
    print()
  print('

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

n = int(input())
for nc in range(n):
    (b, f, r, v) = [int(i) for i 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(' {0}'.format(data[b][f][r]), end='')
        print()
    print('

Solution (Python):
import sys

official_house = {}
for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            official_house[(b, f, r)] = 0

n = int(sys.stdin.readline())
for line in sys.stdin:
    (b, f, r, v) = [int(i) for i in line.split()]
    official_house[(b, f, r)] += v

for b in range(1, 5):
    if b != 1:
        print("
    for f in range(1, 4):
        for r in range(1, 11):
            print(" %d" % official_house[(b, f, r)], end="")
        print()

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

n = int(input())

for nc in range(n):
    (b,f,r,v) = [int(i) for i 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('

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

n = int(input())

for nc in range(n):
    (b,f,r,v) = [int(i) for i 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('

Solution (Python):


dic = {}
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            dic[(b,f,r)] = 0

n = int(raw_input())
for k in range(n):
    b,f,r,v = map(int,raw_input().split())
    dic[(b,f,r)] += v

j = 0
for b in range(1,5):
    for f in range(1,4):
        ls = []
        for r in range(1,11):
            ls.append(dic[(b,f,r)])
        print ' ' + ' '.join(map(str,ls))
        
    else:
        if j < 3:
            print '
        j +=1

Solution (Python):
if __name__ == '__main__':
    nums = [[[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 = [int(i) for i in input().split()]
        nums[b-1][f-1][r-1] += v
    for b in range(4):
        for f in range(3):
            print(' ' + ' '.join([str(i) for i in nums[b][f]]))
        if b == 3: break
        print('

Solution (Python):


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

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

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

Solution (Python):


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

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

Solution (Python):
l=[0]*120
s="
for i in range(input()):b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print "",
for i in range(120):
 print l[i],;j=i+1
 if j==120:break
 if j%30==0:print;print s,
 if j%10==0:print;print "",

Solution (Python):
n=120
l=[0]*120
s="
for i in range(input()):b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print"",

for i in range(1,121):
 print l[i-1],
 if i==120:break
 if i%30==0:print;print s,
 if i%10==0:print;print"",

Solution (Python):
l=[0]*120
s="
for i in range(input()):b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print"",
for i in range(1,121):
 print l[i-1],
 if i==120:break
 if i%30==0:print;print s,
 if i%10==0:print;print"",

Solution (Python):
l=[0]*120
s="
n=input()
while n:n-=1;b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print"",
while 1:
 n+=1;print l[n-1],
 if n==120:break
 if n%30==0:print;print s,
 if n%10==0:print;print"",

Solution (Python):
import sys
n=int(input())
data={}
for i in range(1,5):
	for j in range(1,4):
		for k in range(1,11):
			data[(i,j,k)]=0
			

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

for i in range(1,5):
	for j in range(1,4):
		for k in range(1,11):
			sys.stdout.write(' '+str(data[(i,j,k)]))
		print('')
	if i<4:
		print('

Solution (Python):
from __future__ import print_function
import sys

officalhouse = [0]*4*3*10

n = int( sys.stdin.readline() )
for i in range( n ):
	b, f, r, v = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	bfr = (b-1)*30+(f-1)*10+(r-1)
	officalhouse[bfr] = officalhouse[bfr] + v;
	
output = []
for b in range( 4 ):
	for f in range( 3 ):
		for r in range( 10 ):
			output.append( " {:d}".format( officalhouse[ b*30 + f*10 + r ] ) )
		output.append( "\n" )
	if b < 3:
		output.append( "

print( "".join( output ), end="" )

Solution (Python):
import sys

officalhouse = [0]*4*3*10

n = int( sys.stdin.readline() )
for i in range( n ):
	b, f, r, v = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	bfr = (b-1)*30+(f-1)*10+(r-1)
	officalhouse[bfr] = officalhouse[bfr] + v;
	
output = []
for b in range( 4 ):
	for f in range( 3 ):
		for r in range( 10 ):
			output.append( " {:d}".format( officalhouse[ b*30 + f*10 + r ] ) )
		output.append( "\n" )
	if b < 3:
		output.append( "

print( "".join( output ), end="" )

Solution (Python):


class residence(object):
	def __init__(self):
		one = [0] * 10
		two = [0] * 10
		three = [0] * 10
		self.all = [one, two, three]

residences = [ ]

for i in xrange(4):
	residences.append(residence())

n = int(raw_input())

for i in xrange(n):
	b, f, r, v = map(int, raw_input().split())
	residences[b-1].all[f-1][r-1] += v

for i, residence in enumerate(residences):
	for floor in residence.all:
		print '',
		for index, num in enumerate(floor):
			if index == len(floor) - 1:
				print num
			else:
				print num,
	if i != len(residences) - 1:
		print '

Solution (Python):
a = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().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):
if __name__ == "__main__":

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

    n = int(raw_input())

    i = 0
    while i < n:
        x = map(int, raw_input().split())
        b = x[0]
        f = x[1]
        r = x[2]
        v = x[3]
        house[b-1][f-1][r-1] += v
        i += 1

    b = 1
    while b <= 4:
        f = 1
        while f <= 3:
            s = ""
            r = 1
            while r <= 10:
                s += " {0}".format(house[b-1][f-1][r-1])
                r += 1
            print s
            f += 1
        if b != 4:
            print "
        b += 1

Solution (Python):

from copy import deepcopy

rooms = dict(zip(range(1, 11), [0] * 10))
building = dict(zip(range(1, 4), [deepcopy(r) for r in [rooms]*3]))
buildings = dict(zip(range(1, 5), [deepcopy(b) for b in [building]*4]))


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


for b in range(1, 5):
    for f in range(1, 4):
        rooms = buildings[b][f]
        print ' ' + ' '.join(map(str, [rooms[i] for i in xrange(1, 11)]))
    if b != 4:
        print '

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

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

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b != 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):
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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b != 3:
        print('

Solution (Python):
data = [ [ [ 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) = [int(i) for i 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()
    if b < 3:
        print( '

Solution (Python):
data = [
        [
            [
                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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

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

residence = []

for i in xrange(4):
  floor = []
  for j in xrange(3):
    room = []
    for k in xrange(10):
      room.append(0)
    floor.append(room)
  residence.append(floor)

i = 0
while i < n:
  line = map(int, raw_input().split(" "))
  residence[line[0] - 1][line[1] - 1][line[2] - 1] += line[3]
  
  
  i += 1

secion_line = "
for i in xrange(4):
  for j in xrange(3):
    output_line = ""
    for k in xrange(10):
      output_line += " " + str(residence[i][j][k])
    print output_line
  if i != 3:
   print secion_line

Solution (Python):
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]
room = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
for a in data:
    room[a[0]-1][a[1]-1][a[2]-1]+=a[3]

for x,i in enumerate(room):
    for j in i:
            print(''," ".join(map(str,j)))
    if x <= 2 : print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b != 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b != 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
a = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().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):
data = [[[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) = [int(i) for i 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()
    if b != 3:
        print('

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

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)]
n = int(input())
for _ in range(n):
    (b, f, r, v) = [int(i) for i 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()
    if b != 3:
        print('

Solution (Python):



B = 4
F = 3
R = 10
SHARPS = 20

def main():
    """
    The function to be called when this script is run as a script.
    
    """
    
    info_number = int(input())
    given_info_str = (info.split() for info in (
        input() for _ in range(info_number)))
    given_info_int = (list(map(int, info)) for info in given_info_str)
    houses = [[[0 for i in range(R)] for j in range(F)] for k in range(B)]
    for info in given_info_int:
        houses[info[0] - 1][info[1] - 1][info[2] - 1] += info[3]
    for num, building in enumerate(houses):
        for floor in building:
            print (" " + " ".join(map(str, floor)))
        if num < (B - 1):
            print("

if __name__ == "__main__":
    main()

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]], 
[['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
 [['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ['', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], 
 [['', 0, 0, 0, 0, 0, 0, 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 = input()
for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    a[b - 1][f - 1][r] += v
print ' '.join(map(str, a[0][0]))
print ' '.join(map(str, a[0][1]))
print ' '.join(map(str, a[0][2]))
print '
print ' '.join(map(str, a[1][0]))
print ' '.join(map(str, a[1][1]))
print ' '.join(map(str, a[1][2]))
print '
print ' '.join(map(str, a[2][0]))
print ' '.join(map(str, a[2][1]))
print ' '.join(map(str, a[2][2]))
print '
print ' '.join(map(str, a[3][0]))
print ' '.join(map(str, a[3][1]))
print ' '.join(map(str, a[3][2]))

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
build = range(1, 5)
floor = range(1, 4)
dic = {}
for b in build:
    dic[b] = {}
    for f in floor:
        dic[b][f] = [0]*10

n = input()
for i in range(n):
    info = map(int, raw_input().split())
    dic[info[0]][info[1]][info[2]-1] += info[3]
    if dic[info[0]][info[1]][info[2]-1] > 9:
        print 'error'

for b in build:
    for f in floor:
        print '',
        print ' '.join(map(str, dic[b][f]))
    if b != 4:
        print "

Solution (Python):
build = range(1, 5)
floor = range(1, 4)
dic = {b: {f: [0]*10 for f in floor} for b in build}

n = input()
for i in range(n):
    info = map(int, raw_input().split())
    dic[info[0]][info[1]][info[2]-1] += info[3]
    if dic[info[0]][info[1]][info[2]-1] > 9:
        print 'error'

for b in build:
    for f in floor:
        print '',
        print ' '.join(map(str, dic[b][f]))
    if b != 4:
        print "

Solution (Python):
res_list = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
            [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
            [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
            [[0, 0, 0, 0, 0, 0, 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):
    io_rec = list(map(int, input().split(" ")))
    bld_num = io_rec[0] - 1
    floor_num = io_rec[1] - 1
    room_num = io_rec[2] - 1
    io_headcnt = io_rec[3]
    res_list[bld_num][floor_num][room_num] += io_headcnt


for i in range(4):
    if i:
        print("
    bld = res_list[i]
    for j in bld:
        floor_str = map(str, j)
        print(" " + " ".join(floor_str))

Solution (Python):
data = [[[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) = [int(i) for i 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()
    if b < 3:
        print('

Solution (Python):
import sys

n = input()
a_uni = [[[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,raw_input().split())
	a_uni[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:
				sys.stdout.write(' ')
				print(a_uni[i][j][k])
			else :
				sys.stdout.write(' ')
				sys.stdout.write(str(a_uni[i][j][k]))
	if not i==3:
		print '

Solution (Python):
def showrooms(building,floor,rooms):
    for x in xrange(0,floor):
        for y in xrange(0,rooms):
            if y==0:
                print "",
                print building[x][y],
            elif y ==rooms-1:
                print building[x][y]
            else:
                print building[x][y],
FLOOR = 3
ROOMS = 10
n = input()
building1 = [[0 for i in range(ROOMS)] for j in range(FLOOR)]
building2 = [[0 for i in range(ROOMS)] for j in range(FLOOR)]
building3 = [[0 for i in range(ROOMS)] for j in range(FLOOR)]
building4 = [[0 for i in range(ROOMS)] for j in range(FLOOR)]

for x in xrange(0,n):
    b,f,r,v = map(int,raw_input().split())
    f=f-1
    r=r-1
    if b==1:
        building1[f][r] += v
    elif b==2:
        building2[f][r] += v
    elif b==3:
        building3[f][r] += v
    elif b==4:
        building4[f][r] += v
    else:
        print "your input is invalid format."
        break
showrooms(building1,FLOOR,ROOMS)
print "
showrooms(building2,FLOOR,ROOMS)
print "
showrooms(building3,FLOOR,ROOMS)
print "
showrooms(building4,FLOOR,ROOMS)

Solution (Python):
n=input()
L1=[[0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0]]
L2=[[0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0]]   
L3=[[0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0]]
L4=[[0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0],
   [0,0,0,0,0,0,0,0,0,0]]
Mantion=[L1,L2,L3,L4]
for i in range(n):
  b,f,r,v=map(int, raw_input().split())
  Mantion[b-1][f-1][r-1]+=v

for j in range(3):
  L1_str=map(str, L1[j])
  print "",
  print " ".join(L1_str)
print "
for j in range(3):
  L2_str=map(str, L2[j])
  print "",
  print " ".join(L2_str)
print "
for j in range(3):
  L3_str=map(str, L3[j])
  print "",
  print " ".join(L3_str)
print "
for j in range(3):
  L4_str=map(str, L4[j])
  print "",
  print " ".join(L4_str)

Solution (Python):
l = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
n = int(input())
while n > 0:
  b,f,r,v = map(int,input().split())
  l[b-1][f-1][r-1] += v
  n -= 1
c = 0
for b in l:
  c += 1
  for f in b:
    r_l = [str(r) for r in f]
    print(' '+' '.join(r_l))
  if c < len(l):  
    print('

Solution (Python):
house = [[[0 for col in range(10)]for row in range(3)]for layer in range(4)]
n = int(raw_input())
for i in range(n):
    input_line = raw_input().split()
    house[int(input_line[0])-1][int(input_line[1])-1][int(input_line[2])-1] += int(input_line[3])
for i in range(0,4):
    if i != 0:
        print "
    for j in range(0,3):
        buf = ""
        for k in range(0,10):
                buf += " " + str(house[i][j][k])
        print buf

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

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

for b in range(4):
    for f in range(3):
        for r in range(10):
            ans += " "+str(a[b][f][r])
        if (b!=3 or f!=2 or r!=9):
            ans += "\n"
    if (b != 3):
        ans += "

print(ans)

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

nums = []
for i in range(4):
    nums.append([])
    for j in range(3):
        nums[i].append([])
        for k in range(10):
            nums[i][j].append(0)


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

for i, building in enumerate(nums):
    for floor in building:
        print('', ' '.join(map(str, floor)))
    if i != 3:
        print('

Solution (Python):


class FLOOR:
    def __init__(self):
        self.room = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

class BUILD:
    def __init__(self):
        self.floor = [FLOOR(), FLOOR(), FLOOR()]


all_rooms = [BUILD(), BUILD(), BUILD(), BUILD()]


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

for b in range(4):
    for f in range(3):
        display = []
        for r in range(10):
            display.append(str(all_rooms[b].floor[f].room[r]))
        print(' ' + ' '.join(display))
    if (b < 3):
        print('

Solution (Python):
def print_list(lst) :
	a = ' '.join(list(map(str, lst)))
	print(" " + a)

n = int(input())
lst = [[[0 for w in range(10)] for q in range(3)] for e in range(4)]
for _ in range(n):
	b,f,r,v = list(map(int, input().split()))
	lst[b-1][f-1][r-1] += v 
for i in range(4):
	if (i != 0):
		print("
	for j in range(3):
		print_list(lst[i][j])

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

info = list()
buildings = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(num):
    info = input().split()
    buildings[int(info[0])-1][int(info[1])-1][int(info[2])-1] += int(info[3])

for i, b in enumerate(buildings):
    for f in b:
        print(' ', end='')
        print(' '.join(map(str, f)))
    if not i == (len(buildings) - 1):
        print('

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

n = int(input())

while n:
    b, f, r, v = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v
    n -= 1

for i, b in enumerate(house):
    for f in b:
        print(' ', end='')
        print(*f)
    if i < 3:
        print('

Solution (Python):
house1 = [[0 for x in range(10)], [0 for x in range(10)], [0 for x in range(10)]]
house2 = [[0 for x in range(10)], [0 for x in range(10)], [0 for x in range(10)]]
house3 = [[0 for x in range(10)], [0 for x in range(10)], [0 for x in range(10)]]
house4 = [[0 for x in range(10)], [0 for x in range(10)], [0 for x in range(10)]]
houses = [house1, house2, house3, house4]

n = int(input())

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

cnt = 0
for house in houses:
    for floor in house:
        floor = [str(x) for x in floor]
        print(' ' + ' '.join(floor))
    if cnt != 3:
        print('
    cnt += 1

Solution (Python):
import sys

S = [[[0 for k in xrange(10)] for j in xrange(3)] for i in xrange(4)]

n = input()

for l in xrange(n):
    b, f, r, v = map(int, raw_input().split())
    S[b - 1][f - 1][r - 1] += v
    
for k in xrange(4):
    for j in xrange(3):
        for i in xrange(10):
            tmp = ' ' + str(S[k][j][i]) 
            sys.stdout.write(tmp)
        print ""
    if k != 3:
        print "