import java.util.*;

import java.math.RoundingMode;
import java.text.DecimalFormat;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        // 四舍五入操作
        DecimalFormat df = new DecimalFormat("0.00");
        df.setRoundingMode(RoundingMode.HALF_UP);

        while (in.hasNext()) { // 注意 while 处理多个 case
            int width = in.nextInt();
            int height = in.nextInt();
            int[][] firstImg = new int[width][height];

            double allDot = (double) width * height;
            double equalDotNum = 0;

            // 记录图像一
            for (int i = 0; i < firstImg.length; i++) {
                // 行
                for (int j = 0; j < firstImg[i].length; j++) {
                    // 列
                    firstImg[i][j] = in.nextInt();
                }
            }
            
            // 可直接判断了
            for (int i = 0; i < firstImg.length; i++) {
                // 行
                for (int j = 0; j < firstImg[i].length; j++) {
                    // 列
                    if (firstImg[i][j] == in.nextInt()) {
                        equalDotNum++;
                    }
                }
            }

            System.out.println(df.format(equalDotNum / allDot * 100));

        }
    }
}