import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr1 = new int[n][m];
        int[][] arr2 = new int[n][m];
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                arr1[i][j] = sc.nextInt();
            }
        }
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                arr2[i][j] = sc.nextInt();
            }
        }
        int count = 0 ;    // 记录相同的像素点的个数
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                if(arr1[i][j] == arr2[i][j]) {
                    count++;
                }
            }
        }
        double re = count*1.0 / (n * m) * 100;
        System.out.println(String.format("%.2f",re));
    }
}