#include using namespace std; int main(){ int H, W; cin >> H >> W; vector> A(H, vector(W, 0)); int ans = 0; for (int i = 0; i < H - 1; i += 2){ for (int j = 0; j < W - 1; j += 2){ A[i][j] = 1; A[i][j + 1] = 1; A[i + 1][j] = 1; A[i + 1][j + 1] = 1; ans += 4; } } if (H >= 3 && W >= 3 && H % 2 == 1 && W % 2 == 1){ A[H - 2][W - 2] = 0; A[H - 1][W - 2] = 1; A[H - 2][W - 1] = 1; A[H - 1][W - 1] = 1; ans += 2; } cout << ans << endl; for (int i = 0; i < H; i++){ for (int j = 0; j < W; j++){ cout << A[i][j]; if (j < W - 1){ cout << ' '; } } cout << endl; } }