m, n = map(int, input().split()) val1 = [] val2 = [] cnt = 0 for i in range(m): nums1 = list(map(int, input().split())) val1.append(nums1) for i in range(m): nums2 = list(map(int, input().split())) val2.append(nums2) for i in range(m): for j in range(n): if val1[i][j] == val2[i][j]: cnt += 1 sim = cnt / (m*n) * 100 print("%.2f" % sim)