Problem:
Official House You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b , f , r and v which represent that v persons entered to room r of f th floor at building b . If v is negative, it means that −v persons left. Assume that initially no person lives in the building. Input In the first line, the number of notices n is given. In the following n lines, a set of four integers b , f , r and v which represents i th notice is given in a line. Output For each building, print the information of 1st, 2nd and 3rd floor in this order. For each floor information, print the number of tenants of 1st, 2nd, .. and 10th room in this order. Print a single space character before the number of tenants. Print "####################" (20 '#') between buildings. Constraints  No incorrect building, floor and room numbers are given.  0 ≤ the number of tenants during the management ≤ 9  Sample Input 3
1 1 3 8
3 2 2 7
4 3 8 1 Sample Output 0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0

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

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

for tr in range(n):
    b, f, r, v = map(int, input().split())
    oh[b - 1][f - 1][r - 1] += v
    
for k in range(4):
    for j in range(3):
        tmp = ''
        for i in range(10):
            tmp += (' ' + str(oh[k][j][i]))
        print(tmp)
    if k < 3:
        print('

Solution (Python):
def main():
    n = int(input())
    n_b = 4
    n_f = 3
    n_r = 10

    from collections import defaultdict
    state = defaultdict(int)

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

    for b in range(1, n_b + 1):
        for f in range(1, n_f + 1):
            room_state = []
            for r in range(1, n_r + 1):
                room_state.append(state[(b, f, r)])
            print(" " + " ".join(map(str, room_state)))
        if b != n_b:
            print("


if __name__ == "__main__":
    main()

Solution (Python):
a=[[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):
  print(' ',end='')
  print(*a[i][j])
 if i!=3:print('

Solution (Python):
rooms = []
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])
rooms.append([[0 for i in range(10)] for j in range(3)])

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

for number, room in enumerate(rooms):
    for row in room:
        print ' ' + ' '.join(map(str, row))
    if len(rooms) - 1 > number:
        print('

Solution (Python):
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):
  print('',*a[i][j])
 if i!=3:print('

Solution (Python):
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 [print('',*a[i][j])for j in range(3)]
 if i!=3:print('

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

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

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

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

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

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

for i in range(n):
    b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] += a[i][3]

for i in range(4):
    for j in range(3):
        b[i][j].insert(0, "")
        print(*b[i][j])
    if i == 3:
        break
    print("

Solution (Python):
buildings=[[[0 for i in range(10)]for m in range(3)]for k in range(4)]
x=int(input())
for i in range(x):
    a,b,c,d=map(int,input().split())
    buildings[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print("",buildings[i][j][k],end="")
        print()
    if i!=3:
        print("

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

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

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

Solution (Python):

import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[0 for i in range(4)] for j in range(n)]
index = 0
result[index] = array[0][0:4]
for i in range(1,n):
    if result[index][0:3] == array[i][0:3]:
        result[index][3] += array[i][3]
    elif result[index][0:3] != array[i][0:3]:
        index += 1
        result[index] = array[i][0:]
index = 0
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == result[index][0] - 1 and j == result[index][1] - 1 and k == result[index][2] - 1):
                print result[index][3],
                if index != len(result) - 1:
                    index += 1
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "

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

a = [[[0 for iii in range(10)] for ii in range(3)] for i in range(4)]

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

for i in range(4):
    for ii in range(3):
        for iii in range(10):
            print(" " + str(a[i][ii][iii]), end="")
        print()
    if i == 3: break
    print("

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

ab = 4
af = 3
ar = 10

data = [[[0 for i in range(ar)] for j in range(af)] for k in range(ab)]

for i in range(n):
    instr = input().split()
    b = int(instr[0])
    f = int(instr[1])
    r = int(instr[2])
    v = int(instr[3])

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

for i in range(ab):
    if i != 0:
        print('
    for j in range(af):
        print("", *data[i][j])

Solution (Python):
from collections import defaultdict
m = defaultdict(int)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    m[(b, f, r)] += v
for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print("", m[(b, f, r)], end="")
        print("")
    if b < 4:
        print("

Solution (Python):
'''
いちばん簡単なのは建物とフロアごとにリスト作って、足し引き
'''




a = int(input())

n = 10
m = 3
o = 4
h = [
        [
            [0 for i in range(n)] 
         for j in range(m)] 
    for k in range(o)]



for i in range(a):
    w,x,y,z = map(int, input().split())
    h[w-1][x-1][y-1] += z



def makeFence():
    fence = '
    print(fence)


def showRoom(f):
    for k in range(len(f)-1):
        print(' ' + str(f[k]), end='')
    print(' ' + str(f[len(f)-1]))


def showFloor(b):
    j = 0
    while j < len(b):
        f = b[j]
        showRoom(f)
        j += 1

def statusShow(h):
    for i in range(len(h)-1):
        b = h[i]
        showFloor(b)
        makeFence()
    showFloor(h[len(h)-1])

statusShow(h)

Solution (Python):
import sys 

buildings = tuple(i for i in range(4)) 
floors = tuple(i for i in range(3)) 
rooms = tuple(i for i 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):
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):
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i!=3:print('

Solution (Python):
from __future__ import print_function
n = int(raw_input())
bilding1 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding2 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding3 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding4 = [[" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"],
           [" 0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0 ","0"]
           ]
bilding = []
bilding.append(bilding1)
bilding.append(bilding2)
bilding.append(bilding3)
bilding.append(bilding4)

for i in range(0,n):
    inf = raw_input()
    inf= inf.split(" ")
    b = int(inf[0]) -1
    f = int(inf[1]) -1
    r = int(inf[2]) -1
    v = int(inf[3])
    bilding[b][f][r] = int(bilding[b][f][r]) + v
    if(r == 0):
        bilding[b][f][r] = " " + str(bilding[b][f][r]) + " "
    elif(r < 9):
        bilding[b][f][r] = str(bilding[b][f][r]) + " "
    else:
        bilding[b][f][r] = str(bilding[b][f][r])

count = 0
for j in range(0,4):
    for k in range(0,3):
        for l in range(0,10):
            print((bilding[j][k][l]),end="")
        print("")
    if(count < 3):
        print("
        count += 1

Solution (Python):

"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n):
    
    buildings = []
    for _ in range(4):          
        buildings.append([[0]*10 for _ in range(3)]) 

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

    res = []
    for b in buildings:
        for f in b:
            f_stat = ' '.join(map(str, f))
            res.append(' ' + f_stat)
        res.append('
    res = res[:-1]
    print(*res, sep='\n')


def main(args):
    n = int(input())
    solve(n)


if __name__ == '__main__':
    main(sys.argv[1:])

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

N = int(input())
moves = [[int(i)-1 for i in input().split()] for _ in range(N)]

for m in moves:
    b,f,r,v = m
    v += 1
    A_college[b][f][r] += v

for b,building in enumerate(A_college):
    if 0 != b: print('
    for flr in building:
        print('',*flr)

Solution (Python):
a=[[10*[0]for _ in range(3)]for _ in range(4)]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i!=3:print('

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

Solution (Python):

import sys
n = input()
array = []
for i in range(n):
    array.append(map(int, raw_input().split()))
array.sort()
result = [[0 for i in range(4)] for j in range(n)]
index = 0
result[index] = array[0][0:4]
for i in range(1,n):
    if result[index][0:3] == array[i][0:3]:
        result[index][3] += array[i][3]
    elif result[index][0:3] != array[i][0:3]:
        index += 1
        result[index] = array[i][0:]
index = 0
for i in range(4):
    for j in range(3):
        for k in range(10):
            sys.stdout.write(' ')
            if(i == result[index][0] - 1 and j == result[index][1] - 1 and k == result[index][2] - 1):
                print result[index][3],
                if index != len(result) - 1:
                    index += 1
            else:
                print 0,
        else:
            print
    else:
        if(i != 3):
            print "

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

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

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("

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

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

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("

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

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

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("

Solution (Python):
n = int(input())
info = []
for _ in range(n):
    temp = [int(x) for x in input().split( )]
    info.append(temp)
state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for a in info:
    state[a[0]-1][a[1]-1][a[2]-1] += a[3]
for b in range(4):
    for f in range(3):
        string = ''
        for k in range(10):
            string += ' ' + str(state[b][f][k])
        print(string)
    if b < 3:
        print('

Solution (Python):
notice = int(input())
record = [[[0] * 10 for i in range(3)] for j in range(4)]

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

ans = ('\n' + '
print(ans)

Solution (Python):
n = int(input())
buffer = []
i = 0
while i<n:
    b,f,r,v = map(int,input().split())
    buffer.append([b,f,r,v])
    i = i + 1

room = []
for h in range(15):
    if h == 3 or h == 7 or h == 11:
        room.append(['**']*10)
    else:
        room.append([0]*10)
            
for y in range(n):
    if buffer[y][0] == 1:
        room[buffer[y][1]-1][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1][buffer[y][2]-1]
    elif buffer[y][0] == 2:
        room[buffer[y][1]-1+4][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+4][buffer[y][2]-1]
    elif buffer[y][0] == 3:
        room[buffer[y][1]-1+8][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+8][buffer[y][2]-1]
    elif buffer[y][0] == 4:
        room[buffer[y][1]-1+12][buffer[y][2]-1] = buffer[y][3] + room[buffer[y][1]-1+12][buffer[y][2]-1]
        
for x in range(15):
    if x == 3 or x == 7 or x == 11:
        print("
    else:
        for y in range(10):
            print(" "+str(room[x][y]), end = "")   
        print()

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

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

    if i != 3:
        print("

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

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

    if i != 3:
        print("

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

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

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

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

Solution (Python):


n = int(input())

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

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(x[i][j][k]), end = '' if k != 9 else '\n')

    print("

Solution (Python):
arr = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]
for _ in range(int(input())):
    a,b,c,d = map(int,input().split())
    arr[a-1][b-1][c-1] += d
for j1 in range(4):
    for j2 in range(3):
        u = arr[j1][j2]
        print("",u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9])
    if j1 == 3:
        break
    print("

Solution (Python):



import sys

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

n = int(sys.stdin.readline())
for i in range(n):
    b, f, r, v = map(int, sys.stdin.readline().split())
    tenant[b-1][f-1][r-1] += v

separator = '
for b in range(4):
    for f in range(3):
        for r in range(10):
            print(' ', tenant[b][f][r], sep='', end='')
        print()
    if b != 3:
        print(separator)

Solution (Python):
SEPARATE = "

tower = [
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
		[[0, 0, 0, 0, 0, 0, 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())
i = 0
while i < n:
	b, f, r, v = map(int, input().split())
	tower[b - 1][f - 1][r - 1] += v
	i += 1

i = 0
j = 0
k =  0
while k < 4:	
	while j < 3:
		while i < 10:
			print(" " + str(tower[k][j][i]), end = "")
			i += 1
		print()
		j += 1
		i = 0
	if k != 3:
		print(SEPARATE)
	j = 0
	k += 1

Solution (Python):
N = int(input())
n = [ map(int, input().split()) for i in range(N) ]
kousya = [ [[0]*10 for i in range(3)] for j in range(4) ]
for b, f, r, v in n:
    kousya[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        print('', *kousya[i][j])
    else:
        if i == 3: break
        print('

Solution (Python):
a = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n = int(input())
for i in range(n) :
    b, f, r, v = [int(x) for x in input().split()]
    a[b-1][f-1][r-1] += v
for i, b in enumerate(a) :
    for f in b :
        for r in f :
            print(' %d' % r, end = '')
        print()
    if i < 3 :
        print('

Solution (Python):

a = [[0 for i in range(10)] for k in range(3 * 4)]
for i in range(int(input())):
    b, f, r, v = map(int, input().split())
    a[(b-1)*3 + (f-1)][r-1] += v
for idx, i in enumerate(a):
    if idx % 3 == 0 and idx != 0:
        for k in range(20):
            print("
        print("")
    print(" ", end = "")
    print(" ".join(map(str, i)))

Solution (Python):
L=[0]*120
n = int(input())
i = 0
while i < n:
    b, f, r, v = map(int, input().split(' '))
    p = (r - 1) + (f - 1) * 10 + (b - 1) * 30
    L[p] += v
    i += 1
ans = ''
ans += ' ' + ' '.join(map(str, L[0:10].copy())) + '\n'
q = 1
while q < 12:
    if q % 3 == 0:
        ans += '
    ans += ' ' + ' '.join(map(str, L[q*10:(q+1)*10].copy())) + '\n'
    q += 1
print(ans[:-1])

Solution (Python):


if __name__ == '__main__':
    man = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

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

    print ' '+('\n%s\n ' % ('

Solution (Python):
import sys

n = int(sys.stdin.readline())
values =[ [ int(val) for val in num[:-1].split() ] for num in sys.stdin.readlines() ]

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

for value in values:
    nyukyo[value[0]-1][value[1]-1][value[2]-1] += value[3]
    if nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] < 0:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 0
    elif nyukyo[value[0]-1][value[1]-1][value[2]-1] > 9:
        nyukyo[value[0] - 1][value[1] - 1][value[2] - 1] = 9

for j in range(4):
    for n in range(3):
        for m in range(10):
            print( ' ' + str(nyukyo[j][n][m]), end='')
        print('')
    if j < 3:
        print('

Solution (Python):
n = int(input())
move = []
first = []
second = []
third = []
forth = []

for p in range(3):
    first.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

for q in range(3):
    second.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    
for r in range(3):
    third.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    
for s in range(3):
    forth.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

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

for j in move:
    f = j[1] - 1
    r = j[2] - 1
    if j[0] == 1:
        first[f][r] += j[3]
    elif j[0] == 2:
        second[f][r] += j[3]
    elif j[0] == 3:
        third[f][r] += j[3]
    else:
        forth[f][r] += j[3]

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

print("

for i in range(3):
    print(' ' + ' '.join(map(str, second[i])))
    
print("

for i in range(3):
    print(' ' + ' '.join(map(str, third[i])))
    
print("

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

Solution (Python):
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()

Solution (Python):
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()

Solution (Python):
n=int(input())
build,story,room,people=[],[],[],[]
for i in range(n):
    date=list(map(int,input().split(' ')))
    build.append(date[0])
    story.append(date[1])
    room.append(date[2])
    people.append(date[3])
build1=[[0 for i in range(10)] for j in range(3)]
build2=[[0 for i in range(10)] for j in range(3)]
build3=[[0 for i in range(10)] for j in range(3)]
build4=[[0 for i in range(10)] for j in range(3)]
for i in range(n):
    m=int(i)
    if(build[m]==1):
        build1[story[m]-1][room[m]-1]=build1[story[m]-1][room[m]-1]+people[m]
    elif(build[m]==2):
        build2[story[m]-1][room[m]-1]=build2[story[m]-1][room[m]-1]+people[m]
    elif(build[m]==3):
        build3[story[m]-1][room[m]-1]=build3[story[m]-1][room[m]-1]+people[m]
    else:
        build4[story[m]-1][room[m]-1]=build4[story[m]-1][room[m]-1]+people[m]

for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build1[i]))))
print('
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build2[i]))) )
print('
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build3[i]))) )
print('
for i in range(3):
    print(' '+' '.join(list(map( lambda x: str(x),build4[i]))) )

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

Solution (Python):
from collections import defaultdict

tower = defaultdict(lambda: defaultdict(list))
for x in range(1, 5):
    for y in range(1, 4):
        for z in range(1, 11):
            tower[x][y].append(0)

count = int(input())

for x in range(count):
    b, f, r, v = map(int, input().split())
    if v > 0:
        tower[b][f][r-1] += v
    else:
        tower[b][f][r-1] -= -v


for key, value in tower.items():
    for layer, value in value.items():
        print(' ', end='')
        print(' '.join(map(str, value)))
    if key != 4:
        print('

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

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

for i in range(len(house)):
    if (i+1)%4 ==0:
        print(''.join(str(i) for i in house[i]))
    else:
        print('',' '.join(str(i) for i in house[i]))

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

sep = "

for i in range(4):
  for j in range(3):
    print(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9}".format(room[i][j][0],room[i][j][1],room[i][j][2],room[i][j][3],room[i][j][4],room[i][j][5],room[i][j][6],room[i][j][7],room[i][j][8],room[i][j][9]))
  if i < 3:
    print(sep)

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


a = {}
b = {}
c = {}
d = {}

for i in range(1, 31):
    a[i] = 0
    b[i] = 0
    c[i] = 0
    d[i] = 0

n = int(input())

for j in range(n):
    m = list(map(int, input().split()))

    if m[0] == 1:
        a[m[2] + 10 * (m[1] - 1)] = a[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 2:
        b[m[2] + 10 * (m[1] - 1)] = b[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 3:
        c[m[2] + 10 * (m[1] - 1)] = c[m[2] + 10 * (m[1] - 1)] + m[3]

    elif m[0] == 4:
        d[m[2] + 10 * (m[1] - 1)] = d[m[2] + 10 * (m[1] - 1)] + m[3]

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(a[j + 10 * (i - 1)]), end='')
    print()

print('

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(b[j + 10 * (i - 1)]), end='')
    print()

print('

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(c[j + 10 * (i - 1)]), end='')
    print()

print('

for i in range(1, 4):
    for j in range(1, 11):
        print(' {0}'.format(d[j + 10 * (i - 1)]), end='')
    print()

Solution (Python):
F = [0 for i in range(10)]
def dfloor(l):
    f = F.copy()
    f[l[0]-1] = l[1]
    return f

H = {1:[F,F,F],
    2:[F,F,F],
    3:[F,F,F],
    4:[F,F,F]}
N = int(input())
p = 0
for n in range(N):
    a,b,c,d = tuple(int(n) for n in input().split())
    H[a][b-1] = [H[a][b-1][h]+dfloor([c,d])[h] for h in range(10)]
for I in H.values():
    p += 1
    for i in I:
        print(" " + " ".join(map(str,i)))
    if p != 4:
        print("

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

n = int(input())
for l in range(n):
    
    b, f, r, v = map(int, input().split())
    roomsOfBuilding[b - 1][f - 1][r - 1] += v
counter = 0
for building in roomsOfBuilding:
    counter += 1
    for rooms in building:
        for room in rooms:
            print(' ' + str(room), end='')
        print('')
    if counter < 4:
        print('

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

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

Solution (Python):
home = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
N = int(input())
for i in range(N):
    a, b, c, d = map(int, input().split())
    home[a - 1][b - 1][c - 1] += d
for i in range(3):
    for j in range(3):
        for k in range(10):
            print(' ' + str(home[i][j][k]), end ='')
        print()
    print('
for j in range(3):
    for k in range(10):
        print(' ' + str(home[3][j][k]), end ='')
    print()

Solution (Python):
情報数 = int(input())

現在の校舎状態 = [[[0 for x in range(10)] for y in range(3)] for z in range(4)]

for i in range(情報数):
    棟, 階, 部屋番号, 追加人数 = map(int, input().split())
    現在の校舎状態[棟-1][3-階][部屋番号-1] += 追加人数

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ", end='')
            print(現在の校舎状態[i][2-j][k], end='')
        print()
    if i != 3:
        print("