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
n = input()
a = [[[0]*10 for i in range(3)] for i in range(4)]
for i in xrange(n):
	b = map(int, raw_input().split())
	a[b[0]-1][b[1]-1][b[2]-1] += b[3]

for i in range(4):
	for j in range(3):
		for k in range(10):
			sys.stdout.write(' %s' % a[i][j][k])
		print ""
	if i != 3:
		print '

Solution (Python):
n = int(input())
Building = [[[0 for r in range(11)] for f in range(4)] for b in range(5)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    Building[b][f][r] += v

for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print(" " + str(Building[b][f][r]), end = "")
        print()
    if b != 4:
        print("

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


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

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

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

for i in range(n):
    C = map(int, raw_input().split())
    Mem[C[0]-1][C[1]-1][C[2]-1] += C[3]

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

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


lst = [[[0 for q in range(10)] for w in range(3)] for e in range(4)]

n = int(input())
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):
n = int( raw_input() )
house = [ [ [ 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() )
  house[b-1][f-1][r-1] += v
     
for i in range(4):
  for j in range(3):
    ans=''
    for k in range(10):
      ans += ' ' + str( house[i][j][k] )
    print ans
  if i != 3: 
    print '

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

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

n = input()

for i in range(n):
    Inf = map(int, raw_input().split())

    Adr[Inf[0]-1][Inf[1]-1][Inf[2]-1] += Inf[3]

for b in range(4):
    for f in range(3):
        print "",
        for r in range(10):
            if r != 9:
                print Adr[b][f][r],
            if r == 9:
                if f == 3:
                    print Adr[b][f][r],
                if f != 3:
                    print Adr[b][f][r]


    if b < 3:
        print "

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

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

Solution (Python):
data = [None] * 4
for i in xrange(4):
    data[i] = [None] * 3
    for j in xrange(3):
        data[i][j] = [0] * 10

n = input()
for i in xrange(n):
    line = map(int, raw_input().split())
    data[line[0] - 1][line[1] - 1][line[2] - 1] += line[3]

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

Solution (Python):
n = int(raw_input())
l = [[[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())
    l[b-1][f-1][r-1] += v
for i in range(4):
    if i != 0:
        print "
    for j in range(3):
        print "",
        for k in range(9):
            print "%d" %l[i][j][k] ,
        print l[i][j][9]

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

Solution (Python):



n = input()

A = []
for i in range(n):
    A.append(raw_input().split())

buil1 = [[0 for i in range(10)] for j in range(3)]
buil2 = [[0 for i in range(10)] for j in range(3)]
buil3 = [[0 for i in range(10)] for j in range(3)]
buil4 = [[0 for i in range(10)] for j in range(3)]

b = []
f = []
r = []
v = []

for i in range(n):
    b.append(int(A[i][0]))
    f.append(int(A[i][1]))
    r.append(int(A[i][2]))
    v.append(int(A[i][3]))
for i in range(n) :   
    if b[i] == 1:
         buil1[f[i]-1][r[i]-1] += v[i]
    elif b[i] == 2:
         buil2[f[i]-1][r[i]-1] += v[i]
    elif b[i] == 3:
         buil3[f[i]-1][r[i]-1] += v[i]
    elif b[i] == 4:
         buil4[f[i]-1][r[i]-1] += v[i]

                    
                        
for i in range(3):
    print"",
    for j in range(10):
        if j == 9 :
            print buil1[i][j]
        else :
            print buil1[i][j],
    
    
print"
for i in range(3):
    print"",
    for j in range(10):
        if j == 9 :
            print buil2[i][j]
        else :
            print buil2[i][j],
    
print"
for i in range(3):
    print"",
    for j in range(10):
        if j == 9 :
            print buil3[i][j]
        else :
            print buil3[i][j],
    
print"
for i in range(3):
    print"",
    for j in range(10):
        if j == 9 :
            print buil4[i][j]
        else :
            print buil4[i][j],

Solution (Python):
import sys
n = input()
d = [[[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())
  d[b-1][f-1][r-1] += v
for i in range(4):
  for j in range(3):
    for k in range(10):
      sys.stdout.write(' %d' % d[i][j][k])
    if k==9:
      sys.stdout.write('\n')
  if j==2 and i<=2:
    sys.stdout.write('

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

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

for i in range(4):
    for j in range(3):
        s = ' '
        s += ' '.join(map(str,ryou[i][j]))
        print(s)
    if not i == 3:
        print(sep)

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

building_a = [[0 for j in range(11)] for i in range(4)]
building_b = [[0 for j in range(11)] for i in range(4)]
building_c = [[0 for j in range(11)] for i in range(4)]
building_d = [[0 for j in range(11)] for i in range(4)]

for i in range(n):
    b, f, r, v = map(int, raw_input().split())
    if b == 1:
        building_a[f][r] += v
    elif b == 2:
        building_b[f][r] += v
    elif b == 3:
        building_c[f][r] += v
    elif b == 4:
        building_d[f][r] += v
        
for i in range(1, 4):
    print "",
    for j in range(1, 11):
        print building_a[i][j],
    print 
for i in range(20):
    sys.stdout.write("
print

for i in range(1, 4):
    print "",
    for j in range(1, 11):
        print building_b[i][j],
    print 
for i in range(20):
    sys.stdout.write ("
print

for i in range(1, 4):
    print "",
    for j in range(1, 11):
        print building_c[i][j],
    print 
for i in range(20):
    sys.stdout.write("
print

for i in range(1, 4):
    print "",
    for j in range(1, 11):
        print building_d[i][j],
    print

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

Solution (Python):
data =[[[0 for r in range(10)] for f in range(3)] for b in range(4)]
result = ""
n = input()
for i in range(0, n):
    b, f, r, v = map(int, raw_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):
                result += " " + str(data[b][f][r])
         if(b != 3 or f != 2 or r !=9):
            result += "\n"
    if(b != 3):
        result += "
        
print result

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

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

Solution (Python):
import sys
k1 = [[0 for i in xrange(10)] for j in xrange(3)]
k2 = [[0 for i in xrange(10)] for j in xrange(3)]
k3 = [[0 for i in xrange(10)] for j in xrange(3)]
k4 = [[0 for i in xrange(10)] for j in xrange(3)]
 
n = input()
for i in xrange(n):
    m = map(int,raw_input().split())
    if m[0] == 1:
     k1[m[1]-1][m[2]-1] = k1[m[1]-1][m[2]-1] + m[3] 
    elif m[0] == 2:
     k2[m[1]-1][m[2]-1] = k2[m[1]-1][m[2]-1] + m[3]         
    elif m[0] == 3:
     k3[m[1]-1][m[2]-1] = k3[m[1]-1][m[2]-1] + m[3]         
    elif m[0] == 4:
     k4[m[1]-1][m[2]-1] = k4[m[1]-1][m[2]-1] + m[3] 
 
 
for i in xrange(3):
    for j in xrange(10):
        x = ' ' + str(k1[i][j])
        sys.stdout.write(x)
    if j == 9:
        print ""
 
print"
 
for i in xrange(3):
    for j in xrange(10):
        y = ' ' + str(k2[i][j])
        sys.stdout.write(y)
    if j == 9:
        print ""
 
print"
 
for i in xrange(3):
    for j in xrange(10):
        z = ' ' + str(k3[i][j])
        sys.stdout.write(z)
    if j == 9:
        print ""
         
print"
 
for i in xrange(3):
    for j in xrange(10):
        zz = ' ' + str(k4[i][j])
        sys.stdout.write(zz)
    if j == 9:
        print ""

Solution (Python):
import sys
printf = sys.stdout.write

bilt1 = [0] * 30
bilt2 = [0] * 30
bilt3 = [0] * 30
bilt4 = [0] * 30

sha = "
count = 0;

x = input()
for i in range(x):
    b,f,r,v =map(int, raw_input().split())
    if b == 1:
        bilt1[((f - 1) * 10) + (r - 1)] = bilt1[((f - 1) * 10) + (r - 1)] + v
    elif b == 2:
        bilt2[((f - 1) * 10) + (r - 1)] = bilt2[((f - 1) * 10) + (r - 1)] + v
    elif b == 3:
        bilt3[((f - 1) * 10) + (r - 1)] = bilt3[((f - 1) * 10) + (r - 1)] + v
    else:
        bilt4[((f - 1) * 10) + (r - 1)] = bilt4[((f - 1) * 10) + (r - 1)] + v

for i in range(3):
    for j in range(10):
        print " ",
        printf(str(bilt1[(i * 10) + j]))
    print ""
print sha

for i in range(3):
    for j in range(10):
        print " ",
        printf(str(bilt2[(i * 10) + j]))
    print ""
print sha

for i in range(3):
    for j in range(10):
        print " ",
        printf(str(bilt3[(i * 10) + j]))
    print ""
print sha

for i in range(3):
    for j in range(10):
        print " ",
        printf(str(bilt4[(i * 10) + j]))
    print ""

Solution (Python):
import sys
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,num = input().strip().split()
	A[int(b)-1][int(f)-1][int(r)-1]+=int(num)

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

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

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


















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

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

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

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

for i, floors in enumerate(bldgs):
  if i != 0: print ("
  for rooms in floors:
    print ("", *rooms)

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

n = input()

for i in xrange(n):
    b,f,r,v=map(int,raw_input().split())
    house_info[b-1][f-1][r-1] += v
    
for i in xrange(4):
    for j in xrange(3):
        result = " " + " ".join(map(str,house_info[i][j]))
        print result
    if i < 3:
        print "

Solution (Python):


dic = {}
bui = [k for k in range(1, 5)]
flo = [k for k in range(1, 4)]
roo = [k for k in range(1, 11)]

for b in bui:
    for f in flo:
        for r in roo:
            dic[(b, f, r)] = 0

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

for b in bui:
    for f in flo:
        buf = ""
        for r in roo:
            buf += " "+ str(dic[(b, f, r)])
        print buf
    if b < 4:
        print "

Solution (Python):
regidents = [[[0 for b in range(10)] for f in range(3) ]for r in range(4)]
n = int(input())
for i in range(n):
    building, floor, room, delta = map(int, input().split())
    regidents[building-1][floor-1][room-1] += delta
print('\n

Solution (Python):
n=int(input())
rs=[[[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())
    rs[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,rs[b][f])))

Solution (Python):
n = input()
arr = [map(int,raw_input().split()) for _ in range(n)]

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

for line in arr:
    b,f,r,v = line
    tou[b-1][f-1][r-1] = tou[b-1][f-1][r-1] + v

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

Solution (Python):
class OfficialHouse:
    def __init__(self):
        self.room = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
    def inout(self, b, f, r, v):
        self.room[b-1][f-1][r-1] += v
    def output(self):
        for i in range(4):
            for j in range(3):
                s = ""
                for k in range(10):
                    s += " %d" % (self.room[i][j][k])
                print s
            if i != 3:
                print "

if __name__ == "__main__":
    oh = OfficialHouse()

    n = int(raw_input())
    for i in range(n):
        b, f, r, v = map(int, raw_input().split())
        oh.inout(b,f,r,v)
    oh.output()

Solution (Python):

import sys

def check(x_list, f, r, v):
    x_list[f][r] += v

def peo(x_list):
    for i in range(3):
        for j in range(10):
            sys.stdout.write(" %d" %(x_list[i][j]))
        print ("")

A_bill = [[0,0,0,0,0,0,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_bill = [[0,0,0,0,0,0,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_bill = [[0,0,0,0,0,0,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_bill = [[0,0,0,0,0,0,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):
    x = raw_input()
    b, f, r, v = x.split()
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    
    if b == 1:
        check(A_bill, f-1,r-1,v)
    elif b == 2:
        check(B_bill, f-1,r-1,v)
    elif b == 3:
        check(C_bill, f-1,r-1,v)
    elif b == 4:
        check(D_bill, f-1,r-1,v)

peo(A_bill)
print("
peo(B_bill)
print("
peo(C_bill)
print("
peo(D_bill)

Solution (Python):
import sys

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

n = input()

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

for i in xrange(4):
	if i != 0:
		print "
	for j in xrange(3):
		for k in xrange(10):
			sys.stdout.write(" "+str(buildings[i][j][k]))
		print

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

for b in range(4):
    for f in range(3):
        print(' '+' '.join(str(x) for x in arr[b][f]))
    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(input())
k = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]
for i in range(n):
    b,f,r,v = map(int,raw_input().split())
    k[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, k[b][f])))
    if b != 3:
        print("

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

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

n = input()
a = [[[0] * 10] * 3] * 4
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in xrange(n) :
    b, f, r, v = map(int, raw_input().split())

    a[b-1][f-1][r-1] += v;

for i in xrange(4) :
    for j in xrange(3) :
        for k in xrange(10) :
            sys.stdout.write(" " + str(a[i][j][k]))
        print
    if i < 3 :
        print "

Solution (Python):




class ryou:
	def flinit(self):
		room=list()
		for i in range(10):
			room+=[0]
		return room









def kaijo(x):
	print "",
	for i in range(len(x)-1):
		print str(x[i]),
	print str(x[len(x)-1])




floor_11=ryou().flinit()
floor_12=ryou().flinit()
floor_13=ryou().flinit()
floor_21=ryou().flinit()
floor_22=ryou().flinit()
floor_23=ryou().flinit()
floor_31=ryou().flinit()
floor_32=ryou().flinit()
floor_33=ryou().flinit()
floor_41=ryou().flinit()
floor_42=ryou().flinit()
floor_43=ryou().flinit()


fldic={"11":floor_11,
       "12":floor_12,
       "13":floor_13,
       "21":floor_21,
       "22":floor_22,
       "23":floor_23,
       "31":floor_31,
       "32":floor_32,
       "33":floor_33,
       "41":floor_41,
       "42":floor_42,
       "43":floor_43
       }





n=int(raw_input())



for l in range(n):
	list_mojiretsu=raw_input().split(" ")
	henka=map(int,list_mojiretsu)
	fldic[str(henka[0])+str(henka[1])][henka[2]-1]+=henka[3]
	


kaijo(floor_11)
kaijo(floor_12)
kaijo(floor_13)
print "
kaijo(floor_21)
kaijo(floor_22)
kaijo(floor_23)
print "
kaijo(floor_31)
kaijo(floor_32)
kaijo(floor_33)
print "
kaijo(floor_41)
kaijo(floor_42)
kaijo(floor_43)

Solution (Python):




class ryou:
	def flinit(self):
		room=list()
		for i in range(10):
			room+=[0]
		return room









def kaijo(x):
	print "",
	for i in range(len(x)-1):
		print str(x[i]),
	print str(x[len(x)-1])




floor_11=ryou().flinit()
floor_12=ryou().flinit()
floor_13=ryou().flinit()
floor_21=ryou().flinit()
floor_22=ryou().flinit()
floor_23=ryou().flinit()
floor_31=ryou().flinit()
floor_32=ryou().flinit()
floor_33=ryou().flinit()
floor_41=ryou().flinit()
floor_42=ryou().flinit()
floor_43=ryou().flinit()


fldic={"11":floor_11,
       "12":floor_12,
       "13":floor_13,
       "21":floor_21,
       "22":floor_22,
       "23":floor_23,
       "31":floor_31,
       "32":floor_32,
       "33":floor_33,
       "41":floor_41,
       "42":floor_42,
       "43":floor_43
       }





n=int(raw_input())



for l in range(n):
	list_mojiretsu=raw_input().split(" ")
	henka=map(int,list_mojiretsu)
	fldic[str(henka[0])+str(henka[1])][henka[2]-1]+=henka[3]
	


kaijo(floor_11)
kaijo(floor_12)
kaijo(floor_13)
print "
kaijo(floor_21)
kaijo(floor_22)
kaijo(floor_23)
print "
kaijo(floor_31)
kaijo(floor_32)
kaijo(floor_33)
print "
kaijo(floor_41)
kaijo(floor_42)
kaijo(floor_43)

Solution (Python):
N = int(input())
m=[]
line = ''
m = [[[0 for k in range(10)] for j in range(3)] for i in range(10)]
for i in range(N):
    n = input().split()
    b = int(n[0])
    f = int(n[1])
    r = int(n[2])
    v = int(n[3])
    m[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            line += ' {0}'.format(m[i][j][k])
        print(line)
        line = ''
    if i < 3:
        print('

Solution (Python):

n = int(input())
Univ = [[[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(' ')]
    Univ[b-1][f-1][r-1] += v

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

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

Solution (Python):
def create_List():
	re_list = [[],[],[],[]]
	for i in range(4):
		for j in range(3):
			re_list[i].append([0 for k in range(10)])
	return re_list


num = create_List()
for _ in range(int(input())):
	data = list(map(int,input().split()))
	num[data[0]-1][data[1]-1][data[2]-1] += data[3]


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

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

for x in range(4):
    for y in range(3):
        print(end = " ")
        print(*l[x][y])
    if x != 3:
        print("

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

for x in range(4):
    for y in range(3):
        print("", *l[x][y])
    if x != 3:
        print("

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

for i in range(n):
    call=list(map(int,input().split()))
    array[(call[0]-1)*3-1+call[1]][call[2]-1]+=call[3]
for i in range(0,12):
    if i%3==0 and i!=0:
        for j in range(20):
            print("
        print()
    for j in range(10):
        print(" "+str(array[i][j]),end="")
    print()

Solution (Python):
n = int(input())
a =[[[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())

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

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

Solution (Python):

roomDict = {}
for b in range(1, 4 + 1):
    for f in range(1, 3 + 1):
        for r in range(1, 10 + 1):
            roomNum = b * 100 + f * 10 + r
            roomDict[roomNum] = 0


n = int(input())
for i in range(n):
    input_b, input_f, input_r, input_v = map(int, input().split()) 
    roomNum = input_b * 100 + input_f * 10 + input_r
    numOfPeople = roomDict[roomNum]
    roomDict[roomNum] = numOfPeople + input_v


isFirst = True
for b in range(1, 4 + 1):
    if isFirst:
        isFirst = False
    else:
        print("
    for f in range(1, 3 + 1):
        for r in range(1, 10 + 1):
            roomNum = b * 100 + f * 10 + r
            print(" {0}".format(roomDict[roomNum]), end='')
        print('')

Solution (Python):
rooms = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n = int(input())
for _ in range(n):
    info = list(map(int,input().split()))
    rooms[info[0]-1][info[1]-1][info[2]-1] += info[3]

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

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

for i in residence:
    for j in i:
        s += " "+" ".join(map(str,j)) + "\n"

    s += sep+"\n"

print(s.rstrip(sep+"\n"))

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

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

for k in range(4):
	for j in range(3):
		for i in range(10):
			print(" {}".format(a[k][j][i]), end="")
		print("")
	if not k == 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()
    if bi < 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v

for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r),end='')

        print()
    if bi < 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v


for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v


for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 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(i) for i in input().split()]
    data[b-1][f-1][r-1] += v





for bi,b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r),end='')

        print()
    if bi < 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(i) for i in input().split()]                 
    data[b-1][f-1][r-1] += v                                       
                                                                   
for bi, b in enumerate(data):                                      
    for f in b:                                                    
        for r in f:                                                
            print(' {0}'.format(r), end='')                        
                                                                   
        print()                                                    
    if bi < 3:                                                     
        print('