#include <stdio.h>
int main()
{
    int i, j, count = 0;
    int arr[100][100] = {0};
    int arr2[100][100] = {0};
    int m,n,z;
    scanf("%d%d", &m,&n);
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &arr2[i][j]);
        }
    }
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            if (arr[i][j] == arr2[i][j])
            {
                count++;
            }
        }
    }
    z = m * n;
    float Similarity;
    Similarity = 100.0*(float)count /(float) z;
    printf("%.2f", Similarity);
    return 0;
}