while True:
    try:
        num=input().split(" ")
        m,n=map(int,num)
        pixel_lista=[]
        pixel_listb=[]
        same_count=0
        for i in range(m):
            pixel=input().split(" ")
            pixel_lista.append(list(map(int,pixel)))
        for i in range(m):
            pixel=input().split(" ")
            pixel_listb.append(list(map(int,pixel)))
        for i in range(m):
            for j in range(n):
                if pixel_lista[i][j]==pixel_listb[i][j]:
                    same_count+=1
        print("{:.2f}".format(same_count*100/(m*n)))
    except:
        break