PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000142. Bảng không có hiệu nguyên tố (No Prime Differences)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bảng không có hiệu nguyên tố (No Prime Differences)

No Prime Differences

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given integers n,mn,m, fill an n×mn\times m grid with the integers from 11 to n⋅mn\cdot m, using each number exactly once.

Two cells are adjacent if they share a side. For every adjacent pair of cells, the absolute difference between their values must not be prime.

A valid arrangement is guaranteed to exist. Print any valid arrangement.

Input

One line contains integers n,mn,m.

Output

Print nn rows of mm integers. Every value from 11 to n⋅mn\cdot m must appear exactly once, and every side-adjacent absolute difference must be nonprime.

Subtasks

  • Subtask 1 (20 points): 4≤n,m≤74\le n,m\le7; n⋅m≤49n\cdot m\le49.
  • Subtask 2 (30 points): 4≤n,m≤604\le n,m\le60; n⋅m≤3600n\cdot m\le3600.
  • Subtask 3 (50 points): 4≤n,m≤10004\le n,m\le1000; n⋅m≤106n\cdot m\le10^6.

Examples

Input

4 4

Output

5 6 7 8
13 14 15 16
1 2 3 4
9 10 11 12

Explanation

The grid uses each number from 11 to 1616 once. Horizontal neighbors differ by 11, which is not prime. Vertical neighbors between consecutive rows differ by 88, 1212, and 88, all composite. Thus the grid is valid; other arrangements are allowed.