H,W = map(int, input().split()) MAP = [[1]*W for _ in range(H)] if H>1 and W>1 and H%2==1 and W%2==1: MAP[H-1][W-1]=0 elif H%2==1: MAP[H-1]=[0]*W elif W%2==1: for i in range(H): MAP[i][W-1]=0 ans = 0 for map in MAP: ans+=sum(map) print(ans) for map in MAP: print(*map)