a = []
b = []
m,n = map(int, input().split())
for i in range(m):
    l = list(map(int, input().split()))
    a.append(l)
for i in range(m):
    l = list(map(int, input().split()))
    b.append(l)

x = 0
for i in range(m):
    for j in range(n):
        if a[i][j] == b[i][j]:
            x += 1
print('{:.2f}'.format(x/(m*n)*100))