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




"""
??´?????????
"""

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

number = int(input())

for n in range(number):
    inp = input().split(" ")
    b = int(inp[0]) - 1
    f = int(inp[1]) - 1
    r = int(inp[2]) - 1
    v = int(inp[3])
    rooms[b][f][r] += v

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

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

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

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



for i, b in enumerate(building):
    for f in b:
        for r in f:
            print(" %d"%(r), end="")
        print("")
    if i != 3:
        print ("

Solution (Python):
n=int(input())
x1=[[int(0) for i in range(10)]for j in range(3)]
x2=[[int(0) for i in range(10)]for j in range(3)]
x3=[[int(0) for i in range(10)]for j in range(3)]
x4=[[int(0) for i in range(10)]for j in range(3)]

for i in range(n):
    b,f,r,v=[int(s) for s in input().split()]
    if b==1:
        x1[f-1][r-1]=x1[f-1][r-1]+v
    elif b==2:
        x2[f-1][r-1]=x2[f-1][r-1]+v
    elif b==3:
        x3[f-1][r-1]=x3[f-1][r-1]+v
    else:
        x4[f-1][r-1]=x4[f-1][r-1]+v
for j in range(3):
    for k in range(10):
        print("",x1[j][k],end="")
    print("")
for n in range(20):
    print('
print("")
for j in range(3):
    for k in range(10):
        print("",x2[j][k],end="")
    print("")
for n in range(20):
    print('
print("")
for j in range(3):
    for k in range(10):
        print("",x3[j][k],end="")
    print("")
for n in range(20):
    print('
print("")
for j in range(3):
    for k in range(10):
        print("",x4[j][k],end="")
    print("")

Solution (Python):
n = int(input())
data = [[[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(s) for s in input().split(' ')]
	data[b-1][f-1][r-1] += v

while data:
	building = data.pop(0)
	for floor in building:
		rooms = ' ' + ' '.join([str(room) for room in floor])
		print(rooms)
	if data:
		print('

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

n = int(input())

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

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

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

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

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

  if i != 3:
    print('

Solution (Python):

def make_buildings():
    return [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]

def print_building(building):
    return "\n".join(map(lambda floor: " " + " ".join(map(str, floor)),building))
    
line_number = int(input())
regidents_data = [list(map(int, input().split(" "))) for i in range(line_number)]
buildings = make_buildings()

for data in regidents_data:
    b, f, r, v = data
    buildings[b-1][f-1][r-1] += v

print("\n

Solution (Python):

def format_building(building):
    return "\n".join(map(lambda floor: " " + " ".join(map(str, floor)),building))
    
line_number = int(input())
regidents_data = [list(map(int, input().split(" "))) for i in range(line_number)]
buildings = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]

for data in regidents_data:
    b, f, r, v = data
    buildings[b-1][f-1][r-1] += v

print("\n

Solution (Python):
n=int(input())
nyukyo=[list(map(int, input().split())) for i in range(n)]
bld=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for ny in nyukyo:
    bld[ny[0]-1][ny[1]-1][ny[2]-1]+=ny[3]

for i,b in enumerate(bld):
    for f in b:
        print("",*f)
    if i != 3:
        print("

Solution (Python):
num = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
b, f, r, v, v1, n, x, y, z  = 0, 0, 0, 0, 0, 0, 0, 0, 0
n = int(input())
for i in range(n):
	b, f, r, v = list(map(int, input().split()))
	num[b - 1][f - 1][r - 1] += v
for i in range(4):
	if y >= 1:
		z = 0
		y = 0
		x += 1
		print()
		print('
	for i in range(3):
		if z >= 1:
			z = 0
			y += 1
			print('')
		for i in range(10):
			print('', num[x][y][z], end = '')
			z += 1
print()

Solution (Python):
num = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
b, f, r, v, v1, n, x, y, z  = 0, 0, 0, 0, 0, 0, 0, 0, 0
n = int(input())
for i in range(n):
	b, f, r, v = list(map(int, input().split()))
	num[b - 1][f - 1][r - 1] += v
for i in range(4):
	if y >= 1:
		z = 0
		y = 0
		x += 1
		print()
		print('
	for i in range(3):
		if z >= 1:
			z = 0
			y += 1
			print('')
		for i in range(10):
			print('', num[x][y][z], end = '')
			z += 1
print()

Solution (Python):
data = [[[0 for i in range(10)] for j in range(3)] for h in range(4)]
n = int(input())
for o in range(n):
    a = input().split()
    b = int(a[0])
    f = int(a[1])
    r = int(a[2])
    v = int(a[3])
    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())
residents = [[["0" for rooms in range(10)]for floor in range(3)]for builds in range(4)]

for i in range(N):
    b,f,r,v = list(map(int, input().split()))
    new_number = int(residents[b-1][f-1][r-1])+ v
    residents[b-1][f-1][r-1] = str(new_number)

for buils_num in range(4):
    for floor_num in range(3):
        print(' '+' '.join(residents[buils_num][floor_num]))
    if buils_num < 3:
        print('

Solution (Python):
ls = [[[0 for i in range(10)] for j in range(3)]for s in range(4)]
n = int(input())
for g in range(0,n):
    b,f,r,v = map(int,input().split())
    ls[b-1][f-1][r-1] += v
for k in range(0,4):
    if k == 0:
        pass
    else:
        print("
    for z in range(0,3):
        lis = ""
        for s in range(0,10):
            lis += " "+str(ls[k][z][s])
        print(lis)

Solution (Python):
idx = int(input())
in_dict = {}

for i in range(idx):
    b, f, r, v = (int(x) for x in input().split())
    b -= 1
    f -= 1
    r -= 1
    in_dict[(b,f,r)] = in_dict.get((b,f,r),0) + v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(" ",end="")
            print(in_dict.get((b,f,r),0), end="")
        print("\n", end="")
    if b in range(3):print("

Solution (Python):
def out(bnum):
    print(' '+str(bnum['1f']).replace(',','')[1:10*2])
    print(' '+str(bnum['2f']).replace(',','')[1:10*2])
    print(' '+str(bnum['3f']).replace(',','')[1:10*2])
    
n = int(input())
b1 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b2 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b3 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
b4 = {'1f': [0]*10, '2f': [0]*10, '3f': [0]*10}
for i in range(n):
    b, f, r, v = map(int,input().split())
    r -= 1
    if b == 1:
        b1[repr(f)+'f'][r] += v
    elif b == 2:
        b2[repr(f)+'f'][r] += v
    elif b == 3:
        b3[repr(f)+'f'][r] += v
    elif b == 4:
        b4[repr(f)+'f'][r] += v
out(b1)
print('
out(b2)
print('
out(b3)
print('
out(b4)

Solution (Python):
class myResi():
    def __init__(self):
        self.val=[[0]*10 for _ in range(3)]
    def __str__(self):
        ret = ''
        for i in range(3):
            ret += ' '+(str(self.val[i]).replace(',','')[1:10*2])+'\n'
        return ret.rstrip("\n")
    def setVal(self,f,r,v):
        self.val[f-1][r-1] += v
        
def fill(allb,b,f,r,v):
    bname=allb[b-1]
    bname.setVal(f,r,v)
    
b1=myResi()
b2=myResi()
b3=myResi()
b4=myResi()
allb=[b1,b2,b3,b4]
n=int(input())
for _ in range(n):
    b,f,r,v = map(int,input().split())
    fill(allb,b,f,r,v)
    
print(b1)
print('
print(b2)
print('
print(b3)
print('
print(b4)

Solution (Python):
b_ifo = [[[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())
    b_ifo[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(b_ifo[i][j][k]), end = "")
        print()
    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 " %d %d %d %d %d %d %d %d %d %d" % (row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9])
    if len(rooms) - 1 > number:
        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=[int('0') for i in range(10)]
w=["
z=[]
for i in range(15):
    z+=[a]
    if i == 3 or i== 7 or i== 11:
        z+=[w]
x=[[[0 for i in range(10)] for k in range(3)] for j in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    x[b-1][f-1][r-1]+=v

for i in range(4):
    for k in range(3):
        print(" "+" ".join(str(x[i][k][o]) for o in range(10)))
    if i ==0 or i ==1 or i==2:
        print("

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


building = {b: [[0] * 10, [0] * 10, [0] * 10] for b in range(1, 5)}

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

for b in range(1, 5):
    for level in building[b]:
        print(' ' + ' '.join([str(l) for l in level]))
    if b < 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(" " + str(house[i][j][k]), end="")
        print()
    if j == 3 - 1 and i != 4 - 1:
        print("

Solution (Python):
class OfficialHouse:
    def __init__(self):
        self.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]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]],
                     [[0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0],
                      [0,0,0,0,0,0,0,0,0,0]]]


    def input_bfrv(self, b, f, r, v):
        self.bill[b-1][f-1][r-1] += v

    def result(self):
        for i in range(4):
            for j in range(3):
                print("", ' '.join(map(str, self.bill[i][j])))
            if i != 3:
                print("

oh = OfficialHouse()

n = int(input())

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

   oh.input_bfrv(b, f, r, v)

oh.result()

Solution (Python):
nyukyo = [[[0 for i in range(10)] for m in range(3)] for n in range(4)]
num = int(input())
for i in range(num):
    handan = input().split()
    handan = list(map(int, handan))
    nyukyo[handan[0]-1][handan[1]-1][handan[2]-1] += handan[3]

for m in nyukyo[0]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("
for m in nyukyo[1]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("
for m in nyukyo[2]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("
for m in nyukyo[3]:
    t = list(map(str, m))
    print(" "+" ".join(t))

Solution (Python):
box = [[[0]*10 for i in range(3)] for j in range(4)]
num = int(input())
for i in range(num):
    temp = list(map(int, input().split()))
    box[temp[0]-1][temp[1]-1][temp[2]-1] += temp[3]
    if box[temp[0]-1][temp[1]-1][temp[2]-1] < 0: box[temp[0]-1][temp[1]-1][temp[2]-1] = 0

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

Solution (Python):
a = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
e = '
n = int(input())
for i in range(n):
    b,f,r,v = [int(i) for i in 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(e)

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-11] += v
	
for i in range(12):
	for j in range(10):
		print(" {}".format(list[i][j]), end="")
	print()	
	if ((i + 1) % 3) == 0 and i != 11:
		print("

Solution (Python):
def Input(b, f, rn, h):
    A[b][f][rn] += h

def Output():
    for b in range(4):
        for f in range(4):
            for rn in range(10):
                if f < 3:
                    print(' ' + str(A[b][f][rn]), end = '')
                if f == 3 and b != 3:
                    print('
            if b == 3 and f == 3:
                break
            print()

n = int(input())

A = [[[0 for rn in range(10)] for f in range(3)] for b in range(4)]

for idx in range(n):
    R = input().split()
    B = int(R[0]) - 1
    F = int(R[1]) - 1
    RN = int(R[2]) - 1
    H = int(R[3])
    Input(B, F, RN, H)
Output()

Solution (Python):
house = {1:[[0 for i in range(10)] for j in range(3)], 2:[[0 for i in range(10)] for j in range(3)],
         3:[[0 for i in range(10)] for j in range(3)], 4:[[0 for i in range(10)] for j in range(3)]}
n = int(input())
for i in range(n):
    building, floor, room, people_numbers = [int(j) for j in input().split()]
    house[building][floor - 1][room - 1] += people_numbers

partition = "
for i in range(4):
    for j in range(3):
        tmp_list = [str(tmp) for tmp in house[i + 1][j]]
        print(" {}".format(" ".join(tmp_list)))
        if j == 2 and i != 3: print(partition)

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

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

k = 0
for i in range(4):
    for j in range(3):
        output = " ".join(map(str, table[i][j]))
        print(" %s" % output)
    if k < 3:
        print("
        k += 1

Solution (Python):
from collections import OrderedDict
from itertools import cycle, islice
 
d = OrderedDict(("{} {} {}".format(b, f, r), 0) for b in range(1, 5)
                                                for f in range(1, 4)
                                                for r in range(1, 11))
 
n = int(input())
for _ in range(n):
    s = input()
    idx = s.rfind(" ")
    d[s[:idx]] += int(s[idx+1:])

data = d.values()
delim = "
for i in range(0, 120, 10):
    print(" " + " ".join(map(str, islice(cycle(data), i, i+10))))
    if i in (20, 50, 80):
        print(delim)

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

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

informations=int(input())

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

for i in range(0,4):
    for j in range(0,3):
        for k in range(0,10):
            write(' ')
            write(str(buildings[i][j][k]))
        print()
    if i !=3:
        for j in range(0,20):
            write('
        print()

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

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 c in range(4):
    for d in range(3):print('',*a[c][d])
    if c != 3:print('

Solution (Python):
towers = [
    [[0 for i in range(10)] for j in range(3)] for k in range(4)
]
floor = 3
 
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    towers[b-1][f-1][r-1] += v
 
for b in towers:
    for f in b:
        for r in f:
            print(' ' + str(r), end='')
        print('')
    if floor:
        print('
        floor -= 1

Solution (Python):
N = int(input())
buildings = [[[0 for V in range(10)] for F in range(3)] for B in range(4)]
for i in range(N):
 b, f, r, num = map(int, input().split())
 buildings[b-1][f-1][r-1] += num

for i in range(4):
 for j in range(3):
  for k in range(10):
   print(" {0}".format(buildings[i][j][k]), end="")
  print()
 if i!=3:
  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(' {}'.format(house[i][j][k]), end='')
        print()
    if i != 3:
        print('

Solution (Python):

q = []
for i in range(4):
	b = []
	for j in range(3):
		a = [0 for x in range(10)]
		b.append(a)
	q.append(b)

t = int(input())
for _ in range(t):
	b, f, r, v = [int(x) for x in input().split()]
	q[b-1][f-1][r-1] += v

a = 0
for x in q:
	a += 1
	for y in x:
		for z in range(len(y)):
			print(" {}".format(y[z]), end='')
			if (z==(len(y))-1):
				print()
	if (a!=4):	
		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().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(' %d' %(A[b][f][r]), end='')
        print('')
    if b < 3:
        print('

Solution (Python):
house = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for i in range(int(input())):
    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):
        house[b][f] = ' ' + ' '.join(map(str, house[b][f]))
    house[b] = '\n'.join(map(str, house[b])) + '\n'
border = '
house = border.join(map(str, house))
print(house.rstrip())

Solution (Python):
n = int(raw_input())
 
info = [[[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())
    b, f, r = b-1, f-1, r-1
    info[b][f][r] += v
 
sharp = False
for i in info:
    if sharp:
        print "
    for j in i:
        print " "+" ".join(map(str, j))
    sharp = True

Solution (Python):
x = {}
for i in range(4):
    for j in range(3):
        for k in range(10):
            i,j,k = str(i), str(j), str(k)
            x[i+j+k] = 0

n = int(input())
for i in range(n):
    i,j,k,l = map(int, input().split())
    key = str(i-1)+str(j-1)+str(k-1)
    x[key] = x[key] + int(l)

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

Solution (Python):
import itertools
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 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):
room = [0 for i in range(120)]
c = int(input())
for i in range(c):
    b, f, r, v = [int(s) for s in input().split()]
    index = (30 * (b - 1)) + (10 * (f - 1)) + (r - 1)
    room[index] += v

for i in range(12):
    if (i != 0) and (i % 3 == 0):
        print('
    print(' ' + ' '.join([str(v) for v in room[i*10:i*10+10]]))

Solution (Python):
import sys

nyuukyosha = []

for tou in range(4):
	nyuukyosha.append([])
	for kai in range(3):
		nyuukyosha[tou].append([])
		for heya in range(10):
			nyuukyosha[tou][kai].append(0)

n = int(raw_input())

for i in range(n):
	data = map(int, raw_input().split())
	a = data[0] - 1
	b = data[1] - 1
	c = data[2] - 1
	nyuukyosha[a][b][c] += data[3]

for tou in range(4):
	for kai in range(3):
		for heya in range(10):
			sys.stdout.write(" {:}".format(nyuukyosha[tou][kai][heya]))
		print("")
	if tou < 3:
		print("

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

for i in range(n):
    data = [int(j) for j in list(input().split())]
    tower = data[0]-1
    rank = data[1]-1
    room = data[2]-1
    dormitory[tower][rank][room] += data[3]

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

Solution (Python):
residence=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
lines=[input() for i in range(n)]
for l in lines:
    k=list(map(int,l.split()))
    residence[k[0]-1][k[1]-1][k[2]-1]+=k[3]
    if residence[k[0]-1][k[1]-1][k[2]-1]>9: residence[k[0]-1][k[1]-1][k[2]-1]=9

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

Solution (Python):
def main():
    
    n = int(input())
    movements = [list(map(int, input().split())) for i in range(n)]
    houses = [[[0 for room in range(10)] for floor in range(3)] for building in range(4)]
    
    for move in movements:
        [b, f, r, v] = move
        houses[b-1][f-1][r-1] += v
    
    for index, building in enumerate(houses):
        for floor in building:
            print(' ' + ' '.join(map(str,floor)))
        if index != 3: print('


main()

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

tenant = [
    [ [0]*10, [0]*10, [0]*10, ],
    [ [0]*10, [0]*10, [0]*10, ],
    [ [0]*10, [0]*10, [0]*10, ],
    [ [0]*10, [0]*10, [0]*10, ]
]


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

for b in range(4):
    for f in range(3):
        print(' ', end='')
        print(' '.join(map(str,tenant[b][f])))
    if b < 3:
        print('

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 main(args):
    residents = [[[0] * 10 for _ in range(3)] for _ in range(4)]
    n = int(input())
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        residents[b-1][f-1][r-1] += v

    for i in range(4):
        for j in range(3):
            t = ''
            for k in range(10):
                t += '{:2d}'.format(residents[i][j][k])
            print(t)
        if i != 3:
            print('



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

Solution (Python):
import sys

def main():
    lines = sys.stdin.readlines()

    
    rooms = [0] * 10
    floors = [rooms] * 3
    buildings = [floors] * 4

    data_num = 0

    for index, line in enumerate(lines):
        
        
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   
            f = int(elems[1]) - 1   
            r = int(elems[2]) - 1   
            v = int(elems[3])       
            
            
            ans = []
            for b_i in range(0, 4):
                b_list = []
                for f_i in range(0, 3):
                    f_list = []
                    for r_i in range(0, 10):
                        if b == b_i and f == f_i and r == r_i:
                            f_list.append(buildings[b_i][f_i][r_i] + v)
                        else:
                            f_list.append(buildings[b_i][f_i][r_i])
                    b_list.append(f_list)
                ans.append(b_list)
            
            buildings = ans

    for b_i in range(0, 4):
        for f_i in range(0, 3):
            for r_i in range(0, 10):
                sys.stdout.write(' %d' % buildings[b_i][f_i][r_i])
            sys.stdout.write('\n')
        if b_i != 3:
            print "



if __name__ == "__main__":
    main()

Solution (Python):


import fileinput
import math

def main():
    offiHouse = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]   

    n = int(input())

    for i in range(n):
        a, b, c, d = map(int, input().split())

        offiHouse[a-1][b-1][c-1] += d

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

if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
    for k in l[i]:print("",*k)
    if i!=3:print("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("

Solution (Python):
R=range
I=input
p=print
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(I())):b,f,r,v=map(int,I().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:p("",*k)
 if i!=3:p("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
for i in R(int(input())):b,f,r,v=map(int,input().split());l[b-1][f-1][r-1]+=v
for i in R(4):
 for k in l[i]:print("",*k)
 if i!=3:print("

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
n=int(input())
for a 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 k in l[b]:
        print('',*k)
    if b<3:
        print('

Solution (Python):
R=range
l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)]
n=int(input())
for a 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 k in l[b]:
        print('',*k)
    if b<3:
        print('

Solution (Python):
import sys
n=int(input())
a=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
    w=input().split()
    b=(int(w[0]))
    f=(int(w[1]))
    r=(int(w[2]))
    v=(int(w[3]))
    a[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(" {0}".format(a[i][j][k]))
        sys.stdout.write("\n")
    if (i!=3):
        for x in range(20):
            sys.stdout.write("
        sys.stdout.write("\n")

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