a,b = map(int,input().split())
list1 = []
sum = 0
for i in range(a):
list1.extend(list(map(int,input().split())))
for i in list1:
if i>0:
sum+=i
print(sum)
n,m = map(int,input().strip().split())
A = [list(map(int,input().strip().split())) for i in range(n)]
sum = 0
for j in A :
for k in j :
if k > 0 :
sum += k
print(sum)