{"raw_statement":[{"iden":"statement","content":"Students went into a class to write a test and sat in some way. The teacher thought: \"Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating.\"\n\nThe class can be represented as a matrix with _n_ rows and _m_ columns with a student in each cell. Two students are neighbors if cells in which they sit have a common side.\n\nLet's enumerate students from 1 to _n_·_m_ in order of rows. So a student who initially sits in the cell in row _i_ and column _j_ has a number (_i_ - 1)·_m_ + _j_. You have to find a matrix with _n_ rows and _m_ columns in which all numbers from 1 to _n_·_m_ appear exactly once and adjacent numbers in the original matrix are not adjacent in it, or determine that there is no such matrix."},{"iden":"input","content":"The only line contains two integers _n_ and _m_ (1 ≤ _n_, _m_ ≤ 105; _n_·_m_ ≤ 105) — the number of rows and the number of columns in the required matrix."},{"iden":"output","content":"If there is no such matrix, output \"_NO_\" (without quotes).\n\nOtherwise in the first line output \"_YES_\" (without quotes), and in the next _n_ lines output _m_ integers which form the required matrix."},{"iden":"examples","content":"Input\n\n2 4\n\nOutput\n\nYES\n5 4 7 2 \n3 6 1 8 \n\nInput\n\n2 1\n\nOutput\n\nNO"},{"iden":"note","content":"In the first test case the matrix initially looks like this:\n\n1 2 3 4\n5 6 7 8\n\nIt's easy to see that there are no two students that are adjacent in both matrices.\n\nIn the second test case there are only two possible seatings and in both of them students with numbers 1 and 2 are neighbors."}],"translated_statement":[{"iden":"statement","content":"学生进入教室参加考试，并以某种方式就座。老师想：\"他们很可能这样坐是为了互相抄袭。我需要重新安排他们的座位，使得原来相邻的学生在新座位中不再相邻。\"\n\n班级可以表示为一个包含 #cf_span[n] 行和 #cf_span[m] 列的矩阵，每个单元格中有一名学生。如果两名学生所在的单元格有公共边，则称他们为相邻。\n\n我们将学生从 #cf_span[1] 到 #cf_span[n·m] 按行顺序编号。因此，最初坐在第 #cf_span[i] 行、第 #cf_span[j] 列的学生编号为 #cf_span[(i - 1)·m + j]。你需要找到一个包含 #cf_span[n] 行和 #cf_span[m] 列的矩阵，其中从 #cf_span[1] 到 #cf_span[n·m] 的每个数字恰好出现一次，且原矩阵中相邻的数字在新矩阵中不相邻；若不存在这样的矩阵，则指出这一点。\n\n输入仅包含一行，包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n, m ≤ 105]；#cf_span[n·m ≤ 105]）——即所需矩阵的行数和列数。\n\n如果不存在这样的矩阵，请输出 \"_NO_\"（不含引号）。\n\n否则，在第一行输出 \"_YES_\"（不含引号），然后在接下来的 #cf_span[n] 行中，每行输出 #cf_span[m] 个整数，构成所需的矩阵。\n\n在第一个测试用例中，初始矩阵如下：\n\n容易看出，没有任何两名学生在两个矩阵中都是相邻的。\n\n在第二个测试用例中，只有两种可能的就座方式，而在两种方式中，编号为 1 和 2 的学生都是相邻的。"},{"iden":"input","content":"输入仅包含一行，包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n, m ≤ 105]；#cf_span[n·m ≤ 105]）——即所需矩阵的行数和列数。"},{"iden":"output","content":"如果不存在这样的矩阵，请输出 \"_NO_\"（不含引号）。否则，在第一行输出 \"_YES_\"（不含引号），然后在接下来的 #cf_span[n] 行中，每行输出 #cf_span[m] 个整数，构成所需的矩阵。"},{"iden":"examples","content":"输入\n2 4\n输出\nYES\n5 4 7 2 \n3 6 1 8\n\n输入\n2 1\n输出\nNO"},{"iden":"note","content":"在第一个测试用例中，初始矩阵如下：\n1 2 3 4\n5 6 7 8\n容易看出，没有任何两名学生在两个矩阵中都是相邻的。\n\n在第二个测试用例中，只有两种可能的就座方式，而在两种方式中，编号为 1 和 2 的学生都是相邻的。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ with $ 1 \\leq n, m \\leq 10^5 $ and $ n \\cdot m \\leq 10^5 $.  \nLet $ G = (V, E) $ be the grid graph with $ |V| = n \\cdot m $, where each vertex corresponds to a cell $ (i,j) $ for $ 1 \\leq i \\leq n $, $ 1 \\leq j \\leq m $, and edges connect horizontally/vertically adjacent cells.  \nLabel vertices by $ \\ell(i,j) = (i-1)m + j $, yielding a linear ordering $ L = [1, 2, \\dots, nm] $.  \nLet $ E_{\\text{adj}} = \\{ \\{u, v\\} \\mid u, v \\in V \\text{ are adjacent in } G \\} $.\n\n**Constraints**  \n1. $ n \\cdot m \\leq 10^5 $  \n2. Each integer from $ 1 $ to $ n \\cdot m $ must appear exactly once in the output matrix.  \n3. For any two distinct integers $ a, b \\in \\{1, \\dots, nm\\} $, if $ |a - b| = 1 $, then their positions in the new matrix must **not** be adjacent (i.e., no shared side).\n\n**Objective**  \nDetermine whether there exists a bijection $ f: V \\to \\{1, 2, \\dots, nm\\} $ such that for all $ \\{u, v\\} \\in E_{\\text{adj}} $, $ |f(u) - f(v)| \\neq 1 $.  \nIf such $ f $ exists, output the matrix $ [f(i,j)]_{i=1..n, j=1..m} $; otherwise, output \"NO\".","simple_statement":null,"has_page_source":false}