#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    int same_count = 0;
    int total = n * m;
    
    // 读取并比较两幅图像的像素
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int pixel1, pixel2;
            cin >> pixel1;
        }
        // 错误:此处应读取第二幅图像的对应像素并比较
        for (int j = 0; j < m; ++j) {
            int pixel2;
            cin >> pixel2;
            // 比较像素
            if (pixel1 == pixel2) {
                same_count++;
            }
        }
    }
    
    // 计算相似度百分比
    double similarity = (double)same_count / total * 100;
    
    // 输出结果,保留两位小数
    cout << fixed << setprecision(2) << similarity << endl;
    
    return 0;
}

/**************************************************************
	Problem: 1407
	User: fuyijun
	Language: C++
	Result: Compile Error
****************************************************************/