Matrix multiplication
Given two square matrices A and B of dimensions m × n and n × q respectively:
Then the matrix C of dimension m × q is called their product:
where:
The operation of multiplication of two matrices is feasible only if the number of columns in the first factor equals to the number of rows in the second. In this case we say that the shape of the matrices is consistent.
Given two matrices A and B. Find their product.
Input
The first line contains two positive integers n[a]
and m[a]
- the dimensions of matrix A. Each of the next n[a]
rows contains m[a]
numbers - the elements a[ij]
of matrix A. In (n[a]
+ 2)-nd row two positive integers n[b]
and m[b]
are given - the dimensions of matrix B. In the following n[b]
lines m[b]
numbers are given - the elements b[ij]
of matrix B. Dimensions of the matrices do not exceed 100 × 100, all integers do not exceed 100 by absolute value.
Output
Print in the first line the dimensions of the resulting matrix C: n[с]
and m[c]
. In the next n[с]
rows print space separated m[c]
numbers - the corresponding elements c[ij]
of matrix C. If you cannot multiply matrixs in the first and only line of output -1.