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: Wrong Answer

Solution code:
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 == 4:
        break
    print("####################")

Submission status: Wrong Answer

Solution code:
D = [[[0 for x 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

S = '#'*20

for B in D:
    for F in B:
        print(' ' + ' '.join(map(str,F)))
    if B != 3:
        print('#'*20)

Submission status: Wrong Answer

Solution code:
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 X in D:
    for Y in X:
        print(' ' + ' '.join(map(str,Y)))
    if X != 3:
        print('#'*20)

Submission status: Wrong Answer

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

# coding: utf-8
# Here your code !

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"
        result+="#"*rooms*2+"\n"
            
    print(result.rstrip())        
    
def inputError():
    print("input error")
    return -1


func()

Submission status: Wrong Answer

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

# coding: utf-8
# Here your code !

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+="#"*rooms*2+"\n"
            
    print(result.rstrip())        
    
def inputError():
    print("input error")
    return -1


func()

Submission status: Wrong Answer

Solution code:
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 
            else:
                info.append([b, f, r, v])
            break

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 = '')
        #if floor == 2 and building == 3:
            #break
        print('')
    if building < 3:
        print("####################")

Submission status: Wrong Answer

Solution code:

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

print(info)

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

Submission status: Wrong Answer

Solution code:
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]:
        for x in f:
            print(x)
    if b1 != 3:
        print("#" * 20)

Submission status: Wrong Answer

Solution code:
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())))
    print(a)
    b=a[0][0]-1
    f=a[0][1]-1
    r=a[0][2]-1
    v=a[0][3]
    arr[b][f][r]+=v
print(arr[2][2])

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

Submission status: Wrong Answer

Solution code:
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 bldg in bldgs:
    for floor in bldg:
        print(' '.join([str(f) for f in floor]))
    print('#'*20)

Submission status: Wrong Answer

Solution code:
def print_residence(residence):
    for i in range(4):
        for j in range(3):
            print " ".join(map(str, residence[i][j]))
        print "####################"

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

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

print_residence(residence)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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(*l[i][j], end = " ")
	if i != 3:
		print("####################")

Submission status: Wrong Answer

Solution code:
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())
    print(b,f,r,v)
    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("####################")

Submission status: Wrong Answer

Solution code:
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] += v

for i, room in enumerate(rooms):
    if i%30 == 0:
        print('#'*20)
    if (i+1)%10 == 0:
        print(room)
    else:
        print(room, end=' ')

Submission status: Wrong Answer

Solution code:
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):
    if i%30 == 0:
        print('#'*20)
    if (i+1)%10 == 0:
        print(room)
    else:
        print(room, end=' ')

Submission status: Wrong Answer

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 = input().split()
    b = int(b) - 1
    f = int(f) - 1
    r = int(r) - 1
    v = int(v)
    a[b][f][r] = v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {0}".format(a[i][j][k]), end = "")
        print()
    if i != 3:
        print("#" * 20)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

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):
        for r in range(10):
            print(rooms[b][f][r], end = "")
        print()

Submission status: Wrong Answer

Solution code:


#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

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

Submission status: Wrong Answer

Solution code:
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[::-1]:
        for r in f[:-1]:
            print("%d "%(r), end="")
        print("%d"%(f[-1]))
    if i != 3:
        print ("####################")

Submission status: Wrong Answer

Solution code:
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[:-1]:
            print("%d "%(r), end="")
        print("%d"%(f[-1]))
    if i != 3:
        print ("###################")

Submission status: Wrong Answer

Solution code:
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]=x1[f-1][r-1]+v
    elif b==3:
        x3[f-1][r-1]=x1[f-1][r-1]+v
    else:
        x4[f-1][r-1]=x1[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('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x2[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x3[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x4[j][k],end="")
    print("")

Submission status: Wrong Answer

Solution code:
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 b in bld:
    for f in b:
        print(*f)
    print("####################")

Submission status: Wrong Answer

Solution code:
num = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
b, f, r, v, n, x, y, z  = 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()

Submission status: Wrong Answer

Solution code:
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
    count = 0
    counta = 0
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
b1 = {'f1': [0]*9, 'f2': [0]*9, 'f3': [0]*9}
b2 = {'f1': [0]*9, 'f2': [0]*9, 'f3': [0]*9}
b3 = {'f1': [0]*9, 'f2': [0]*9, 'f3': [0]*9}
b4 = {'f1': [0]*9, 'f2': [0]*9, 'f3': [0]*9}

n= int(input())
for i in range(n):
    b, f, r, v = input().split()
    fstr= 'f' + f
    rint= int(r) - 1
    vint= int(v)
    if b == '1':
        b1[fstr][rint]+=vint
    elif b == '2':
        b2[fstr][rint]+=vint
    elif b == '3':
        b3[fstr][rint]+=vint
    elif b == '4':
        b4[fstr][rint]+=vint

print(str(b1['f1']).replace(',','')[1:9*2])
print(str(b1['f2']).replace(',','')[1:9*2])
print(str(b1['f3']).replace(',','')[1:9*2])
print('#'*20)

print(str(b2['f1']).replace(',','')[1:9*2])
print(str(b2['f2']).replace(',','')[1:9*2])
print(str(b2['f3']).replace(',','')[1:9*2])
print('#'*20)

print(str(b3['f1']).replace(',','')[1:9*2])
print(str(b3['f2']).replace(',','')[1:9*2])
print(str(b3['f3']).replace(',','')[1:9*2])
print('#'*20)


print(str(b4['f1']).replace(',','')[1:9*2])
print(str(b4['f2']).replace(',','')[1:9*2])
print(str(b4['f3']).replace(',','')[1:9*2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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] = str(v)

for i in rooms:
    for j in i: 
        print(' '.join(j))
    print('####################')

Submission status: Wrong Answer

Solution code:
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] = str(v)

for number, i in enumerate(rooms):
    for j in i: 
        print(" %s" % ' '.join(j))
    if len(rooms) - 1 > number:
        print('####################')

Submission status: Wrong Answer

Solution code:
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][0]:
    print(m, end=" ")
for m in nyukyo[0][1]:
    print(m, end=" ")
for m in nyukyo[0][2]:
    print(m, end=" ")
print("#"*20)
for m in nyukyo[1][0]:
    print(m, end=" ")
for m in nyukyo[1][1]:
    print(m, end=" ")
for m in nyukyo[1][2]:
    print(m, end=" ")
print("#"*20)
for m in nyukyo[2][0]:
    print(m, end=" ")
for m in nyukyo[2][1]:
    print(m, end=" ")
for m in nyukyo[2][2]:
    print(m, end=" ")
print("#"*20)
for m in nyukyo[3][0]:
    print(m, end=" ")
for m in nyukyo[3][1]:
    print(m, end=" ")
for m in nyukyo[3][2]:
    print(m, end=" ")

Submission status: Wrong Answer

Solution code:
house = [[[0]*8 for i in range(3)] for i in range(4)]
num = int(input())

for i in range(num):
	temp = list(map(int, input().split()))
	house[temp[0]-1][temp[1]-1][temp[2]-1] = temp[3]

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

Submission status: Wrong Answer

Solution code:
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 = "#"*20
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
table = [[[str(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] = str(v)

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

Submission status: Wrong Answer

Solution code:
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 = cycle(d.values())
delim = "#" * 20
for i in range(0, 120, 10):
    print(" ".join(map(str, islice(data, i, i+10))))
    if i in (20, 50, 80):
        print(delim)

Submission status: Wrong Answer

Solution code:
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:])
    print(d[s[:idx]], s[idx+1:])

data = d.values()
delim = "#" * 20
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)

Submission status: Wrong Answer

Solution code:
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(str(buildings[i][j][k]))
        print()
    if i !=3:
        for j in range(0,10):
            write('#')
        print()

Submission status: Wrong Answer

Solution code:
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 "#"*20
    for j in range(3):
        pri = ""
        for k in range(10):
            pri += " "+ str(lst[i][j][k])
        print pri

Submission status: Wrong Answer

Solution code:
N = int(input())
buildings = [[[0]*10]*3]*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("####################")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for x in q:
	for y in x:
		for z in range(len(y)):
			print(" {}".format(y[z]), end='')
			if (z==(len(y))-1):
				print()
	print("#"*20)

Submission status: Wrong Answer

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

i = 0
for x in q:
	i += 1
	for y in x:
		for z in range(len(y)):
			print(" {}".format(y[z]), end='')
			if (z==(len(y))-1):
				print()
	if (i!=t):	
		print("#"*20)

Submission status: Wrong Answer

Solution code:
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(3, -1, -1):
    for f in range(2, -1, -1):
        house[b][f].reverse()
        print(' ' + ' '.join(map(str, house[b][f])))
    print('####################')

Submission status: Wrong Answer

Solution code:
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):
        print(' ' + ' '.join(map(str, house[b][f])))
    print('####################')

Submission status: Wrong Answer

Solution code:
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'
house = '#' * 20 + '\n' + '\n'.join(map(str, house))
print(house)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
residence=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
input()
lines=sys.stdin.readlines()
for l in lines:
    k=list(map(int,l.split()))
    residence[k[0]-1][k[1]-1][k[2]-1]=k[3]
for b in range(4):
    for f in range(3):
        print(' '.join(map(str,residence[b][f])))
        if b!=3: print('#'*20)

Submission status: Wrong Answer

Solution code:
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]
for b in range(4):
    for f in range(3):
        print(' '+' '.join(map(str,residence[b][f])))
    if b!=3: print('#'*20)

Submission status: Wrong Answer

Solution code:
import sys

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

    # The number of rooms
    rooms = [0] * 10
    floors = [rooms] * 3
    buildings = [floors] * 4

    data_num = 0

    for index, line in enumerate(lines):
        #print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if index == 0:
            data_num = int(elems[0])
        else:
            b = int(elems[0]) - 1   # as index
            f = int(elems[1]) - 1   # as index
            r = int(elems[2]) - 1   # as index
            v = int(elems[3])       # as data
            # print v
            print buildings[b][f][r]
            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:
                            # print buildings[b][f][r]
                            f_list.append(buildings[b_i][f_i][r_i])
                    b_list.append(f_list)
                ans.append(b_list)
            # print ans
            buildings = ans
            # [buildings[b][f][r]+=v if ]
            # buildings[b][f][r] = 2
            # print buildings

    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')
        print "####################"



if __name__ == "__main__":
    main()