m,n=map(int,input().split(' ')) list_=[] sum=0 for i in range(2*m): list_num=list(map(int,input().split(' '))) list_.extend(list_num) for i in range(m*n): if list_[i]==list_[i+m*n]: sum+=1 print("{:.2f}".format(100*sum/m/n))
m,n=map(int,input().split(' ')) list_=[] sum=0 for i in range(2*m): list_num=list(map(int,input().split(' '))) list_.extend(list_num) for i in range(m*n): if list_[i]==list_[i+m*n]: sum+=1 print("{:.2f}".format(100*sum/m/n))