import java.util.*;
import java.lang.*;
class Main
{
public static void main
(String[] args
) {
Scanner input
= new Scanner
(System.
in); int n = input.nextInt();
int m = input.nextInt();
int x[][] = new int[n][];
for (int i = 0; i < n; i++)
x[i] = new int[m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
x[i][j] = input.nextInt();
System.
out.
println(m
+ " " + n
); for (int j = 0; j < m; j++){
for (int i = n - 1; i >= 0; i--)
System.
out.
print(x
[i
][j
] + " "); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKQoJewoJCVNjYW5uZXIgaW5wdXQgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBuID0gaW5wdXQubmV4dEludCgpOwoJCWludCBtID0gaW5wdXQubmV4dEludCgpOwoJCWludCB4W11bXSA9IG5ldyBpbnRbbl1bXTsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykKCQkJeFtpXSA9IG5ldyBpbnRbbV07CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJCWZvciAoaW50IGogPSAwOyBqIDwgbTsgaisrKQoJCQkJeFtpXVtqXSA9IGlucHV0Lm5leHRJbnQoKTsKCQlTeXN0ZW0ub3V0LnByaW50bG4obSArICIgIiArIG4pOwoJCWZvciAoaW50IGogPSAwOyBqIDwgbTsgaisrKXsKCQkJZm9yIChpbnQgaSA9IG4gLSAxOyBpID49IDA7IGktLSkKCQkJCVN5c3RlbS5vdXQucHJpbnQoeFtpXVtqXSArICIgIik7CgkgICAgCVN5c3RlbS5vdXQucHJpbnRsbigpOwoJCX0gICAKCX0KfQ==