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 fth floor at building b. If v is negative, it means that &minus;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 ith 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



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

Submission status: Accepted

Solution code:
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('#' * 20)

Submission status: Accepted

Solution code:
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('#' * 20)

Submission status: Accepted

Solution code:
H = [[[0 for x in xrange(10)] for j in xrange(3)] for i in xrange(4)]
n = input()

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

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

Submission status: Accepted

Solution code:
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('#' * 20)

Submission status: Accepted

Solution code:
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('#' * 20)

Submission status: Accepted

Solution code:
N = int(input())
A = [[[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, v = [int(j) for j in input().split()]
    A[b-1][f-1][r-1] += v

for a, b in enumerate(A):
    for f in b:
        print(' ' + ' '.join([str(i) for i in f]))
    else:
        if a != len(A) - 1:
            print('#' * 20)

Submission status: Accepted

Solution code:
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(["#" for x in range(20)]))

Submission status: Accepted

Solution code:
n = int(input())
a =[' 0',' 0',' 0',' 0',' 0',' 0',' 0',' 0',' 0',' 0']
A_1 = a.copy()
A_2 = a.copy()
A_3 = a.copy()
B_1 = a.copy()
B_2 = a.copy()
B_3 = a.copy()
C_1 = a.copy()
C_2 = a.copy()
C_3 = a.copy()
D_1 = a.copy()
D_2 = a.copy()
D_3 = a.copy()
ren1 = [A_1,A_2,A_3]
ren2 = [B_1,B_2,B_3]
ren3 = [C_1,C_2,C_3]
ren4 = [D_1,D_2,D_3]
for i in range(n):
    b = input()
    c = b.split(' ')
    ren = int(c[0])
    kai = int(c[1])
    banme = int(c[2])
    nin = int(c[3])
    if nin < 0:
        if ren == 1:
            ren1[kai-1][banme-1] = ' %s'%(int(ren1[kai-1][banme-1])+nin)
        elif ren == 2:
            ren2[kai-1][banme-1] = ' %s'%(int(ren2[kai-1][banme-1])+nin)
        elif ren == 3:
            ren3[kai-1][banme-1] = ' %s'%(int(ren3[kai-1][banme-1])+nin)
        elif ren == 4:
            ren4[kai-1][banme-1] = ' %s'%(int(ren4[kai-1][banme-1])+nin)
    elif ren == 1:
        ren1[kai-1][banme-1] = ' %s'%(int(ren1[kai-1][banme-1])+nin)
    elif ren == 2:
        ren2[kai-1][banme-1] = ' %s'%(int(ren2[kai-1][banme-1])+nin)
    elif ren == 3:
        ren3[kai-1][banme-1] = ' %s'%(int(ren3[kai-1][banme-1])+nin)
    elif ren == 4:
        ren4[kai-1][banme-1] = ' %s'%(int(ren4[kai-1][banme-1])+nin)
print(''.join(A_1))
print(''.join(A_2))
print(''.join(A_3))
print('####################')
print(''.join(B_1))
print(''.join(B_2))
print(''.join(B_3))
print('####################')
print(''.join(C_1))
print(''.join(C_2))
print(''.join(C_3))
print('####################')
print(''.join(D_1))
print(''.join(D_2))
print(''.join(D_3))

Submission status: Accepted

Solution code:
a = [[[0 for z in range(10)] for y in range(3)] for x 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 in range(4):
    for j in range(3):
        print('', *a[i][j])
    if i != 3:
        print('#' * 20)

Submission status: Accepted

Solution code:
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
nums = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for d in data:
    nums[d[0] - 1][d[1] - 1][d[2] - 1] += d[3]
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' ' + str(nums[i][j][k]), end='')
        print('')
    if i != 3:
        print('#' * 20)

Submission status: Accepted

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

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

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

for i in L:
    for j in i:
        print (" {}" * 10).format(*j)
    if i is not L[-1] :print "#" * 20

Submission status: Accepted

Solution code:
rooms = [0] * (4*3*10)
n = input();
for i in xrange(n):
	b,f,r,v = map(int, raw_input().split())
	rooms[(b-1)*30+(f-1)*10+(r-1)] += v

sep = "#" * 20
for b in xrange(4):
	for f in xrange(3):
			t = 30*b + 10*f
			print ""," ".join(map(str, rooms[t:t+10]))
	if b < 3: print sep

Submission status: Accepted

Solution code:
buils = [
    [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
    [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
    [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
    [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]

n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(raw_input())
ans = ""

room = [[[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())
    room[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            ans += " %d" % (room[i][j][k])
        print ans
        ans = ""
    if i != 3:
        print "#"*20

Submission status: Accepted

Solution code:
import sys

# 1????????¢10??????3????????????4?£????????????????????????????????????????
def make_room_data():
    room_data = []
    for i in range(4):
        one_house = []
        for j in range(3):
            one_floor = []
            for k in range(10):
                one_floor.append(0)

            one_house.append(one_floor)

        room_data.append(one_house)

    return room_data
    
def main():
    room_data = make_room_data()
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        data = sys.stdin.readline().strip().split(' ')
        b, f, r, v = [int(i) for i in data]
        room_data[b-1][f-1][r-1] += v

    # ????????¨???
    for i in range(4):
        for j in range(3):
            for k in range(10):
                print(' %d' % (room_data[i][j][k]), end='')

            print('')

        if i != 3:
            print('#' * 20)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
BUILDING = 4
FLOOR = 3
ROOM = 10

resident = []
for i in range(BUILDING):
	building = []
	for j in range(FLOOR):
		floor = []
		for k in range(ROOM):
			floor.append(0)
		building.append(floor)
	resident.append(building)

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

for i in range(BUILDING):
	for j in range(FLOOR):
		output_line = ""
		for k in range(ROOM):
			output_line += " " + str(resident[i][j][k])
		print output_line
	if i != BUILDING-1:
		print "####################"

Submission status: Accepted

Solution code:
N = int(input())
a = [map(int,input().split()) for i in range(N)]
arr = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]
for b,f,r,v in a:
    arr[b-1][f-1][r-1] += v
i=1
for bl in arr:
    for fl in bl:
        print(' '+' '.join(map(str,fl)))
    if i != len(arr):
        print('#'*20)
    i += 1

Submission status: Accepted

Solution code:
b1 = [[0 for i in range(10)] for j in range(3)]
b2 = [[0 for i in range(10)] for j in range(3)]
b3 = [[0 for i in range(10)] for j in range(3)]
b4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
i = 1
while i <= n:
    b, f, r, v = map(int, input().split())
    if (b == 1):
        b1[f-1][r-1] += v
    elif (b == 2):
        b2[f-1][r-1] += v
    elif (b == 3):
        b3[f-1][r-1] += v
    elif (b == 4):
        b4[f-1][r-1] += v
    i += 1

for i in range(3):
    print('', ' '.join(map(str, b1[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b2[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b3[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b4[i])))

Submission status: Accepted

Solution code:
def aaa(strArg):
  str = ''
  for c in strArg:
    str += ' ' + c
  return str

n = [int(input())]

house = ['0' * 30, '0' * 30, '0' * 30, '0' * 30]
hr = '#' * 20

for nn in range(n[0]):
  bfrv = [int(x) for x in input().split()]

  b = bfrv[0] - 1
  f = bfrv[1] - 1
  r = bfrv[2] - 1
  v = bfrv[3]

  pos = (f * 10) + r
  humal = int(house[b][pos]) + v

  house[b] = house[b][:pos] + str(humal) + house[b][pos + 1:]

for ii in range(4):
  print(aaa(house[ii][:10]))
  print(aaa(house[ii][10:20]))
  print(aaa(house[ii][20:]))
  if ii != 3:
    print(hr)

Submission status: Accepted

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

output =[]
for i in range(4):
    for j in range(3):
        output = list(map(str, room_list[i][j]))
        print(" " + " ".join(output))
    if i < 3:
        print("#" * 20)

Submission status: Accepted

Solution code:
F = [[[0] * 10 for i in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
 b, f, r, v = map(int, input().split())
 F[b-1][f-1][r-1] += v
for x in range(0, 4):
 for y in range(0, 3):
  for z in range(0, 10):
   print(" {0}".format(F[x][y][z]), end = '')
  print()
 if x != 3:
  print("#" * 20)

Submission status: Accepted

Solution code:
building = [[[0 for i in range(10)] for i in range(3)]for i in range(4)]

n = input()

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

for B in range(4):
    for F in range(3):
        print " "+ " ".join(map(str,building[B][F]))
    if B != 3:
        print "#"*20

Submission status: Accepted

Solution code:
n = int(input())
h = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
    b, f, r, v = [int(e) for e in input().split()]
    h[b-1][f-1][r-1] += v
for i, b in enumerate(h):
    if i != 0:
        print('#'*20)
    for f in b:
        print(' ', end='')
        print(*f)

Submission status: Accepted

Solution code:
import sys

data = [0] * (4 * 3 * 10)

def get_index(b, f, r):
    return ((b - 1) * 3 + (f - 1)) * 10 + (r - 1)

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

for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            sys.stdout.write(" %d" % data[get_index(b, f, r)])
        sys.stdout.write("\n")
    if b != 4:
        print("#" * 20)

Submission status: Accepted

Solution code:
house = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
    input_4 = list(map(int,input().split()))
    house[input_4[0]-1][input_4[1]-1][input_4[2]-1] += input_4[3]
for i in range(4):
    for j in range(3):
        print('',' '.join(map(str,house[i][j])))
    if i != 3:
        print('#'*20)

Submission status: Accepted

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

n = int(input())
for i in range(n):
    data = list(map(int, input().split()))
    house[data[0]-1][data[1]-1][data[2]-1] += data[3]
    
for i in range(4):
    for j in range(3):
        print('',' '.join(list(map(str,house[i][j]))))
    if i!=3: print('####################')

Submission status: Accepted

Solution code:
#coding:utf-8
x=[[[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=list(map(int,input().split()))

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


for line,i in enumerate(x):
    for j in i:
        for k in j:
            print(" "+str(k),end="")
        print("")

    if line!=3:
        for i in range(20):
            print("#",end="")
        print("")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
person = [[0 for _ in range(10)] for _ in range(12)]

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

for index, p in enumerate(person):
  print(" "+" ".join([str(m) for m in p]))
  if (index+1)%3 == 0 and index < len(person)-1:
    print("####################")

Submission status: Accepted

Solution code:
habitant_dictionary = {}
for building in range(1, 4 + 1):
    habitant_dictionary[building] = [0] * 30

information_number = int(raw_input())
while 0 < information_number:
    data = [int(x) for x in raw_input().split()]
    habitant_dictionary[data[0]][(int(data[1]) - 1) * 10 + (int(data[2]) - 1)] += int(data[3])
    information_number -= 1

for building in range(1, 4 + 1):
    for i in range(0, 30, 10):
        print(' ' + ' '.join([str(x) for x in habitant_dictionary[building][i:i + 10]]))
    if building is not 4:
        print('#' * 20)

Submission status: Accepted

Solution code:
a1 = [[0 for i in range(10)] for j in range(3)]
a2 = [[0 for i in range(10)] for j in range(3)]
a3 = [[0 for i in range(10)] for j in range(3)]
a4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
for i in range(0,n):
    x = [int (z) for z in input().split(' ')]
    if x[0] == 1:
        a1[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 2:
        a2[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 3:
        a3[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 4:
        a4[x[1]-1][x[2]-1] += x[3]

for t in range(0,3):
    for i in a1[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a2[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a3[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a4[t]:
        print(" %d" % i, end='')
    print('')

Submission status: Accepted

Solution code:
room = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(4):
    for j in range(3):
        for k in range(10):
            room[i][j].append(0)
n = int(input())
for _ 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):
        print(" "+" ".join(map(str, room[i][j])))
    if i != 3: print("#"*20)

Submission status: Accepted

Solution code:
h = [ [ [ 0 for x in range(0, 10) ] for y in range(0, 3) ] for z in range(0, 4) ]
for i in range(0, int(input())):
    b,f,r,v = map(int, input().split())
    h[b-1][f-1][r-1] += v
c = 1
for x in h:
    for y in x:
        print(" " + " ".join(map(str, y)))
    if c < 4:
        print("#" * 20)
    c += 1

Submission status: Accepted

Solution code:
class Building(object):
    def __init__(self):
        self.floor = []
        self.floor.extend([[0] * 10])
        self.floor.extend([[0] * 10])
        self.floor.extend([[0] * 10])

    def change_resident(self, f, r, v):
        self.floor[f][r] += v

    def print_status(self):
        for f in self.floor:
            print(' {0}'.format(' '.join(map(str, f))))

if __name__ == '__main__':
    # ?????????4?£??????????
    buildings = []
    for i in range(4):
        buildings.append(Building())

    # ??????????????\???
    data_num = int(input())
    data = []
    for i in range(data_num):
        data.append([int(x) for x in input().split(' ')])

    # ??\?±?????????´??°
    for d in data:
        b = d[0]
        f = d[1]
        r = d[2]
        v = d[3]
        buildings[b-1].change_resident(f-1, r-1, v)

    # ?????????????????¨???
    buildings[0].print_status()
    print('#' * 20)
    buildings[1].print_status()
    print('#' * 20)
    buildings[2].print_status()
    print('#' * 20)
    buildings[3].print_status()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

n = int(input())
matrix = []
while n > 0:
    values = [int(x) for x in input().split()]
    matrix.append(values)
    n -= 1

official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]

Min = 0
Max = 9
for b, f, r, v in matrix:
    num = official_house[b - 1][f - 1][r - 1]
    if Min >= num or Max >= num:
        official_house[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        print('',' '.join(str(x) for x in official_house[i][j]))
    if 3 > i:
        print('#' * 20)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

n = int(input())
matrix = []
while n > 0:
    values = [int(x) for x in input().split()]
    matrix.append(values)
    n -= 1

official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]

Min = 0
Max = 9
for b, f, r, v in matrix:
    num = official_house[b - 1][f - 1][r - 1]
    if Min <= num or Max >= num:
        official_house[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        print('',' '.join(str(x) for x in official_house[i][j]))
    if 3 > i:
        print('#' * 20)

Submission status: Accepted

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

Submission status: Accepted

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

s = ""
for i in range(4):
    for j in range(3):
        for k in range(10):
            s += " " + str(h[i][j][k])
        s += "\n"
    if i < 3:
        s += "####################\n"

print(s,end="")

Submission status: Accepted

Solution code:
l=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n=int(input())
for i in range(n):
	a,b,c,d=list(map(int,input().split()))
	l[a-1][b-1][c-1]+=d
for i in l[:-1]:
	for j in i:
		print(" "+" ".join(list(map(str,j))))
	print("####################")

for j in l[-1]:
	print(" "+" ".join(list(map(str,j))))

Submission status: Accepted

Solution code:
count = [[[0]*11 for j in range(4)] for i in range(5)]
n = int(input())

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

for b in range(1, 5):
    if b >= 2:
        print("####################")
    for f in range(1, 4):
        for r in range(1, 11):
            print(" ", count[b][f][r], end="", sep="")
        print()

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

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

n = int(input())

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

for i in range(4):
    for j in range(3):
        print(" ",end="")       
        print(" ".join(map(str,num_j[i][j])))
    
    if i != 3:
        print("#"*20)

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

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

n = int(input())

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

for i in range(4):
    for f in num_j[i]:
        print(""," ".join([str(x) for x in f]))
    
    if i != 3:
        print("#"*20)

Submission status: Accepted

Solution code:
import sys
n=input()
house=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(4):
    for j in range(3):
        for k in range(10):
            house[i][j].append(0)
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):
        for k in range(10):
            sys.stdout.write(' %d'%house[i][j][k])
        print('')
    if i!=3:
        print('#'*20)

Submission status: Accepted

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

info = int(input())
for i in range(info):
    b,f,r,v = [int(i) for i in input().split()]
    A[b-1][f-1][r-1] += v
    if A[b-1][f-1][r-1] < 0:
        A[b-1][f-1][r-1] = 0
    elif A[b-1][f-1][r-1] > 9:
        A[b-1][f-1][r-1] = 9

for i in range(3):
    print(' '+' '.join([str(i) for i in A[0][i]]))
print('#'*20)
for i in range(3):
    print(' '+' '.join([str(i) for i in A[1][i]]))
print('#'*20)
for i in range(3):
    print(' '+' '.join([str(i) for i in A[2][i]]))
print('#'*20)
for i in range(3):
    print(' '+' '.join([str(i) for i in A[3][i]]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
'import sys'
d=[[[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(j) for j in input().split()]
    d[b-1][f-1][r-1]+=v
for i, b in enumerate(d):
    for f in b:
        for r in f:
            print(" {}".format(r),end="")
        print()
    if i< 3:
        print("#"*20)

Submission status: Accepted

Solution code:
n = int(input())
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for rec in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v
    
for i, b in enumerate(rooms):
    for f in b:
        print("",*f)
    if i != 3:
        print("####################")

Submission status: Accepted

Solution code:
nb=4
nf=3
nr=10
d = {}
n = int(input())
for i in range(n):
    [b,f,r,v] = map(int, input().split())
    key = "%2d %2d %2d"  % (b,f,r)
    if key in d:
        d[key] += v
    else:
        d[key] = v

for b in range(1,nb+1):
    for f in range(1,nf+1):
        for r in range(1,nr+1):
            key = "%2d %2d %2d" % (b,f,r)
            if key in d:
                print(" "+str(d[key]),end="")
            else:
                print(" "+str(0),end="")
            if r==nr:
                print()
            if r==nr and f==nf and b != nb:
                print('####################')

Submission status: Accepted

Solution code:
building = {1:[],2:[],3:[],4:[]}
for b in range(1, 4+1):
    building[b] = [0 for i in range(3*10)]

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

for b in range(1, 4+1):
    for i in range(3):
        for j in range(10):
            print(" {0}".format(building[b][(i*10)+j]), end="")
        print()
    if b < 4:
        print("#"*20)

Submission status: Accepted

Solution code:
n = int(input())
count = list()
for b in range(4):
    count.append(list())
    for f in range(3):
        count[b].append(list())
        for r in range(10):
            count[b][f].append(0)

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

for b in range(len(count)):
    for f in range(len(count[b])):
        for r in range(len(count[b][f])):
            print("", count[b][f][r], end="")
        print()
    if b < len(count) - 1:
        print("####################")

Submission status: Accepted

Solution code:
#coding:utf-8

apartment = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
N = int(input())
data = [[int(x) - 1 for x in input().split()] for y in range(N)]
for x in data:
	apartment[x[0]][x[1]][x[2]] += x[3] + 1
	if apartment[x[0]][x[1]][x[2]] > 9:
		apartment[x[0]][x[1]][x[2]] = 9
	elif apartment[x[0]][x[1]][x[2]] < 0:
		apartment[x[0]][x[1]][x[2]] = 0
for x in range(4):
	for y in range(3):
		for z in range(10):
			print(" " + str(apartment[x][y][z]), end="")
		print()
	if x != 3:
		print(("#"*20))

Submission status: Accepted

Solution code:
l = [[['0' for i in range(10)] for j in range(3)] for j in range(4)]
for n in range(int(input())):
    b, f, r, v = map(int, input().strip().split())
    l[b-1][f-1][r-1] = str(v + int(l[b-1][f-1][r-1]))
for k in range(4):
    if bool(k):
        print('#'*20)
    for j in l[k]:
        print(' ' + ' '.join(j))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
arr = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)]

n = int(input())
for i in range(n):
    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):
            print(' ',arr[i][j][k],sep = '',end='')
        print('')
    if i != 3:
        print('####################')

Submission status: Accepted

Solution code:
n = int(input())

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

for b in range(len(arrey)):
    for f in range(len(arrey[b])):
        for r in range(len(arrey[b][f])):
            print(' ' + str(arrey[b][f][r]),end='') if r != len(arrey[b][f]) - 1 else print(' ' + str(arrey[b][f][r]))
    if b != len(arrey) - 1:
        print('####################')

Submission status: Accepted

Solution code:
# ??¬????????±
room = [[[0 for a in range(10)] for b in range(3)] for c in range(4)]
n = int(input())
for cnt0 in range(n):
    # ?????°??????????????????
    a,b,c,d = map(int,input().split())
    room[a-1][b-1][c-1]+=d
# ???????????±??????
for cnt1 in range(4):
    for cnt2 in range(3):
        for cnt3 in range(10):
            # OutputPrit
            print(" "+str(room[cnt1][cnt2][cnt3]),end="")
        # ??????
        print ()
    if cnt1<3:
            # ????£???????####################(20??????#)?????????
        print("#"*20)

Submission status: Accepted

Solution code:
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 = [int(i) for i in input().split()]
    a[b-1][f-1][r-1] += v

for i, x in enumerate(a):
    for y in x:
        for z in y:
            print(' %d' % z, end='')
        print('')
    if i < 4 - 1:
        print('####################')

Submission status: Accepted

Solution code:
import sys

a=[]
for t in range(4):
    a.append([])
    for f in range(3):
        a[t].append([])
        for r in range(10):
            a[t][f].append(0)

lines = [line for line in sys.stdin]

n = lines[0]

for l in lines[1:]:
    b, f, r, v  = map(int,l.split())
    b -= 1
    f -= 1
    r -= 1
    a[b][f][r] += v

for i,t in enumerate(a):
    for f in t:
        print (" " +" ".join(map(str,f)))
    if len(a) != i +1:
        print ('#'*20)

Submission status: Accepted

Solution code:
# -*- Coding: utf-8 -*-
# ???????????????
info = [[[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,list(input().split()))
    info[b-1][f-1][r-1] += v

# ???????????????
for i in range(4):
    if i != 0:
        print('####################')
    for j in range(3):
        print(' '+' '.join(map(str,info[i][j])))

Submission status: Accepted

Solution code:
n = int(input())
house = []
for i in range(4):
    house.append([])
    for j in range(3):
        house[i].append([])
        for k in range(10):
            house[i][j].append(0)

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("" , house[i][j][k], end="")
        print()
    if i < 3:
        print("#" * 20)