import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc=new Scanner(System.in); int H=sc.nextInt(); int W=sc.nextInt(); int[] A=new int[H]; int[] B=new int[W]; int[][] m=new int[H][W]; for(int h=0;h1)++bottom; else ++top; } if(A[h]>1) { int left=Math.min(bottom,(top==0?A[h]:(A[h]-1))); int right=A[h]-left; for(int w=0;w1) { {m[i][w]=s++;B[w]--;} }else m[i][w]=t--; } t=t_-(H-h); } break; } for(int w=0;w