#include<stdio.h>
int main() {
    int n, m;
    int i, j, count = 0;
    float xs ;
    int a[10][10] = {0}, b[10][10] = {0};
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d ", &a[i][j]);
        }
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d ", &b[i][j]);
            if (a[i][j] == b[i][j])
                count++;
        }
    }

    xs = 100.0*count / (m * n);
    printf("%.2f\n", xs);
}