#CCBCHBA0000122. Lưới số theo hàng zích zắc (Zigzag Number Grid)

Lưới số theo hàng zích zắc (Zigzag Number Grid)

Zigzag Number Grid

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn rows and mm columns, use 1-based row numbers. Odd rows contain 1,2,…,m1,2,\ldots,m; even rows contain m,m−1,…,1m,m-1,\ldots,1. Print exactly nn rows and mm integers per row, separated by one space and without trailing spaces.

Input

One line contains integers n,mn,m, the row and column counts.

Output

Print exactly nn rows.

Subtasks

  • Subtask 1 (20%): 1≤n,m≤31\le n,m\le 3.

  • Subtask 2 (30%): 1≤n,m≤81\le n,m\le 8.

  • Subtask 3 (50%): 1≤n,m≤151\le n,m\le 15.

Examples

Example 1

Input:

3 4

Output:

1 2 3 4
4 3 2 1
1 2 3 4

Explanation:

Odd rows increase; even rows decrease.

Example 2

Input:

1 1

Output:

1

Explanation:

Odd rows increase; even rows decrease.