#include <cstdio>
#include <stdlib.h>

#include <iostream>
#include <chrono>


#define B (1*4)
#define N 10000

#if _DEBUG
typedef long lli;
#else
typedef long long int  lli;
#endif

lli a[N*N];
lli b[N*N];
lli c[N*N];

int n,m,l;

void mult() {
    lli t11, t12, t13, t14, t21, t22, t23, t24, t31, t32, t33, t34, t41, t42, t43, t44;
    for(int ib=0; ib<n-B+1; ib+=B)
        for(int jb=0; jb<l-B+1; jb+=B) {
            for(int i=ib; i<ib+B-3; i+=4)
                for(int j=jb; j<jb+B-3; j+=4) {
                    t11 = c[i*N + j];
                    t12 = c[i*N + (j+1)];
                    t13 = c[i*N + (j+2)];
                    t14 = c[i*N + (j+3)];
                    t21 = c[(i+1)*N + j];
                    t22 = c[(i+1)*N + (j+1)];
                    t23 = c[(i+1)*N + (j+2)];
                    t24 = c[(i+1)*N + (j+3)];
                    t31 = c[(i+2)*N + j];
                    t32 = c[(i+2)*N + (j+1)];
                    t33 = c[(i+2)*N + (j+2)];
                    t34 = c[(i+2)*N + (j+3)];
                    t41 = c[(i+3)*N + j];
                    t42 = c[(i+3)*N + (j+1)];
                    t43 = c[(i+3)*N + (j+2)];
                    t44 = c[(i+3)*N + (j+3)];
                    for(int k=0; k<m; k++) {
                        t11 += a[i*N + k] * b[k*N + j];
                        t12 += a[i*N + k] * b[k*N + (j+1)];
                        t13 += a[i*N + k] * b[k*N + (j+2)];
                        t14 += a[i*N + k] * b[k*N + (j+3)];
                        t21 += a[(i+1)*N + k] * b[k*N + j];
                        t22 += a[(i+1)*N + k] * b[k*N + (j+1)];
                        t23 += a[(i+1)*N + k] * b[k*N + (j+2)];
                        t24 += a[(i+1)*N + k] * b[k*N + (j+3)];
                        t31 += a[(i+2)*N + k] * b[k*N + j];
                        t32 += a[(i+2)*N + k] * b[k*N + (j+1)];
                        t33 += a[(i+2)*N + k] * b[k*N + (j+2)];
                        t34 += a[(i+2)*N + k] * b[k*N + (j+3)];
                        t41 += a[(i+3)*N + k] * b[k*N + j];
                        t42 += a[(i+3)*N + k] * b[k*N + (j+1)];
                        t43 += a[(i+3)*N + k] * b[k*N + (j+2)];
                        t44 += a[(i+3)*N + k] * b[k*N + (j+3)];
                    }
                    c[i*N + j] = t11;
                    c[i*N + (j+1)] = t12;
                    c[i*N + (j+2)] = t13;
                    c[i*N + (j+3)] = t14;
                    c[(i+1)*N + j] = t21;
                    c[(i+1)*N + (j+1)] = t22;
                    c[(i+1)*N + (j+2)] = t23;
                    c[(i+1)*N + (j+3)] = t24;
                    c[(i+2)*N + j] = t31;
                    c[(i+2)*N + (j+1)] = t32;
                    c[(i+2)*N + (j+2)] = t33;
                    c[(i+2)*N + (j+3)] = t34;
                    c[(i+3)*N + j] = t41;
                    c[(i+3)*N + (j+1)] = t42;
                    c[(i+3)*N + (j+2)] = t43;
                    c[(i+3)*N + (j+3)] = t44;
                }
        }

    // 下側
    {
        for(int i=n/B*B; i<n-3; i+=4)
            for(int j=0; j<l/B*B-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                t21 = c[(i+1)*N + j];
                t22 = c[(i+1)*N + (j+1)];
                t23 = c[(i+1)*N + (j+2)];
                t24 = c[(i+1)*N + (j+3)];
                t31 = c[(i+2)*N + j];
                t32 = c[(i+2)*N + (j+1)];
                t33 = c[(i+2)*N + (j+2)];
                t34 = c[(i+2)*N + (j+3)];
                t41 = c[(i+3)*N + j];
                t42 = c[(i+3)*N + (j+1)];
                t43 = c[(i+3)*N + (j+2)];
                t44 = c[(i+3)*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t22 += a[(i+1)*N + k] * b[k*N + (j+1)];
                    t23 += a[(i+1)*N + k] * b[k*N + (j+2)];
                    t24 += a[(i+1)*N + k] * b[k*N + (j+3)];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t32 += a[(i+2)*N + k] * b[k*N + (j+1)];
                    t33 += a[(i+2)*N + k] * b[k*N + (j+2)];
                    t34 += a[(i+2)*N + k] * b[k*N + (j+3)];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                    t42 += a[(i+3)*N + k] * b[k*N + (j+1)];
                    t43 += a[(i+3)*N + k] * b[k*N + (j+2)];
                    t44 += a[(i+3)*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
                c[(i+1)*N + j] = t21;
                c[(i+1)*N + (j+1)] = t22;
                c[(i+1)*N + (j+2)] = t23;
                c[(i+1)*N + (j+3)] = t24;
                c[(i+2)*N + j] = t31;
                c[(i+2)*N + (j+1)] = t32;
                c[(i+2)*N + (j+2)] = t33;
                c[(i+2)*N + (j+3)] = t34;
                c[(i+3)*N + j] = t41;
                c[(i+3)*N + (j+1)] = t42;
                c[(i+3)*N + (j+2)] = t43;
                c[(i+3)*N + (j+3)] = t44;
            }
        // 下の右
        for(int i=n/B*B; i<n-3; i+=4)
            for(int j=l/4*4; j<l/B*B; j++)
            {
                t11 = c[i*N + j];
                t21 = c[(i+1)*N + j];
                t31 = c[(i+2)*N + j];
                t41 = c[(i+3)*N + j];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                }
                c[i*N + j] = t11;
                c[(i+1)*N + j] = t21;
                c[(i+2)*N + j] = t31;
                c[(i+3)*N + j] = t41;
            }
        // 下の下
        for(int i=n/B*B + ((n-n/B*B)/4)*4; i<n; i++)
            for(int j=0; j<(l/B*B)-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
            }
        for(int i=n/B*B + ((n-n/B*B)/4)*4; i<n; i++)
            for(int j=(l/4)*4; j<l/B*B; j++) {
                t11 = c[i*N + j];
                for(int k=0; k<m; k++)
                    t11 += a[i*N + k] * b[k*N + j];
                c[i*N + j] = t11;
            }
    }


    //右側
    {
        for(int i=0; i<n/B*B-3; i+=4)
            for(int j=l/B*B; j<l-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                t21 = c[(i+1)*N + j];
                t22 = c[(i+1)*N + (j+1)];
                t23 = c[(i+1)*N + (j+2)];
                t24 = c[(i+1)*N + (j+3)];
                t31 = c[(i+2)*N + j];
                t32 = c[(i+2)*N + (j+1)];
                t33 = c[(i+2)*N + (j+2)];
                t34 = c[(i+2)*N + (j+3)];
                t41 = c[(i+3)*N + j];
                t42 = c[(i+3)*N + (j+1)];
                t43 = c[(i+3)*N + (j+2)];
                t44 = c[(i+3)*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t22 += a[(i+1)*N + k] * b[k*N + (j+1)];
                    t23 += a[(i+1)*N + k] * b[k*N + (j+2)];
                    t24 += a[(i+1)*N + k] * b[k*N + (j+3)];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t32 += a[(i+2)*N + k] * b[k*N + (j+1)];
                    t33 += a[(i+2)*N + k] * b[k*N + (j+2)];
                    t34 += a[(i+2)*N + k] * b[k*N + (j+3)];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                    t42 += a[(i+3)*N + k] * b[k*N + (j+1)];
                    t43 += a[(i+3)*N + k] * b[k*N + (j+2)];
                    t44 += a[(i+3)*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
                c[(i+1)*N + j] = t21;
                c[(i+1)*N + (j+1)] = t22;
                c[(i+1)*N + (j+2)] = t23;
                c[(i+1)*N + (j+3)] = t24;
                c[(i+2)*N + j] = t31;
                c[(i+2)*N + (j+1)] = t32;
                c[(i+2)*N + (j+2)] = t33;
                c[(i+2)*N + (j+3)] = t34;
                c[(i+3)*N + j] = t41;
                c[(i+3)*N + (j+1)] = t42;
                c[(i+3)*N + (j+2)] = t43;
                c[(i+3)*N + (j+3)] = t44;
            }
        // 右の右
        for(int i=0; i<n/B*B-3; i+=4)
            for(int j=l/B*B + ((l-l/B*B)/4)*4; j<l; j++) {
                t11 = c[i*N + j];
                t21 = c[(i+1)*N + j];
                t31 = c[(i+2)*N + j];
                t41 = c[(i+3)*N + j];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                }
                c[i*N + j] = t11;
                c[(i+1)*N + j] = t21;
                c[(i+2)*N + j] = t31;
                c[(i+3)*N + j] = t41;
            }
        // 右の下
        for(int i=n/4*4; i<n/B*B; i++)
            for(int j=l/B*B; j<l-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
            }
        for(int i=(n/4)*4; i<n/B*B; i++)
            for(int j=l/B*B + ((l-B/B*B)/4)*4; j<l; j++) {
                t11 = c[i*N + j];
                for(int k=0; k<m; k++)
                    t11 += a[i*N + k] * b[k*N + j];
                c[i*N + j] = t11;
            }
    }

    // 右下
    {
        for(int i=n/B*B; i<n-3; i+=4)
            for(int j=l/B*B; j<l-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                t21 = c[(i+1)*N + j];
                t22 = c[(i+1)*N + (j+1)];
                t23 = c[(i+1)*N + (j+2)];
                t24 = c[(i+1)*N + (j+3)];
                t31 = c[(i+2)*N + j];
                t32 = c[(i+2)*N + (j+1)];
                t33 = c[(i+2)*N + (j+2)];
                t34 = c[(i+2)*N + (j+3)];
                t41 = c[(i+3)*N + j];
                t42 = c[(i+3)*N + (j+1)];
                t43 = c[(i+3)*N + (j+2)];
                t44 = c[(i+3)*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t22 += a[(i+1)*N + k] * b[k*N + (j+1)];
                    t23 += a[(i+1)*N + k] * b[k*N + (j+2)];
                    t24 += a[(i+1)*N + k] * b[k*N + (j+3)];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t32 += a[(i+2)*N + k] * b[k*N + (j+1)];
                    t33 += a[(i+2)*N + k] * b[k*N + (j+2)];
                    t34 += a[(i+2)*N + k] * b[k*N + (j+3)];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                    t42 += a[(i+3)*N + k] * b[k*N + (j+1)];
                    t43 += a[(i+3)*N + k] * b[k*N + (j+2)];
                    t44 += a[(i+3)*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
                c[(i+1)*N + j] = t21;
                c[(i+1)*N + (j+1)] = t22;
                c[(i+1)*N + (j+2)] = t23;
                c[(i+1)*N + (j+3)] = t24;
                c[(i+2)*N + j] = t31;
                c[(i+2)*N + (j+1)] = t32;
                c[(i+2)*N + (j+2)] = t33;
                c[(i+2)*N + (j+3)] = t34;
                c[(i+3)*N + j] = t41;
                c[(i+3)*N + (j+1)] = t42;
                c[(i+3)*N + (j+2)] = t43;
                c[(i+3)*N + (j+3)] = t44;
            }
        // 右下の右
        for(int i=n/B*B; i<n-3; i+=4)
            for(int j=l/B*B + ((l-l/B*B)/4)*4; j<l; j++) {
                t11 = c[i*N + j];
                t21 = c[(i+1)*N + j];
                t31 = c[(i+2)*N + j];
                t41 = c[(i+3)*N + j];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t21 += a[(i+1)*N + k] * b[k*N + j];
                    t31 += a[(i+2)*N + k] * b[k*N + j];
                    t41 += a[(i+3)*N + k] * b[k*N + j];
                }
                c[i*N + j] = t11;
                c[(i+1)*N + j] = t21;
                c[(i+2)*N + j] = t31;
                c[(i+3)*N + j] = t41;
            }
        for(int i=n/B*B + ((n-n/B*B)/4)*4; i<n; i++)
            for(int j=l/B*B; j<l-3; j+=4) {
                t11 = c[i*N + j];
                t12 = c[i*N + (j+1)];
                t13 = c[i*N + (j+2)];
                t14 = c[i*N + (j+3)];
                for(int k=0; k<m; k++) {
                    t11 += a[i*N + k] * b[k*N + j];
                    t12 += a[i*N + k] * b[k*N + (j+1)];
                    t13 += a[i*N + k] * b[k*N + (j+2)];
                    t14 += a[i*N + k] * b[k*N + (j+3)];
                }
                c[i*N + j] = t11;
                c[i*N + (j+1)] = t12;
                c[i*N + (j+2)] = t13;
                c[i*N + (j+3)] = t14;
            }
        for(int i=n/B*B + ((n-n/B*B)/4)*4; i<n; i++)
            for(int j=l/B*B + ((l-l/B*B)/4)*4; j<l; j++) {
                t11 = c[i*N + j];
                for(int k=0; k<m; k++)
                    t11 += a[i*N + k] * b[k*N + j];
                c[i*N + j] = t11;
            }
    }

}

int main(void) {
#if _DEBUG
    for(n=2; n<N; n*=2) {
        m=l=n;
#else
        scanf("%d%d%d", &n, &m, &l);
#endif


#if _DEBUG
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                a[i*N + j] = rand();
        for(int i=0; i<m; i++)
            for(int j=0; j<l; j++)
                b[i*N + j] = rand();
#else
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                scanf("%lld", &a[i*N + j]);
        for(int i=0; i<m; i++)
            for(int j=0; j<l; j++)
                scanf("%lld", &b[i*N + j]);
#endif
        for(int i=0; i<n; i++)
            for(int j=0; j<l; j++)
                c[i*N + j] = 0;

        auto start = std::chrono::system_clock::now();
        mult();
        auto end = std::chrono::system_clock::now();

#if _DEBUG
        auto dur = end-start;
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        std::cout << n << ":" << msec << " milli sec" << std::endl;
    }
#else
    for(int i=0; i<n; i++) {
        for(int j=0; j<l-1; j++)
            printf("%lld ", c[i*N + j]);
        printf("%lld", c[i*N + l-1]);
        printf("\n");
    }
#endif
    return 0;
}

Measured memory_bytes: 4632