main=interact$(>>=(1%).map read.words).lines 0%_="\n" _%x=unwords(map show x)++'\n':sum x%map abs(zipWith(-)x$tail x++x)