#include <iostream>
using namespace std;
int main()
{
int n, m, a[150][150] = {}, b;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
double sum = n * m, k = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
cin >> b;
if (a[i][j] == b)
k++;
}
printf("%.2lf", k / sum * 100);
return 0;
}