int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int val[2][n][m];
    double count = 0.0;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < m; k++) {
                scanf("%d ", &val[i][j][k]);  //依次输入整数
            }
        }
        if (i == 1) {  //第二次矩阵输入结束时
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < m; k++) {
                    //判断两个矩阵相同点的个数
                    if (val[0][j][k] == val[1][j][k]) count += 1;
                }
            }
        }
    }
    printf("%.2f", (count / (n * n)) * 100);  //输出两个矩阵的相似度值
    return 0;
}