// editor4
int main() {
    int m, n, p, q;

    // Read dimensions of the first matrix
    scanf("%d %d", &m, &n);

    int A[m]; // Declare first matrix

    // Read elements of the first matrix
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    // Read dimensions of the second matrix
    scanf("%d %d", &p, &q);

    int B[p][q]; // Declare second matrix

    // Read elements of the second matrix
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < q; j++) {
            scanf("%d", &B[i][j]);
        }
    }

    // Check for invalid input condition before declaring result matrix
    if (n != p) {
        printf("Invalid input\n");
        return 0; // Exit if matrices cannot be multiplied
    }

    int C[m][q]; // Declare result matrix

    // Call the matrix multiplication function
    multiplyMatrices(m, n, p, q, A, B, C);

    // Print the result matrix
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < q; j++) {
            printf("%d%s", C[i][j], (j == q - 1) ? "" : " "); // Print elements with space separation
        }
        printf("\n"); // New line after each row
    }

    return 0; // Indicate successful execution
}