const maxn=90; type tt=array[1..maxn,1..maxn]of longint; var row,col:byte; best,b:tt; map:array[0..1]of tt; k,m:longint; procedure init; var i,j:longint; begin readln(row,col); for i:=1 to row do begin for j:=1 to col-1 do read(map[0,i,j]); readln end; for j:=1 to col do begin for i:=1 to row-1 do read(map[1,i,j]); readln; end; end; function getET(s,u:longint;var e:longint;var t:longint):boolean; begin if ((k>=row)and(s=1)and(u=1))or (k>=col)and(s=m)and(u=0) then begin getET:=false; exit; end; if km2 then m:=row+col-k else m:=m1; b:=best; for s1:=1 to m do for s2:=1 to m do begin best[s1,s2]:=maxlongint; for u1:=0 to 1 do if getET(s1,u1,e1,t1) then for u2:=0to 1 do begin if ((s1<>s2)or(u1<>u2))and (b[t1,t2]+e1+e2