#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int m, n;
    cin >> m >> n; //m行n列
    int arr1[100][100] = { {0} };
    int arr2[100][100] = { {0} };
    int count=0;
    double sameforce;
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> arr1[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> arr2[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (arr1[i][j] == arr2[i][j])
            {
                count++;
            }
        }
    }
    sameforce = (100.0 * count) / (m * n);
    cout <<fixed<<setprecision(2)<< sameforce << endl;
}