Ms. Kuso is giving her students a chemistry exam! In order to ensure the fairness of the exam, she will create different versions of the exam, each having an ID from to , such that any student that is sitting adjacent to any other student (including diagonals) will have exams with differing IDs.
However, making separate versions of exams is a very tedious task! As such, Ms. Kuso has given you the task of assigning exams to each student. Your task is to minimize the number of exams that Ms. Kuso must create.
The students will sit in an grid of desks.
Constraints
Input Specification
The first and only line will contain two space-separated integers, and .
Output Specification
On the first line, output , the minimum number of different exams that Ms. Kuso must create.
Then, output an grid of integers, where each integer represents the ID of the exam that each student sitting at each seat should receive. If there are multiple possible configurations, output any one of them.
Exam IDs should run from to , inclusive.
Sample Input 1
2 2
Sample Output 1
4
1 2
3 4
Sample Input 2
1 5
Sample Output 2
2
1 2 1 2 1
Comments