13 lines
307 B
Python
13 lines
307 B
Python
|
import sys
|
||
|
|
||
|
L = [list(map(int,l.split(' '))) for l in sys.stdin.read().splitlines()]
|
||
|
|
||
|
def extrapolate(L):
|
||
|
if all(a == 0 for a in L):
|
||
|
return 0
|
||
|
M = [b-a for a,b in zip(L,L[1:])]
|
||
|
return L[-1]+extrapolate(M)
|
||
|
|
||
|
print(sum(extrapolate(l) for l in L))
|
||
|
print(sum(extrapolate(l[::-1]) for l in L))
|