import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), n = sc.nextInt(), i = 0, sum = 0;
        int[] v = new int[m*n];
        while (i < m*n) v[i++] = sc.nextInt();
        i = 0;
        while (i < m*n) sum += (v[i++] + sc.nextInt())%2;
        System.out.printf("%.2f", (1 - (double)sum/m/n)*100);
    }
}