import java.util.Scanner;
public class Main {
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int na = scanner.nextInt();
int ma = scanner.nextInt();
int[][] a = new int[na][ma];
for (int i = 0; i < na; i++) {
for (int j = 0; j < ma; j++) {
a[i][j] = scanner.nextInt();
}
}
int nb = scanner.nextInt();
int mb = scanner.nextInt();
if (ma != nb) {
return;
}
int[][] b = new int[nb][mb];
for (int i = 0; i < nb; i++) {
for (int j = 0; j < mb; j++) {
b[i][j] = scanner.nextInt();
}
}
int[][] c = new int[na][mb];
for (int i = 0; i < na; i++) {
for (int j = 0; j < mb; j++) {
for (int r = 0; r < ma; r++) {
c[i][j] += a[i][r] * b[r][j];
}
}
}
System.
out.
print(na
+ " " + mb
+ "\n"); for (int i = 0; i < na; i++) {
for (int j = 0; j < mb; j++) {
if (j
+ 1 != mb
) System.
out.
print(" "); }
}
}
}