#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); int H,W; cin >> H >> W; vector> ans(H, vector(W, 0)); rep(i,H)rep(j,W) if(ans[i][j] == 0 && i + 1 < H && j + 1 < W) { ans[i][j] = ans[i + 1][j] = ans[i][j + 1] = ans[i + 1][j + 1] = 1; } if(ans[H - 1][W - 1] == 0 && ans[H - 2][W - 1] == 0 && ans[H - 1][W - 2] == 0) { ans[H - 1][W - 1] = 1; ans[H - 2][W - 1] = 1; ans[H - 1][W - 2] = 1; ans[H - 2][W - 2] = 0; } int cnt = 0; rep(i,H)rep(j,W) cnt += ans[i][j]; cout << cnt << "\n"; rep(i,H)rep(j,W) cout << ans[i][j] << " \n"[j == W - 1]; }