def solution(land):
answer = 0
an = {i:land[0][i] for i in range(len(land[0]))}
for i in range(1,len(land)):
ll = land[i]
jj = {i:[] for i in range(len(land[0]))}
new_an = {i:0 for i in range(len(land[0]))}
for k in an:
a = ll[k]
if k == 0:
jj[k].append(a+an[1])
jj[k].append(a+an[2])
jj[k].append(a+an[3])
elif k == 1:
jj[k].append(a+an[0])
jj[k].append(a+an[2])
jj[k].append(a+an[3])
elif k == 2:
jj[k].append(a+an[0])
jj[k].append(a+an[1])
jj[k].append(a+an[3])
elif k == 3:
jj[k].append(a+an[0])
jj[k].append(a+an[1])
jj[k].append(a+an[2])
for k in jj:
new_an[k] = max(jj[k])
an = new_an
answer = max(new_an.values())
return answer