n, m = map(int, input().split()) x = n // 2 * 2 y = m // 2 * 2 print(x * y) ans = [[0] * m for _ in range(n)] for i in range(x): for j in range(y): ans[i][j] = 1 for row in ans: print(*row)