#include<stdio.h>
int main()
{
    int arr1[100][100] = { 0 };
    int arr2[100][100] = { 0 };
    int n, m;
    int c = 0;
    scanf("%d%d", &n, &m);
    int r, f = 0;;
    for (r = 0; r < n; r++) {
        for (c = 0; c < m; c++) {
            scanf("%d", &arr1[r][c]);
        }
    }
    for (r = 0; r < m; r++) {
        for (c = 0; c < m; c++) {
            scanf("%d", &arr2[r][c]);
            if (arr1[r][c] == arr2[r][c])
                f++;
        }
    }
    float   s = f*1.0/(n * n)*100 ;
    printf("%.2f", s);
    return 0;
}