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

Solution (Python):
import sys
def reviewRe():
    
    for area in range(4):
        for floor in range(3):
            sys.stdout.write(' ')
            print ' '.join(map(str,residence[area][floor][:]))
        if area <= 2:
            print "

def move_in():
    n=input()
    for i in range(n):
        b,f,r,v = map(int,raw_input().split())
        adding(b,f,r,v)

def adding(b,f,r,v):
    residence[b-1][f-1][r-1] += v


if __name__ == '__main__':
    residence = [[[0 for room in range(10)] for floor in range(3)] for area in range(4)]
    move_in()
    reviewRe()

Solution (Python):


import sys
import copy


def main():
    n = int(sys.stdin.readline())
    separator = '

    room, floor = 10, 3;
    building1 = [[0 for col in range(room)] for row in range(floor)]
    building2 = copy.deepcopy(building1)
    building3 = copy.deepcopy(building1)
    building4 = copy.deepcopy(building1)

    buildings = {1 : building1,
                 2 : building2,
                 3 : building3,
                 4 : building4
    }

    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    for idx, (key, value) in enumerate(buildings.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if idx < 3:
            print(separator)


if __name__ == '__main__':
    main()

Solution (Python):


import sys


def generate_buidlings(building, floor, room):
    empty_buildings = {
            key: [[0 for col in range(room)] for row in range(floor)]
            for key in range(1, building+1)
    }
    return empty_buildings


def occupy_buildings(empty_buildings):
    occupied_buildings = generate_buidlings(4, 3, 10)
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        occupied_buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return occupied_buildings


def print_residents():
    separator = '
    occupied_buildings = occupy_buildings(generate_buidlings(4, 3, 10))

    for idx, (key, value) in enumerate(occupied_buildings.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if idx < 3:
            print(separator)


def main():
    print_residents()


if __name__ == '__main__':
    main()

Solution (Python):


import sys


def generate_buidlings(building, floor, room):
    empty_buildings = {
            key: [[0 for col in range(room)] for row in range(floor)]
            for key in range(1, building+1)
    }
    return empty_buildings


def occupy_buildings(empty_buildings):
    occupied_buildings = generate_buidlings(4, 3, 10)
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        occupied_buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return occupied_buildings


def print_buildings():
    separator = '
    occupied_buildings = occupy_buildings(generate_buidlings(4, 3, 10))

    for idx, (key, value) in enumerate(occupied_buildings.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if idx < 3:
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Solution (Python):


import sys




















def generate_buidlings_with_residents(building, floor, room):
    buildings = {
            key: [[0 for col in range(room)] for row in range(floor)]
            for key in range(1, building+1)
    }

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return buildings


def print_buildings():
    separator = '
    buildings_with_residents = generate_buidlings_with_residents(4, 3, 10)

    for idx, (key, value) in enumerate(buildings_with_residents.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if key < len(buildings_with_residents):
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Solution (Python):


import sys




















def generate_buidlings_with_residents(building, floor, room):
    buildings = {
        key: [[0 for col in range(room)] for row in range(floor)]
        for key in range(1, building+1)
    }

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return buildings


def print_buildings():
    separator = '
    buildings_with_residents = generate_buidlings_with_residents(4, 3, 10)

    for idx, (key, value) in enumerate(buildings_with_residents.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if key < len(buildings_with_residents):
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Solution (Python):


import sys


def generate_buidlings_with_residents(building, floor, room):
    buildings = {
        key: [[0 for col in range(room)] for row in range(floor)]
        for key in range(1, building+1)
    }

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return buildings


def print_buildings():
    separator = '
    buildings_with_residents = generate_buidlings_with_residents(4, 3, 10)

    for idx, (key, value) in enumerate(buildings_with_residents.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if key < len(buildings_with_residents):
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Solution (Python):


import sys


def generate_buidlings_with_residents(building, floor, room):
    buildings = {
        key: [[0 for col in range(room)] for row in range(floor)]
        for key in range(1, building+1)
    }

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return buildings


def print_buildings():
    separator = '
    buildings_with_residents = generate_buidlings_with_residents(4, 3, 10)

    for idx, (key, value) in enumerate(buildings_with_residents.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if key < len(buildings_with_residents):
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Solution (Python):
a_1= [[0 for i in range(10)] for j in range(3)]
a_2= [[0 for i in range(10)] for j in range(3)]
a_3= [[0 for i in range(10)] for j in range(3)]
a_4= [[0 for i in range(10)] for j in range(3)]

def print_ninzu(a):
    print("",end=" ")
    print(" ".join(map(str,a[0])))
    print("",end=" ")
    print(" ".join(map(str,a[1])))
    print("",end=" ")
    print(" ".join(map(str,a[2])))

n = int(input())
for i in range(n):
    com = list(map(int,input().split()))
    if com[0] == 1:
        a_1[com[1]-1][com[2]-1] += com[3]
    if com[0] == 2:
        a_2[com[1]-1][com[2]-1] += com[3]
    if com[0] == 3:
        a_3[com[1]-1][com[2]-1] += com[3]
    if com[0] == 4:
        a_4[com[1]-1][com[2]-1] += com[3]    
        
print_ninzu(a_1)
print("
print_ninzu(a_2)
print("
print_ninzu(a_3)
print("
print_ninzu(a_4)

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

N = int(input())

i = 0
while i < N:
	b, f, r, v = map(int,input().split())
	All[b-1][f-1][r-1] += v
	i += 1

for x in range(4):
	for y in range(3):
		for z in range(10):
			print(" {}".format(All[x][y][z]), end = "")
			if z == 9:
				print("")
	if x != 3 and y == 2:
		for j in range(20):
			print("
		print("")

Solution (Python):
n = int(input())
data = {}
for i in range(n):
    b, f, r, v = map(int, input().split())
    if (b,f,r) in data:
        data[(b,f,r)] = data[(b,f,r)] + v
    else:
        data[(b,f,r)] = v
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            if (b,f,r) in data:
               print(" "+str(data[(b,f,r)]),end="")
            else:
                print(" 0",end="")
        print("")
    if b < 4:
        print("

Solution (Python):
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for i in range(n):
    b,f,r,v = [int(i) for i in input().split()]
    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):
class Residents:

    def __init__(self):
        self.official_house = []

        for b in range(4):
            self.official_house.append([])
            for f in range(3):
                self.official_house[b].append([])
                for r in range(10):
                    self.official_house[b][f].append(0)

    def move_in(self, building, floor, room, num):
        building -= 1
        floor -= 1
        room -= 1
        if self.official_house[building][floor][room] + num > 9:
            self.official_house[building][floor][room] = 9 
        else:
            self.official_house[building][floor][room] += num 

    def move_out(self, building, floor, room, num):
        building -= 1
        floor -= 1
        room -= 1
        if self.official_house[building][floor][room] < num:
            self.official_house[building][floor][room] = 0 
        else:
            self.official_house[building][floor][room] -= num 

    def show(self, building, floor, room):
        building -= 1
        floor -= 1
        room -= 1
        return self.official_house[building][floor][room]

    def output(self):
        result = ''
        for b in range(4):
            if b > 0:
                result += '
            for f in range(3):
                for r in range(10):
                    result += ' ' + str(self.official_house[b][f][r])
                result += '\n'

        return result

if __name__ == '__main__':

    residents = Residents()
    rows = int(input())

    for i in range(rows):
        (b, f, r, num) = [int(i) for i in input().split(' ')]
        if num > 0:
            residents.move_in(b, f, r, num)
        else:
            residents.move_out(b, f, r, num * -1)

    print(residents.output(), end='')

Solution (Python):
of = [[0 for i in range(10)] for j in range(12)]

n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    of[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(" ",of[i][j],sep="",end="")
    print("")

Solution (Python):
place = []
bn,fn,rn=[4,3,10]
for i in range(bn):
    place.append([])
    for j in range(fn):
        place[i].append([])
        for k in range(rn):
            place[i][j].append(0)

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

for i in range(bn):
    for j in range(fn):
        line = ""
        for k in range(rn):
            line += " "
            line += str(place[i][j][k])
        print(line)
    if(i == bn -1):
        break
    mark = ""
    for i in range(20):
        mark += "
    print(mark)

Solution (Python):
line = int(input())
nums = [[[0 for x in range(0, 10)] for x in range(0, 3)] for x in range(0, 4)]
input1 = []
for i in range(line):
    input1.append(input())


for e in input1:
    efbv =  e.split(" ")
    e_b, e_f, e_r, e_v = map(int, efbv)
    nums[e_b - 1][e_f - 1][e_r -1] += e_v

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

Solution (Python):
import sys
n = int(input())
list_room = [0 for i in range(120)]

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



for i in range(4):
	for j in range(3):
		line = ""
		for k in range(10):
			line += " "+str(list_room[i*30 + j*10 + k])			
		print(line)
	if i != 3:	
		print("

Solution (Python):
n = int(input())
public_hall = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
input_info = []

for b in range(4):
    for f in range(3):
        for r in range(10):
            public_hall[b][f].append(0)

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

for j in range(n):
    public_hall[input_info[j][0] - 1][input_info[j][1] - 1][input_info[j][2] - 1] += input_info[j][3]

for k in range(4):
    for l in range(3):
        for m in range(10):
            print('', public_hall[k][l][m],end='')
        print()
    if k != 3:
        print('

Solution (Python):
res = ['-']
for mak in range(12) :
    tem = ['0' for temp in range(10)]
    res.append(tem)

for mak in range(int(input())) :
    a, b, c, d    = [int(temp) for temp in input().split()]
    res[((a - 1) * 3) + b][c - 1] = str(int(res[((a - 1) * 3) + b][c - 1]) + d)

for mak in range(1,13) :
    if mak != 1 and mak % 3 == 1 :
        print(('
    print('', ' '.join(res[mak]))

Solution (Python):
n = int(input())
array = [input().split() for i in range(n)]
b_1 = []
b_2 = []
b_3 = []
b_4 = []
zero = "0 0 0 0 0 0 0 0 0 0"
for i in range(3):
    b_1.append(zero.split())
    b_2.append(zero.split())
    b_3.append(zero.split())
    b_4.append(zero.split())
for i in range(n):
    b = int(array[i][0])
    f = int(array[i][1])
    r = int(array[i][2])
    v = int(array[i][3])
    if b == 1:
        b_1[f-1][r-1] = str(int(b_1[f-1][r-1])+v)
    elif b == 2:
        b_2[f-1][r-1] = str(int(b_2[f-1][r-1])+v)
    elif b == 3:
        b_3[f-1][r-1] = str(int(b_3[f-1][r-1])+v)
    else:
        b_4[f-1][r-1] = str(int(b_4[f-1][r-1])+v)
for i in range(4):
    for i2 in range(3):
        for i3 in range(10):
            if i == 0:
                if i3 == 9:
                    print(b_1[i2][i3])
                elif i3 == 0:
                    print(" "+b_1[i2][i3],end=" ")
                else:
                    print(b_1[i2][i3],end=" ")
            elif i == 1:
                if i3 == 9:
                    print(b_2[i2][i3])
                elif i3 == 0:
                    print(" "+b_2[i2][i3],end=" ")
                else:
                    print(b_2[i2][i3],end=" ")
            elif i == 2:
                if i3 == 9:
                    print(b_3[i2][i3])
                elif i3 == 0:
                    print(" "+b_3[i2][i3],end=" ")
                else:
                    print(b_3[i2][i3],end=" ")
            else:
                if i3 == 9:
                    print(b_4[i2][i3])
                elif i3 == 0:
                    print(" "+b_4[i2][i3],end=" ")
                else:
                    print(b_4[i2][i3],end=" ")
    if i == 3:
        break
    else:
        print("

Solution (Python):
arr = [[[0 for i1 in range(10)] for i2 in range(3)] for i3 in range(4)]

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

first_b = arr[0]
second_b = arr[1]
third_b = arr[2]
fourth_b= arr[3]

for m in range(3):
    for n in range(10):
        print(" "+str(first_b[m][n]),end="")
    print()
print("
for m in range(3):
    for n in range(10):
        print(" "+str(second_b[m][n]),end="")
    print()
print("
for m in range(3):
    for n in range(10):
        print(" "+str(third_b[m][n]),end="")
    print()
print("
for m in range(3):
    for n in range(10):
        print(" "+str(fourth_b[m][n]),end="")
    print()

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

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

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

Solution (Python):


import sys
import os


def get_house():
    return [[0 for i in range(10)] for j in range(3)]

def print_house(h):
    for i in range(3):
        for j in range(10):
            print(' ', end='')
            print(h[i][j], end='')
        print()

houses = []
for i in range(4):
    houses.append(get_house())

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

for i in range(4):
    print_house(houses[i])
    if i != 3:
        print('

Solution (Python):


c1 = {1:[0]*10,2:[0]*10,3:[0]*10}
c2 = {1:[0]*10,2:[0]*10,3:[0]*10}
c3 = {1:[0]*10,2:[0]*10,3:[0]*10}
c4 = {1:[0]*10,2:[0]*10,3:[0]*10}

n = int(input())

for i in range(n):
    b,f,r,v = input().rstrip().split(" ")
    if int(b) == 1:
        c1[int(f)][int(r)-1] = c1[int(f)][int(r)-1] + int(v)
    elif int(b) == 2:
        c2[int(f)][int(r)-1] = c2[int(f)][int(r)-1] + int(v)
    elif int(b) == 3:
        c3[int(f)][int(r)-1] = c3[int(f)][int(r)-1] + int(v)
    else:
        c4[int(f)][int(r)-1] = c4[int(f)][int(r)-1] + int(v)


for i in (1,2,3):
    result = " " + str(c1[i][0])
    for j in range(1,10):
        result = result + " " + str(c1[i][j])
    print(result)
print("
for i in (1,2,3):
    result = " " + str(c2[i][0])
    for j in range(1,10):
        result = result + " " + str(c2[i][j])
    print(result)
print("
for i in (1,2,3):
    result = " " + str(c3[i][0])
    for j in range(1,10):
        result = result + " " + str(c3[i][j])
    print(result)
print("
for i in (1,2,3):
    result = " " + str(c4[i][0])
    for j in range(1,10):
        result = result + " " + str(c4[i][j])
    print(result)

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())
list = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
	a,b,c,d = [int(j) for j in input().split()]
	list[a-1][b-1][c-1] += d
for i in range(4):
	for j in range(3):
		for k in range(10):
			print(" {0}".format(list[i][j][k]),end='')
		print()
	if i != 3:
		print("

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

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

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(S[i][j][k]), end = "")
        print("")
    if i == 3:
        break
    print("

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

for B in D[:-1]:
    for F in B:
        print(' ' + ' '.join(map(str,F)))
    print('
for F in D[-1]:
    print(' ' + ' '.join(map(str,F)))

Solution (Python):






def func():
    try:
        line = input()
    except:
        return inputError()
        
    (buildings,floors,rooms,maxnumber)=(4,3,10,9)
    tenants=[ [ [0 for i in range(rooms)] for j in range(floors)] for k in range(buildings)]
   
    while(True):
        try:
            line=input().rstrip()
            info=line.split(" ")
            (building, floor, room, number)=( int(info[0])-1, int(info[1])-1, int(info[2])-1, int(info[3]) )
        except EOFError:
            break
        except:
            return inputError()
        
        if( (building >= 0) and (building < buildings) ):
            if( (floor >= 0) and (floor < floors) ):
                if( (room >= 0) and (room < rooms) ):
                    if( (tenants[building][floor][room]+number >= 0) and (tenants[building][floor][room]+number < maxnumber+1) ): 
                        tenants[building][floor][room] += number
                    else:
                        return inputError()
                else:
                    return inputError()
            else:
                return inputError()
        else:
            return inputError()
    
    result=""
    for i in range(buildings):
        for j in range(floors):
            for k in range(rooms):
                result += " {0}".format(tenants[i][j][k])
            result += "\n"
        if(i+1 < buildings):
            result+="
            
    print(result.rstrip())        
    
def inputError():
    print("input error")
    return -1


func()

Solution (Python):
n = int(input())
info = []

for i in range(n):
    b, f, r, v = input().split()
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    if info == []:
        info.append([b, f, r, v])
    else:
        for x in info:
            if b == x[0] and f  == x[1] and r == x[2]:
                x[3] += v
                isAdded = True
                break
            else:
                isAdded = False
        if isAdded == False:
            info.append([b, f, r, v])

for building in range(4):
    for floor in range(3):
        for room in range(10):
            print(" ", end = '')
            arePeople = False
            for y in info:
                if building + 1 == y[0] and floor + 1 == y[1] and room + 1 == y[2]:
                    print(y[3], end = '')
                    arePeople = True
            if arePeople == False:
                print("0", end = '')
        print('')
    if building < 3:
        print("

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

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

Solution (Python):
build = [[[0]*10,[0]*10,[0]*10],[[0]*10,[0]*10,[0]*10],[[0]*10,[0]*10,[0]*10],[[0]*10,[0]*10,[0]*10]]
n = int(input())
for i in range(n):
    b, f, r, v = [int(x) for x in input().split()]
    build[b-1][f-1][r-1] += v
count = 0
for i1 in build:
    for i2 in i1:
        line = ""
        for i3 in i2:
            line += " " + str(i3)
        print(line)
    if count < 3:
        print("
        count += 1

Solution (Python):
N = int(input())
arr = [[[0 for i in range(10)] for j in range(3)]for r in range(4)]
for i in range(N):
    a=[]
    a.append(list(map(int,input().split())))
    b=a[0][0]-1
    f=a[0][1]-1
    r=a[0][2]-1
    v=a[0][3]
    arr[b][f][r]+=v

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

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

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

for i, bldg in enumerate(bldgs):
    if i > 0:
        print('

    for floor in bldg:
        print(' '+' '.join([str(f) for f in floor]))

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

L11= [0] * 10
L12= [0] * 10
L13= [0] * 10
L21= [0] * 10
L22= [0] * 10
L23= [0] * 10
L31= [0] * 10
L32= [0] * 10
L33= [0] * 10
L41= [0] * 10
L42= [0] * 10
L43= [0] * 10

for i in range(n):
 b,f,r,v = map(int, input().split())
 r -= 1
 if b == 1:
  if f == 1:
   L11[r] += v
  if f == 2:
   L12[r] += v
  if f == 3:
   L13[r] += v
 if b == 2:
  if f == 1:
   L21[r] += v
  if f == 2:
   L22[r] += v
  if f == 3:
   L23[r] += v
 if b == 3:
  if f == 1:
   L31[r] += v
  if f == 2:
   L32[r] += v
  if f == 3:
   L33[r] += v
 if b == 4:
  if f == 1:
   L41[r] += v
  if f == 2:
   L42[r] += v
  if f == 3:
   L43[r] += v

def PV(L):
 for i in range(9):
  print(" "  + str(L[i]), end="")
 print(" " + str(L[9]))

def PL():
 print("

PV(L11)
PV(L12)
PV(L13)
PL()
PV(L21)
PV(L22)
PV(L23)
PL()
PV(L31)
PV(L32)
PV(L33)
PL()
PV(L41)
PV(L42)
PV(L43)

Solution (Python):
def print_residence(residence):
    for i in range(4):
        for j in range(3):
            print " " +" ".join(map(str, residence[i][j]))
        if i != 3:
            print "

n = int(raw_input())
residence = [[[0] * 10 for i in range(3)] for j in range(4)]


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

print_residence(residence)

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

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

Solution (Python):


n = int(input().rstrip())
tatemono=[
[[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)]]]

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

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

    print("

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

Solution (Python):
n = int(input())
arr = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    s = input().split(" ")
    nums = list(map(int, s))
    arr[nums[0]-1][nums[1]-1][nums[2]-1] += nums[3]
for k in range(4):
    for j in range(3):
        for i in range(10):
            print(" {0}".format(arr[k][j][i]),end="")
        print("")
    if k < 3:
        for l in range(20):
            print("
        print("")

Solution (Python):
n=int(input())
data=[[int(num)for num in input().split(' ')] for i in range(n)]
state=[[[0 for i in range(10)]for j in range(3)]for k in range(4)] 
for datum in data:
    state[datum[0]-1][datum[1]-1][datum[2]-1]+=datum[3]
for i in range(4):
    for j in range(3):
        s=""
        for k in range(10):
            s+=' '+str(state[i][j][k])
        print(s)
    if i!=3:
        print("

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

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

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

for b in range(4):
    for f in range(3):
        print(''.join(' {}'.format(a[b][f][r]) for r in range(10)))
    if b<3:
        print('

Solution (Python):
rooms = [0] * (4*3*10)
count = int(input())
for i in range(count):
    b, f, r, v = [int(x) for x in input().split()]
    rooms[30*(b-1) + 10*(f-1) + (r-1)] += v
  
for i, room in enumerate(rooms, start=1):
    print('', room, end='')
    if i%10 == 0:
        print()
    if i%30 == 0 and i%120 != 0:
        print('

Solution (Python):
rooms = [[[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())
    rooms[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print('', rooms[i][j][k], end='')
        print()
    if i < 3:
        print('

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

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

for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(map(str, rooms[b][f])))
    if b is not 3:
        print('