#include <stdio.h>

int main() {
    int m, n, cnt = 0;
    scanf("%d %d", &m, &n);
    int arr1[m + 1][n + 1];
    int arr2[m + 1][n + 1];
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &arr1[i][j]);
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &arr2[i][j]);
            if (arr2[i][j] == arr1[i][j]) {
                cnt++;
            }
        }
    }
    printf("%.2f", (float)cnt / (m * n) * 100);
    return 0;
}