/** * @FileName a.cpp * @Author kanpurin * @Created 2022.06.11 03:39:21 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int h,w;cin >> h >> w; if (h%2==0&&w%2==0) { cout << h*w << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cout << 1 << " "; } cout << endl; } } else if (h%2==0) { cout << h*(w-1) << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w-1; j++) { cout << 1 << " "; } cout << 0 << endl; } } else if (w%2 == 0) { cout << (h-1)*w << endl; for (int i = 0; i < h-1; i++) { for (int j = 0; j < w; j++) { cout << 1 << " "; } cout << endl; } for (int j = 0; j < w; j++) { cout << 0 << " "; } cout << endl; } else if (h < w) { cout << h*w-w << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i==j||(i==0&&h<=j)) cout << 0 << " "; else cout << 1 << " "; } cout << endl; } } else { cout << h*w-h << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i==j||(j==0&&w<=i)) cout << 0 << " "; else cout << 1 << " "; } cout << endl; } } return 0; }